Skip to content

Add UFW default policy rules with OVAL checks (CIS 3.3.x)#14767

Open
israel-villar wants to merge 2 commits into
ComplianceAsCode:masterfrom
israel-villar:feat/ufw-default-policy-rules
Open

Add UFW default policy rules with OVAL checks (CIS 3.3.x)#14767
israel-villar wants to merge 2 commits into
ComplianceAsCode:masterfrom
israel-villar:feat/ufw-default-policy-rules

Conversation

@israel-villar
Copy link
Copy Markdown
Contributor

Add three new rules for UFW firewall default policies:

  • ufw_default_incoming_rule: ensure DEFAULT_INPUT_POLICY is DROP or REJECT in /etc/default/ufw
  • ufw_default_outgoing_rule: ensure DEFAULT_OUTPUT_POLICY is DROP or REJECT in /etc/default/ufw
  • ufw_disabled_routed: ensure DEFAULT_FORWARD_POLICY is DROP or REJECT in /etc/default/ufw

All three rules use OVAL checks that read /etc/default/ufw directly, avoiding the SCE approach which fails silently when /tmp is mounted noexec (required by CIS 1.1.2.4). Map the new rules to the ufw component.

Description:

  • Add three new rules for UFW firewall default policies:
    • ufw_default_incoming_rule: ensure DEFAULT_INPUT_POLICY is DROP
      or REJECT in /etc/default/ufw
    • ufw_default_outgoing_rule: ensure DEFAULT_OUTPUT_POLICY is DROP
      or REJECT in /etc/default/ufw
    • ufw_disabled_routed: ensure DEFAULT_FORWARD_POLICY is DROP or
      REJECT in /etc/default/ufw
  • All three rules use OVAL checks that read /etc/default/ufw directly.
  • Map the new rules to the ufw component.

Rationale:

  • A default deny policy on incoming, outgoing and forwarded connections
    ensures only explicitly allowed traffic is permitted, reducing the
    attack surface.
  • SCE scripts fail silently when /tmp is mounted noexec (required by
    CIS 1.1.2.4). The OVAL approach reads the UFW configuration file
    directly and is not affected by mount options.

Review Hints:

  • New rule directories under linux_os/guide/system/network/network-ufw/.
  • ufw_default_outgoing_rule was created directly with OVAL (no SCE),
    consistent with the OVAL checks added for check_ufw_active,
    ufw_default_incoming_rule and ufw_disabled_routed.
  • Build to verify: ./build_product debian13 --datastream-only
  • Build ubuntu2404 to verify no regression:
    ./build_product ubuntu2404 --datastream-only

Add three new rules for UFW firewall default policies:

- ufw_default_incoming_rule: ensure DEFAULT_INPUT_POLICY is DROP or
  REJECT in /etc/default/ufw
- ufw_default_outgoing_rule: ensure DEFAULT_OUTPUT_POLICY is DROP or
  REJECT in /etc/default/ufw
- ufw_disabled_routed: ensure DEFAULT_FORWARD_POLICY is DROP or REJECT
  in /etc/default/ufw

All three rules use OVAL checks that read /etc/default/ufw directly,
avoiding the SCE approach which fails silently when /tmp is mounted
noexec (required by CIS 1.1.2.4). Map the new rules to the ufw component.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the needs-ok-to-test Used by openshift-ci bot. label Jun 5, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 5, 2026

Hi @israel-villar. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

description: |-
A default deny policy on outgoing connections ensures that only explicitly
allowed outbound network traffic will be permitted.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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

@@ -0,0 +1,33 @@
documentation_complete: true
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

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.

@jan-cerny jan-cerny self-assigned this Jun 8, 2026
- Mention the exact setting in the description of both rules: explain that
  DEFAULT_INPUT_POLICY / DEFAULT_OUTPUT_POLICY in /etc/default/ufw must be
  set to DROP or REJECT
- Add test scenarios for ufw_default_incoming_rule: deny.pass, reject.pass,
  allow.fail
- Add test scenarios for ufw_default_outgoing_rule: deny.pass, reject.pass,
  allow.fail

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Used by openshift-ci bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants