Skip to content

Align audit_rules_sudoers_d remediation with DISA STIG content - #15060

Draft
ggbecker wants to merge 1 commit into
ComplianceAsCode:masterfrom
ggbecker:audit_rules_sudoers_d_disa_path
Draft

Align audit_rules_sudoers_d remediation with DISA STIG content#15060
ggbecker wants to merge 1 commit into
ComplianceAsCode:masterfrom
ggbecker:audit_rules_sudoers_d_disa_path

Conversation

@ggbecker

Copy link
Copy Markdown
Member

Description:

  • Change audit_rules_sudoers_d to watch /etc/sudoers.d (no trailing slash), so the remediation emits the path= filter form instead of dir=.
  • Make the audit_rules_watch OVAL template accept both the dir and path filters, with or without a trailing slash.
  • Add test scenarios to audit_rules_sudoers_d covering all accepted forms and the negative cases.

Rationale:

  • Fixes DISA-alignment mismatch on audit_rules_sudoers_d — SSG pass, DISA fail (RHEL 9.2/9.4/9.6/9.8/9.9) #15052
  • The DISA RHEL 9 STIG check for SV-258218 only accepts -a always,exit -F arch=b64 -F path=/etc/sudoers.d -F perm=wa .... Our content generated the semantically equivalent -F dir=/etc/sudoers.d/ form, so systems remediated by our content passed our own scan but failed the DISA scan.
  • Aligning the remediation with the DISA content resolves this mismatch, and relaxing the OVAL check to accept both forms avoids regressing systems already remediated with the previous dir= form.

Review Hints:

  • The key change is dropping the trailing slash from the path template var in rule.yml; template.py derives filter_type (dir vs path) from that slash.
  • The OVAL template change is additive leniency (dir|path) + optional trailing slash, so it never rejects anything previously accepted; it affects all 35 rules using the template.
  • Tested on rhel9 with Automatus (bash remediation): all 21 scenarios pass (8 new + 13 from the shared template).
  • The DISA check accepts any (or no) -F key= value, so keeping key=actions is fine; confirmed against U_RHEL_9_V2R9_STIG_SCAP_1-3_Benchmark.

@ggbecker ggbecker added this to the 0.1.83 milestone Aug 26, 2026
@ggbecker ggbecker added RHEL Red Hat Enterprise Linux product related. backported-into-stabilization PRs which were cherry-picked during stabilization process. STIG STIG Benchmark related. labels Aug 26, 2026
@ggbecker
ggbecker marked this pull request as draft August 26, 2026 13:35
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label Aug 26, 2026
The DISA RHEL 9 STIG (SV-258218) OVAL check requires the /etc/sudoers.d
audit rule to use the 'path' filter without a trailing slash:

    -a always,exit -F arch=b64 -F path=/etc/sudoers.d -F perm=wa ...

Our content generated the semantically equivalent 'dir' form with a
trailing slash, so systems remediated by our content failed DISA scans
while passing our own check.

- The audit_rules_watch OVAL template now accepts both the 'dir' and
  'path' filters, with or without a trailing slash, so systems already
  remediated with the previous form are not regressed. The template.py
  preprocessing normalizes away a trailing slash so the optional-slash
  match is symmetric for every rule using the template.
- audit_rules_sudoers_d now uses the path '/etc/sudoers.d' (no trailing
  slash) so the remediation emits the DISA-aligned 'path=' rule.
- Generalize the coverage into the audit_rules_watch template tests
  (dir<->path filter alternation and trailing-slash toggle) so it
  applies to every rule using the template on all platforms, instead of
  rule-specific tests for audit_rules_sudoers_d.
@ggbecker
ggbecker force-pushed the audit_rules_sudoers_d_disa_path branch from e542e1f to 877b885 Compare August 26, 2026 14:06
@jan-cerny jan-cerny self-assigned this Aug 27, 2026
<literal_component>{{{ PATH_ESCAPED }}}</literal_component>
{{% endif %}}
<literal_component>\s+\-F\s+perm=\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</literal_component>
<literal_component>/?\s+\-F\s+perm=\b([rx]*w[rx]*a[rx]*|[rx]*a[rx]*w[rx]*)\b.*$</literal_component>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ggbecker Will it accidentally start accepting paths with trailing slash where it shouldn't accept it? When the audit rule is supposed to watch a regular file (not a directory) but the audit rule contains a path with a trailing slash, will the rule fail?

Let's assume that I have the following rules in the /etc/audit/audit.rules, which is supposed to watch the /etc/passwd file, but notice the path:

-a always,exit -F arch=b32 -F path=/etc/passwd/ -F perm=wa -F key=identity
-a always,exit -F arch=b64 -F path=/etc/passwd/ -F perm=wa -F key=identity

What will be the OVAL result?

data["name"] = name
if lang == "oval":
data["path_escaped"] = path.replace("/", "\\/")
# Normalize away a trailing slash so it can be made optional in the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ggbecker I consider having the new behavior accessible by a new template parameter instead of changing the existing behavior.

At a minimum, the audit system should collect administrator actions
for all users and root.
{{{ describe_audit_rules_watch("/etc/sudoers.d/", "actions") }}}
{{{ describe_audit_rules_watch("/etc/sudoers.d", "actions") }}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The RHEL 10 STIG contains the trailing slash in the rule, so the description won't match the rule. https://stigaview.com/products/rhel10/v1r2/RHEL-10-500690/

@Mab879

Mab879 commented Aug 27, 2026

Copy link
Copy Markdown
Member

Can we remove the backported-into-stabilization label on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported-into-stabilization PRs which were cherry-picked during stabilization process. do-not-merge/work-in-progress Used by openshift-ci bot. RHEL Red Hat Enterprise Linux product related. STIG STIG Benchmark related.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DISA-alignment mismatch on audit_rules_sudoers_d — SSG pass, DISA fail (RHEL 9.2/9.4/9.6/9.8/9.9)

3 participants