-
Notifications
You must be signed in to change notification settings - Fork 698
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
Align kernel_module_loading remediations #8557
Conversation
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.
This datastream diff is auto generated by the check Click here to see the full diffbash 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 |
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.
Tested and changes LGTM.
I'm addressing some issues with the test scenarios. |
The test_audit.rules changed and the sed command was not updated.
When on rhel8 and ol8, the rule also checks for auid.
@yuumasato: The following tests failed, say
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. |
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. |
I confirm it works in a VM. Merging. |
Description:
The check for the former uses the same definitions as the second rules.
So the remediations of both rules need to be aligned.
Rationale:
audit_rules_kernel_module_loading
results inerror
during remediation #8526