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

SLE15 add nftables ensure default deny policy #10249

Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 4 additions & 1 deletion controls/cis_sle15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,10 @@ controls:
levels:
- l1_server
- l1_workstation
status: manual # rule is missing
status: automated
rules:
- var_nftable_master_config_file=sysconfig
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved
- nftables_ensure_default_deny_policy

- id: 3.5.2.9
title: Ensure nftables service is enabled (Automated)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<def-group>
<definition class="compliance" id="{{{ rule_id }}}" version="1">
{{{ oval_metadata("Make sure that there is permanent nftables configuration is configured
with default chains policy drop") }}}
<criteria operator="AND">
<criterion test_ref="test_{{{ rule_id }}}_file"
comment="Check the existence of top level nftables configuration file" />
<criterion test_ref="test_{{{ rule_id }}}_include_chains_policy"
comment="Check the contents of configuration files for default chains policy"/>
</criteria>
</definition>
<ind:textfilecontent54_test id="test_{{{ rule_id }}}_file"
comment="Check top level configuration file is named as expected"
check="all" check_existence="all_exist" version="1">
<ind:object object_ref="object_{{{ rule_id }}}_file" />
</ind:textfilecontent54_test>
<ind:textfilecontent54_object id="object_{{{ rule_id }}}_file" version="1">
<ind:filepath operation="equals" var_ref="var_nftable_master_config_file"/>
<ind:pattern operation="pattern match">^[\s]*include[\s]+\"([^\s]+)"$</ind:pattern>
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
</ind:textfilecontent54_object>
<external_variable comment="file path" datatype="string"
id="var_nftable_master_config_file" version="1"/>
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved
<local_variable id="var_{{{ rule_id }}}_families_config_paths" datatype="string" version="1"
comment="File paths of all needed families part of the permanent configuration">
<unique>
<glob_to_regex>
<object_component item_field="subexpression" object_ref="object_{{{ rule_id }}}_file" />
</glob_to_regex>
</unique>
</local_variable>

teacup-on-rockingchair marked this conversation as resolved.
Show resolved Hide resolved

<local_variable id="var_{{{ rule_id }}}_include_chains_configurations" datatype="string" version="1"
comment="Chain configuration statements">
<unique>
<glob_to_regex>
<object_component item_field="subexpression" object_ref="object_{{{ rule_id }}}_include_chains_policy" />
</glob_to_regex>
</unique>
</local_variable>

<ind:variable_object id="object_var_{{{ rule_id }}}_include_chains_configurations" version="1">
<ind:var_ref>var_{{{ rule_id }}}_include_chains_configurations</ind:var_ref>
</ind:variable_object>

teacup-on-rockingchair marked this conversation as resolved.
Show resolved Hide resolved

<ind:textfilecontent54_object id="object_{{{ rule_id }}}_include_chains_policy" version="1">
<ind:filepath operation="pattern match" var_check="at least one"
var_ref="var_{{{ rule_id }}}_families_config_paths"/>
<ind:pattern operation="pattern match"
>\s*chain\s*\w*\s*\{([^\}]*)\}</ind:pattern>
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
</ind:textfilecontent54_object>

<ind:variable_state id="state_{{{ rule_id }}}_include_chains_policy"
comment="policy should be drop" version="1">
<ind:value datatype="string" operation="pattern match">\;\s*policy drop\s*\;</ind:value>
</ind:variable_state>

teacup-on-rockingchair marked this conversation as resolved.
Show resolved Hide resolved

<ind:variable_test id="test_{{{ rule_id }}}_include_chains_policy" check="all"
check_existence="all_exist" version="1"
comment="Check configuration files for default chains policy">
<ind:object object_ref="object_var_{{{ rule_id }}}_include_chains_configurations" />
<ind:state state_ref="state_{{{ rule_id }}}_include_chains_policy" />

</ind:variable_test>

teacup-on-rockingchair marked this conversation as resolved.
Show resolved Hide resolved
</def-group>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
documentation_complete: true

prodtype: sle15

title: 'Ensure nftables default deny firewall policy'
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved

description: |-
Base chain policy is the default verdict that will be applied to packets reaching the end of
the chain.
marcusburghardt marked this conversation as resolved.
Show resolved Hide resolved

rationale: |-
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. It is easier to allow acceptable usage than to block
Copy link
Member

Choose a reason for hiding this comment

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

I think an easier management is an argument, but not the strongest one for this requirement. Maybe the main argument here is to ensure that any traffic without an explicit rule is denied by default.

The first part seems to fit better in the description section:

    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.

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 contain a policy of DROP:
teacup-on-rockingchair marked this conversation as resolved.
Show resolved Hide resolved
<pre>$ sudo nft list ruleset | grep 'hook input' </pre>
Output should include a list of nftables similar to:
<tt>type filter hook input priority 0; policy drop; </tt>
Same goes not only for <tt>hook input</tt>, but also <tt>output</tt> and <tt>forward</tt>
1 change: 0 additions & 1 deletion shared/references/cce-sle15-avail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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
Expand Down