-
Notifications
You must be signed in to change notification settings - Fork 803
Add UFW default policy rules with OVAL checks (CIS 3.3.x) #14767
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # platform = multi_platform_ubuntu,multi_platform_debian | ||
|
|
||
| ufw default deny incoming |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <def-group> | ||
| <definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
| {{{ oval_metadata("Ensure ufw default incoming policy is deny or reject", rule_title=rule_title) }}} | ||
| <criteria> | ||
| <criterion comment="DEFAULT_INPUT_POLICY is DROP or REJECT in /etc/default/ufw" | ||
| test_ref="{{{ rule_id }}}_test_default_input_policy" /> | ||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test check="all" check_existence="at_least_one_exists" | ||
| id="{{{ rule_id }}}_test_default_input_policy" version="1" | ||
| comment="Check DEFAULT_INPUT_POLICY is DROP or REJECT in /etc/default/ufw"> | ||
| <ind:object object_ref="{{{ rule_id }}}_obj_default_input_policy"/> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="{{{ rule_id }}}_obj_default_input_policy" version="1"> | ||
| <ind:filepath>/etc/default/ufw</ind:filepath> | ||
| <ind:pattern operation="pattern match">^DEFAULT_INPUT_POLICY="(DROP|REJECT)"$</ind:pattern> | ||
| <ind:instance datatype="int">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
| </def-group> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'Ensure ufw Default Deny Policy for Incoming Connections' | ||
|
|
||
| description: |- | ||
| A default deny policy on incoming connections ensures that any unconfigured | ||
| inbound network traffic will be rejected. | ||
| Set <tt>DEFAULT_INPUT_POLICY</tt> to <tt>DROP</tt> or <tt>REJECT</tt> | ||
| in <tt>/etc/default/ufw</tt>. | ||
|
|
||
| Note: Any port or protocol without an explicit allow before the default | ||
| deny will be blocked. | ||
|
|
||
| rationale: |- | ||
| With a default accept policy the firewall will accept any incoming packet | ||
| that is not configured to be denied. It is easier to allow acceptable | ||
| usage than to block unacceptable usage. | ||
|
|
||
| severity: medium | ||
|
|
||
| platform: package[ufw] | ||
|
|
||
| ocil_clause: 'the default policy for incoming connections is not set to deny or reject' | ||
|
|
||
| ocil: |- | ||
| Run the following command and verify that the default policy for incoming | ||
| connections is deny or reject: | ||
| <pre># ufw status verbose | grep Default:</pre> | ||
| Example output: | ||
| <pre>Default: deny (incoming), ...</pre> | ||
|
|
||
| warnings: | ||
| - general: |- | ||
| Changing firewall settings while connected over network can | ||
| result in being locked out of the system. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default allow incoming | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default deny incoming | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default reject incoming | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # platform = multi_platform_ubuntu,multi_platform_debian | ||
|
|
||
| ufw default deny outgoing |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <def-group> | ||
| <definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
| {{{ oval_metadata("Ensure ufw default outgoing policy is deny or reject", rule_title=rule_title) }}} | ||
| <criteria> | ||
| <criterion comment="DEFAULT_OUTPUT_POLICY is DROP or REJECT in /etc/default/ufw" | ||
| test_ref="{{{ rule_id }}}_test_default_output_policy" /> | ||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test check="all" check_existence="at_least_one_exists" | ||
| id="{{{ rule_id }}}_test_default_output_policy" version="1" | ||
| comment="Check DEFAULT_OUTPUT_POLICY is DROP or REJECT in /etc/default/ufw"> | ||
| <ind:object object_ref="{{{ rule_id }}}_obj_default_output_policy"/> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="{{{ rule_id }}}_obj_default_output_policy" version="1"> | ||
| <ind:filepath>/etc/default/ufw</ind:filepath> | ||
| <ind:pattern operation="pattern match">^DEFAULT_OUTPUT_POLICY="(DROP|REJECT)"$</ind:pattern> | ||
| <ind:instance datatype="int">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
| </def-group> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'Ensure ufw Default Deny Policy for Outgoing Connections' | ||
|
|
||
| description: |- | ||
| A default deny policy on outgoing connections ensures that only explicitly | ||
| allowed outbound network traffic will be permitted. | ||
| Set <tt>DEFAULT_OUTPUT_POLICY</tt> to <tt>DROP</tt> or <tt>REJECT</tt> | ||
| in <tt>/etc/default/ufw</tt>. | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great to describe here the exact setting that is supposed to be configured, ie. explain in the text that we want DEFAULT_OUTPUT_POLICY in /etc/default/ufw to be set to DROP or REJECT.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Updated both ufw_default_incoming_rule and ufw_default_outgoing_rule to explicitly state that DEFAULT_INPUT_POLICY / DEFAULT_OUTPUT_POLICY in /etc/default/ufw must be set to DROP or REJECT |
||
| Note: Any port or protocol without an explicit allow before the default | ||
| deny will be blocked. | ||
|
|
||
| rationale: |- | ||
| With a default accept policy the firewall will allow any outgoing packet | ||
| that is not configured to be denied. Restricting outgoing traffic reduces | ||
| the risk of data exfiltration and limits the impact of a compromised host. | ||
|
|
||
| severity: medium | ||
|
|
||
| platform: package[ufw] | ||
|
|
||
| ocil_clause: 'the default policy for outgoing connections is not set to deny or reject' | ||
|
|
||
| ocil: |- | ||
| Run the following command and verify that the default policy for outgoing | ||
| connections is deny or reject: | ||
| <pre># ufw status verbose | grep Default:</pre> | ||
| Example output: | ||
| <pre>Default: ..., deny (outgoing), ...</pre> | ||
|
|
||
| warnings: | ||
| - general: |- | ||
| Changing firewall settings while connected over network can | ||
| result in being locked out of the system. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default allow outgoing | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default deny outgoing | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| # packages = ufw | ||
|
|
||
| ufw allow ssh | ||
| ufw default reject outgoing | ||
| ufw -f enable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # platform = multi_platform_ubuntu,multi_platform_debian | ||
|
|
||
| ufw default deny routed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <def-group> | ||
| <definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
| {{{ oval_metadata("Ensure ufw default routed policy is disabled or deny", rule_title=rule_title) }}} | ||
| <criteria> | ||
| <criterion comment="DEFAULT_FORWARD_POLICY is DROP or REJECT in /etc/default/ufw" | ||
| test_ref="{{{ rule_id }}}_test_default_forward_policy" /> | ||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test check="all" check_existence="at_least_one_exists" | ||
| id="{{{ rule_id }}}_test_default_forward_policy" version="1" | ||
| comment="Check DEFAULT_FORWARD_POLICY is DROP or REJECT in /etc/default/ufw"> | ||
| <ind:object object_ref="{{{ rule_id }}}_obj_default_forward_policy"/> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="{{{ rule_id }}}_obj_default_forward_policy" version="1"> | ||
| <ind:filepath>/etc/default/ufw</ind:filepath> | ||
| <ind:pattern operation="pattern match">^DEFAULT_FORWARD_POLICY="(DROP|REJECT)"$</ind:pattern> | ||
| <ind:instance datatype="int">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
| </def-group> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| documentation_complete: true | ||
|
|
||
| title: 'Ensure ufw Default Policy for Routed (Forwarded) Traffic is Disabled' | ||
|
|
||
| description: |- | ||
| The default policy for routed (forwarded) traffic in ufw should be set to | ||
| disabled or deny, ensuring that the system does not forward packets between | ||
| interfaces unless explicitly configured to do so. | ||
|
|
||
| rationale: |- | ||
| Unless the system is intended to act as a router, forwarding traffic between | ||
| network interfaces should be disabled. Disabling the routed default policy | ||
| prevents the system from accidentally or maliciously forwarding traffic. | ||
|
|
||
| severity: medium | ||
|
|
||
| platform: package[ufw] | ||
|
|
||
| ocil_clause: 'the default policy for routed traffic is not set to disabled or deny' | ||
|
|
||
| ocil: |- | ||
| Run the following command and verify that the default policy for routed | ||
| traffic is disabled or deny: | ||
| <pre># ufw status verbose | grep Default:</pre> | ||
| Example output: | ||
| <pre>Default: ..., disabled (routed)</pre> | ||
|
|
||
| warnings: | ||
| - general: |- | ||
| Changing firewall settings while connected over network can | ||
| result in being locked out of the system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add test scenarios for both rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added deny.pass.sh, reject.pass.sh, and allow.fail.sh for both rules.