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

Align kernel_module_loading remediations #8557

Conversation

yuumasato
Copy link
Member

Description:

  • Rules 'audit_rules_kernel_module_loading' and 'audit_rules_kernel_module_loading_*' are closely tied.
    The check for the former uses the same definitions as the second rules.
    So the remediations of both rules need to be aligned.

Rationale:

Rules 'audit_rules_kernel_module_loading' and
'audit_rules_kernel_module_loading_*' are closely tied.
The check for the former uses the same definitions as the second rules.
So the remediations of both rules need to be aligned.
@yuumasato yuumasato added the bugfix Fixes to reported bugs. label Apr 14, 2022
@yuumasato yuumasato added this to the 0.1.62 milestone Apr 14, 2022
@yuumasato yuumasato requested a review from mildas April 14, 2022 12:39
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

Open in Gitpod

@github-actions
Copy link

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_kernel_module_loading' differs:
--- old datastream
+++ new datastream
@@ -13,7 +13,9 @@
 do
 ACTION_ARCH_FILTERS="-a always,exit -F arch=$ARCH"
 OTHER_FILTERS=""
- AUID_FILTERS=""
+ 
+ AUID_FILTERS="-F auid>=1000 -F auid!=unset"
+ 
 SYSCALL="init_module finit_module delete_module"
 KEY="modules"
 SYSCALL_GROUPING="init_module finit_module delete_module"

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_kernel_module_loading' differs:
--- old datastream
+++ new datastream
@@ -55,7 +55,7 @@
 find:
 paths: /etc/audit/rules.d
 contains: -a always,exit -F arch=b32(( -S |,)\w+)*(( -S |,){{ item }})+((
- -S |,)\w+)* (-k\s+|-F\s+key=)\S+\s*$
+ -S |,)\w+)* -F auid>=1000 -F auid!=unset (-k\s+|-F\s+key=)\S+\s*$
 patterns: '*.rules'
 register: find_command
 loop: '{{ (syscall_grouping + syscalls) | unique }}'
@@ -100,7 +100,8 @@
 lineinfile:
 path: '{{ audit_file }}'
 regexp: (-a always,exit -F arch=b32)(?=.*(?:(?:-S |,)(?:{{ syscalls_per_file[audit_file]
- | join("|") }}))\b)((?:( -S |,)\w+)+)( (?:-k |-F key=)\w+)
+ | join("|") }}))\b)((?:( -S |,)\w+)+)( -F auid>=1000 -F auid!=unset (?:-k
+ |-F key=)\w+)
 line: \1\2\3{{ missing_syscalls | join("\3") }}\4
 backrefs: true
 state: present
@@ -109,7 +110,8 @@
 - name: Add the audit rule to {{ audit_file }}
 lineinfile:
 path: '{{ audit_file }}'
- line: -a always,exit -F arch=b32 -S {{ syscalls | join(',') }} -F key=modules
+ line: -a always,exit -F arch=b32 -S {{ syscalls | join(',') }} -F auid>=1000
+ -F auid!=unset -F key=modules
 create: true
 mode: o-rwx
 state: present
@@ -130,7 +132,7 @@
 find:
 paths: /etc/audit
 contains: -a always,exit -F arch=b32(( -S |,)\w+)*(( -S |,){{ item }})+((
- -S |,)\w+)* (-k\s+|-F\s+key=)\S+\s*$
+ -S |,)\w+)* -F auid>=1000 -F auid!=unset (-k\s+|-F\s+key=)\S+\s*$
 patterns: audit.rules
 register: find_command
 loop: '{{ (syscall_grouping + syscalls) | unique }}'
@@ -149,7 +151,8 @@
 lineinfile:
 path: '{{ audit_file }}'
 regexp: (-a always,exit -F arch=b32)(?=.*(?:(?:-S |,)(?:{{ syscalls_found
- | join("|") }}))\b)((?:( -S |,)\w+)+)( (?:-k |-F key=)\w+)
+ | join("|") }}))\b)((?:( -S |,)\w+)+)( -F auid>=1000 -F auid!=unset (?:-k
+ |-F key=)\w+)
 line: \1\2\3{{ missing_syscalls | join("\3") }}\4
 backrefs: true
 state: present
@@ -158,7 +161,8 @@
 - name: Add the audit rule to {{ audit_file }}
 lineinfile:
 path: '{{ audit_file }}'
- line: -a always,exit -F arch=b32 -S {{ syscalls | join(',') }} -F key=modules
+ line: -a always,exit -F arch=b32 -S {{ syscalls | join(',') }} -F auid>=1000
+ -F auid!=unset -F key=modules
 create: true
 mode: o-rwx
 state: present
