Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New SLE 15 rule set_nftables_table #10128

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion controls/cis_sle15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,14 @@ controls:
levels:
- l1_server
- l1_workstation
status: manual # rule is missing
status: automated
notes:
The audit (OVAL check) cannot be automated,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a side note, if you are willing to not be SCAP compliant SCE (script check engine) content could be used on this rule to automate the check.

and should be addressed manually.
rules:
- set_nftables_table
- var_nftables_family=inet
- var_nftables_table=filter

- id: 3.5.2.5
title: Ensure base chains exist (Automated)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# platform = multi_platform_sle
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low

{{{ ansible_instantiate_variables("var_nftables_family") }}}
{{{ ansible_instantiate_variables("var_nftables_table") }}}

- name: Collect existing nftables
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.shell: nft list tables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need ansible.builtin.shell or will ansible.builtin.command work? ansible.builtin.command is preferred.

register: existing_nftables

- name: Set nftable table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Set nftable table
- name: Set Nftable Table

ansible.builtin.shell: nft create table {{ var_nftables_family }} {{ var_nftables_table }}
when: existing_nftables.stdout_lines | length == 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# platform = multi_platform_sle

#Set nftables family name
{{{ bash_instantiate_variables("var_nftables_family") }}}
NETWORK_LEVEL=$var_nftables_family
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be removed, and just the variables directly in your command.


#Set nftables table name
{{{ bash_instantiate_variables("var_nftables_table") }}}
TABLE_NAME=$var_nftables_table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.


IS_TABLE=$(nft list tables)
if [ -z "$IS_TABLE" ]
then
nft create table "$NETWORK_LEVEL" "$TABLE_NAME"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
documentation_complete: true

prodtype: sle15

title: 'Ensure a table exists for nftables'
Mab879 marked this conversation as resolved.
Show resolved Hide resolved

description: |-
Tables in nftables hold chains. Each table only has one address family and only applies
to packets of this family. Tables can have one of six families.

rationale: |-
Nftables doesn't have any default tables. Without a table being build, nftables will not filter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Nftables doesn't have any default tables. Without a table being build, nftables will not filter
Nftables doesn't have any default tables. Without a table being built, nftables will not filter

network traffic.
<b>Impact</b>Adding rules to a running nftables can cause loss of connectivity to the system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<b>Impact</b>Adding rules to a running nftables can cause loss of connectivity to the system
Note: adding rules to a running nftables can cause loss of connectivity to the system.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add warning like this about risk of losing connectivity to the system.

severity: medium

identifiers:
cce@sle15: CCE-92569-3

references:
cis@sle15: 3.5.2.4

ocil_clause: 'nftables table does not exist'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ocil_clause: 'nftables table does not exist'
ocil_clause: 'a nftables table does not exist'


ocil: |-
To verify that a nftables table exists, run the following command:
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved
<pre>$ sudo nft list tables</pre>
Mab879 marked this conversation as resolved.
Show resolved Hide resolved
Output should include a list of nftables similar to:
<tt>
table inet filter
</tt>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
documentation_complete: true

title: 'Nftables families'
Mab879 marked this conversation as resolved.
Show resolved Hide resolved


description: |-
Netfilter enables filtering at multiple networking levels. With iptables there
is a separate tool for each level: iptables, ip6tables, arptables, ebtables.
With nftables the multiple networking levels are abstracted into families,
all of which are served by the single tool nft.
<tt>ip</tt>Tables of this family see IPv4 traffic/packets.
<tt>ip6</tt>Tables of this family see IPv6 traffic/packets.
<tt>inet</tt>Tables of this family see both IPv4 and IPv6 traffic/packets,
simplifying dual stack support.
<tt>arp</tt>Tables of this family see ARP-level (i.e, L2) traffic, before
any L3 handling is done by the kernel.
<tt>bdidge</tt>Tables of this family see traffic/packets traversing bridges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<tt>bdidge</tt>Tables of this family see traffic/packets traversing bridges
<tt>bridge</tt>Tables of this family see traffic/packets traversing bridges

(i.e. switching). No assumptions are made about L3 protocols.
<tt>netdev</tt>The netdev family is different from the others in that it
is used to create base chains attached to a single network interface. Such
base chains see all network traffic on the specified interface, with no
assumptions about L2 or L3 protocols. Therefore you can filter ARP traffic from here.

type: string

operator: equals

interactive: true

options:
default: inet
ip: ip
ip6: ip6
inet: inet
arp: arp
bridge: bridge
netdev: netdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
documentation_complete: true

title: 'Nftables tables'
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved

rumch-se marked this conversation as resolved.
Show resolved Hide resolved

description: |-
Tables in nftables hold chains. Each table only has one address family and only applies
to packets of this family. Tables can have one of six families.

type: string

operator: equals

interactive: true

options:
default: filter
filter: filter
1 change: 0 additions & 1 deletion shared/references/cce-sle15-avail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ CCE-92565-1
CCE-92566-9
CCE-92567-7
CCE-92568-5
CCE-92569-3
CCE-92570-1
CCE-92571-9
CCE-92572-7
Expand Down