diff --git a/controls/cis_sle15.yml b/controls/cis_sle15.yml index 5141249b830..86244e08099 100644 --- a/controls/cis_sle15.yml +++ b/controls/cis_sle15.yml @@ -1123,7 +1123,10 @@ controls: levels: - l1_server - l1_workstation - status: manual # rule is missing + status: automated + rules: + - var_nftables_master_config_file=sysconfig + - nftables_ensure_default_deny_policy - id: 3.5.2.9 title: Ensure nftables service is enabled (Automated) @@ -1141,7 +1144,7 @@ controls: - l1_workstation status: automated rules: - - var_nftable_master_config_file=sysconfig + - var_nftables_master_config_file=sysconfig - nftables_rules_permanent - id: 3.5.3.1.1 diff --git a/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/oval/sle15.xml b/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/oval/sle15.xml new file mode 100644 index 00000000000..760b3fbffaf --- /dev/null +++ b/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/oval/sle15.xml @@ -0,0 +1,66 @@ + + + {{{ oval_metadata("Make sure that there is permanent nftables configuration is configured + with default chains policy drop") }}} + + + + + + + + + + + ^[\s]*include[\s]+\"([^\s]+)"$ + 1 + + + + + + + + + + + + + + + + + + + + var_{{{ rule_id }}}_include_chains_configurations + + + + + \s*chain\s*\w*\s*\{([^\}]*)\} + 1 + + + + \;\s*policy drop\s*\; + + + + + + + + diff --git a/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/rule.yml b/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/rule.yml new file mode 100644 index 00000000000..e756df247d0 --- /dev/null +++ b/linux_os/guide/system/network/network-nftables/nftables_ensure_default_deny_policy/rule.yml @@ -0,0 +1,36 @@ +documentation_complete: true + +prodtype: sle15 + +title: 'Ensure nftables Default Deny Firewall Policy' + +description: |- + Base chain policy is the default verdict that will be applied to packets reaching the end of + the chain. There are two policies: accept (Default) and drop. If the policy is set to accept, + the firewall will accept any packet that is not configured to be denied and the packet will + continue traversing the network stack. + +rationale: |- + It is easier to allow acceptable usage than to block unacceptable usage. + +severity: medium + +identifiers: + cce@sle15: CCE-92507-3 + +references: + cis@sle15: 3.5.2.8 + +ocil_clause: 'default policy is not set for nftables rules' + +warnings: + - general: |- + Changing firewall settings while connected over network can result in being locked out + of the system. + +ocil: |- + Run the following commands and verify that base chains policy is drop: +
$ sudo nft list ruleset | grep 'hook input' 
+ Output should include a list of nftables similar to: + type filter hook input priority 0; policy drop; + Same goes not only for hook input, but also output and forward diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/ansible/sle15.yml b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/ansible/sle15.yml index e5ccfa359f8..e0f70da61c6 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/ansible/sle15.yml +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/ansible/sle15.yml @@ -3,15 +3,15 @@ # strategy = restrict # complexity = low # disruption = low -{{{ ansible_instantiate_variables("var_nftable_master_config_file") }}} +{{{ ansible_instantiate_variables("var_nftables_master_config_file") }}} - name: Check the top-level configuration file exists ansible.builtin.stat: - path: "{{ var_nftable_master_config_file }}" + path: "{{ var_nftables_master_config_file }}" - name: Check the {{{ family }}} relevant file is included configuration ansible.builtin.lineinfile: - path: "{{ var_nftable_master_config_file }}" + path: "{{ var_nftables_master_config_file }}" line: 'include "/etc/nftables/{{ item }}-filter"' create: yes loop: diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/bash/sle15.sh b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/bash/sle15.sh index 4b660b5c0c8..1308c0a66bc 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/bash/sle15.sh +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/bash/sle15.sh @@ -6,13 +6,13 @@ {{% set nftables_family_names = ['bridge', 'arp', 'inet'] %}} -{{{ bash_instantiate_variables("var_nftable_master_config_file") }}} +{{{ bash_instantiate_variables("var_nftables_master_config_file") }}} -if [ ! -f "${var_nftable_master_config_file}" ]; then - touch "${var_nftable_master_config_file}" +if [ ! -f "${var_nftables_master_config_file}" ]; then + touch "${var_nftables_master_config_file}" fi {{% for family in nftables_family_names %}} -grep -qxF 'include "/etc/nftables/{{{ family }}}-filter"' "${var_nftable_master_config_file}" \ - || echo 'include "/etc/nftables/{{{ family }}}-filter"' >> "${var_nftable_master_config_file}" +grep -qxF 'include "/etc/nftables/{{{ family }}}-filter"' "${var_nftables_master_config_file}" \ + || echo 'include "/etc/nftables/{{{ family }}}-filter"' >> "${var_nftables_master_config_file}" {{% endfor %}} diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/oval/sle15.xml b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/oval/sle15.xml index 855cc755269..4f75b3c82cf 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/oval/sle15.xml +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/oval/sle15.xml @@ -36,12 +36,12 @@ {{% endfor %}} - + ^[\s]*include[\s]+\"([^\s]+)"$ 1 + id="var_nftables_master_config_file" version="1"/> diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/rule.yml b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/rule.yml index c3199abc5d1..0e096207abe 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/rule.yml +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/rule.yml @@ -2,12 +2,12 @@ documentation_complete: true prodtype: sle15 -title: 'Ensure nftables rules are permanent' +title: 'Ensure nftables Rules are Permanent' description: |- nftables is a subsystem of the Linux kernel providing filtering and classification of network packets/datagrams/frames. The nftables service reads the - {{{ xccdf_value("var_nftable_master_config_file") }}} file for a nftables file or files to + {{{ xccdf_value("var_nftables_master_config_file") }}} file for a nftables file or files to include in the nftables ruleset. A nftables ruleset containing the input, forward, and output base chains allow network traffic to be filtered. @@ -31,18 +31,18 @@ ocil: |- Run the following command to verify the input base chain:
     # awk '/hook input/,/}/' $(awk '$1 ~ /^\s*include/ { gsub("\"","",$2);print $2 }' \