@@ -198,7 +202,7 @@
 find:
 paths: /etc/audit/rules.d
 contains: -a always,exit -F arch=b64(( -S |,)\w+)*(( -S |,){{ item }})+((
- -S |,)\w+)* (-k\s+|-F\s+key=)\S+\s*$
+ -S |,)\w+)* -F auid>=1000 -F auid!=unset (-k\s+|-F\s+key=)\S+\s*$
 patterns: '*.rules'
 register: find_command
 loop: '{{ (syscall_grouping + syscalls) | unique }}'
@@ -243,7 +247,8 @@
 lineinfile:
 path: '{{ audit_file }}'
 regexp: (-a always,exit -F arch=b64)(?=.*(?:(?:-S |,)(?:{{ syscalls_per_file[audit_file]
- | join("|") }}))\b)((?:( -S |,)\w+)+)( (?:-k |-F key=)\w+)
+ | join("|") }}))\b)((?:( -S |,)\w+)+)( -F auid>=1000 -F auid!=unset (?:-k
+ |-F key=)\w+)
 line: \1\2\3{{ missing_syscalls | join("\3") }}\4
 backrefs: true
 state: present
@@ -252,7 +257,8 @@
 - name: Add the audit rule to {{ audit_file }}
 lineinfile:
 path: '{{ audit_file }}'
- line: -a always,exit -F arch=b64 -S {{ syscalls | join(',') }} -F key=modules
+ line: -a always,exit -F arch=b64 -S {{ syscalls | join(',') }} -F auid>=1000
+ -F auid!=unset -F key=modules
 create: true
 mode: o-rwx
 state: present
@@ -273,7 +279,7 @@
 find:
 paths: /etc/audit
 contains: -a always,exit -F arch=b64(( -S |,)\w+)*(( -S |,){{ item }})+((
- -S |,)\w+)* (-k\s+|-F\s+key=)\S+\s*$
+ -S |,)\w+)* -F auid>=1000 -F auid!=unset (-k\s+|-F\s+key=)\S+\s*$
 patterns: audit.rules
 register: find_command
 loop: '{{ (syscall_grouping + syscalls) | unique }}'
@@ -292,7 +298,8 @@
 lineinfile:
 path: '{{ audit_file }}'
 regexp: (-a always,exit -F arch=b64)(?=.*(?:(?:-S |,)(?:{{ syscalls_found
- | join("|") }}))\b)((?:( -S |,)\w+)+)( (?:-k |-F key=)\w+)
+ | join("|") }}))\b)((?:( -S |,)\w+)+)( -F auid>=1000 -F auid!=unset (?:-k
+ |-F key=)\w+)
 line: \1\2\3{{ missing_syscalls | join("\3") }}\4
 backrefs: true
 state: present
@@ -301,7 +308,8 @@
 - name: Add the audit rule to {{ audit_file }}
 lineinfile:
 path: '{{ audit_file }}'
- line: -a always,exit -F arch=b64 -S {{ syscalls | join(',') }} -F key=modules
+ line: -a always,exit -F arch=b64 -S {{ syscalls | join(',') }} -F auid>=1000
+ -F auid!=unset -F key=modules
 create: true
 mode: o-rwx
 state: present

@vojtapolasek vojtapolasek self-assigned this Apr 14, 2022
mildas
mildas previously approved these changes Apr 19, 2022
Copy link
Contributor

@mildas mildas left a comment

Choose a reason for hiding this comment

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

Tested and changes LGTM.

@yuumasato
Copy link
Member Author

I'm addressing some issues with the test scenarios.

@mildas mildas self-requested a review April 20, 2022 11:42
@mildas mildas dismissed their stale review April 20, 2022 11:43

RHEL8 SSGTS test scenarios fail

The test_audit.rules changed and the sed command was not updated.
When on rhel8 and ol8, the rule also checks for auid.
@openshift-ci
Copy link

openshift-ci bot commented Apr 20, 2022

@yuumasato: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-rhcos4-moderate 8f2066b link true /test e2e-aws-rhcos4-moderate
ci/prow/e2e-aws-rhcos4-high 8f2066b link true /test e2e-aws-rhcos4-high

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@mildas
Copy link
Contributor

mildas commented Apr 20, 2022

SSGTS in GH Actions runs in container. It's expected that kernel related rules can't be tested there. The rule must be tested in VM.

@vojtapolasek
Copy link
Collaborator

I confirm it works in a VM. Merging.

@vojtapolasek vojtapolasek merged commit 9f8d633 into ComplianceAsCode:master Apr 21, 2022
@yuumasato yuumasato deleted the audit_kernel_modules_remediation_alignment branch April 21, 2022 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes to reported bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RHEL8 - audit_rules_kernel_module_loading results in error during remediation
3 participants