-    {{{ xccdf_value("var_nftable_master_config_file") }}})
+    {{{ xccdf_value("var_nftables_master_config_file") }}})
     
or for forward base chain:
     # awk '/hook forward/,/}/' $(awk '$1 ~ /^\s*include/ { gsub("\"","",$2);print $2 }' \
-    {{{ xccdf_value("var_nftable_master_config_file") }}})
+    {{{ xccdf_value("var_nftables_master_config_file") }}})
     
Review the base chains to ensure that they follow local site policy fixtext: |- - Edit the {{{ xccdf_value("var_nftable_master_config_file") }}} file and un-comment or add + Edit the {{{ xccdf_value("var_nftables_master_config_file") }}} file and un-comment or add a line with include absolute path to nftables rules file for each nftables file you want included in the nftables ruleset on boot. - For example the {{{ xccdf_value("var_nftable_master_config_file") }}} should contain + For example the {{{ xccdf_value("var_nftables_master_config_file") }}} should contain
include "/etc/nftables/nftables.rules"
diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/invalid_top_level_config_file.fail.sh b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/invalid_top_level_config_file.fail.sh index 67f986f06a6..02d9bb6343c 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/invalid_top_level_config_file.fail.sh +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/invalid_top_level_config_file.fail.sh @@ -1,4 +1,4 @@ -# variables = var_nftable_master_config_file=/etc/sysconfig/nftables.conf +# variables = var_nftables_master_config_file=/etc/sysconfig/nftables.conf # make sure that variable is set correctly on new platform adding echo 'include /some/invalid/path' > "/etc/sysconfig/nftables.conf" diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/no_top_level_config_file.fail.sh b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/no_top_level_config_file.fail.sh index c028d697d40..b8c08827bee 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/no_top_level_config_file.fail.sh +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/no_top_level_config_file.fail.sh @@ -1,3 +1,3 @@ -# variables = var_nftable_master_config_file=/etc/sysconfig/nftables.conf +# variables = var_nftables_master_config_file=/etc/sysconfig/nftables.conf rm "/etc/sysconfig/nftables.conf" diff --git a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/valid_top_level_config_file.pass.sh b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/valid_top_level_config_file.pass.sh index 74bca260ca9..d799ba2ba9b 100644 --- a/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/valid_top_level_config_file.pass.sh +++ b/linux_os/guide/system/network/network-nftables/nftables_rules_permanent/tests/valid_top_level_config_file.pass.sh @@ -1,4 +1,4 @@ -# variables = var_nftable_master_config_file=/etc/sysconfig/nftables.conf +# variables = var_nftables_master_config_file=/etc/sysconfig/nftables.conf {{% set nftables_family_names = ['bridge', 'arp', 'inet'] %}} # make sure file starts from empty diff --git a/linux_os/guide/system/network/network-nftables/var_nftable_master_config_file.var b/linux_os/guide/system/network/network-nftables/var_nftables_master_config_file.var similarity index 100% rename from linux_os/guide/system/network/network-nftables/var_nftable_master_config_file.var rename to linux_os/guide/system/network/network-nftables/var_nftables_master_config_file.var diff --git a/shared/references/cce-sle15-avail.txt b/shared/references/cce-sle15-avail.txt index f5f4b4efee6..d04397ac62e 100644 --- a/shared/references/cce-sle15-avail.txt +++ b/shared/references/cce-sle15-avail.txt @@ -16,7 +16,6 @@ CCE-92501-6 CCE-92503-2 CCE-92505-7 CCE-92506-5 -CCE-92507-3 CCE-92508-1 CCE-92509-9 CCE-92510-7