DRAFT: Fix aarch64 audit rules for unsupported syscalls#14757
Open
macko1 wants to merge 1 commit into
Open
Conversation
37bac4e to
06e5155
Compare
|
This datastream diff is auto generated by the check Click here to see the full diffOVAL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_file_deletion_events' differs.
--- oval:ssg-audit_rules_file_deletion_events:def:1
+++ oval:ssg-audit_rules_file_deletion_events:def:1
@@ -1,4 +1,11 @@
+criteria OR
criteria AND
+extend_definition oval:ssg-system_info_architecture_aarch_64:def:1
+extend_definition oval:ssg-audit_rules_file_deletion_events_unlinkat:def:1
+extend_definition oval:ssg-audit_rules_file_deletion_events_renameat:def:1
+extend_definition oval:ssg-audit_rules_file_deletion_events_renameat2:def:1
+criteria AND
+extend_definition oval:ssg-system_info_architecture_aarch_64:def:1
extend_definition oval:ssg-audit_rules_file_deletion_events_rmdir:def:1
extend_definition oval:ssg-audit_rules_file_deletion_events_unlink:def:1
extend_definition oval:ssg-audit_rules_file_deletion_events_unlinkat:def:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_file_deletion_events' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_file_deletion_events
+++ xccdf_org.ssgproject.content_rule_audit_rules_file_deletion_events
@@ -4,15 +4,29 @@
# Perform the remediation for the syscall rule
# Retrieve hardware architecture of the underlying system
[ "$(getconf LONG_BIT)" = "32" ] && RULE_ARCHS=("b32") || RULE_ARCHS=("b32" "b64")
+
+# Detect if running on aarch64 architecture
+# This remediation script writes audit rules to /etc/audit/rules.d/ or /etc/audit/audit.rules
+# We need runtime detection because this script must work on any architecture
+AARCH64=false
+[ "$(uname -m)" = "aarch64" ] && AARCH64=true
for ARCH in "${RULE_ARCHS[@]}"
do
ACTION_ARCH_FILTERS="-a always,exit -F arch=$ARCH"
OTHER_FILTERS=""
AUID_FILTERS="-F auid>=1000 -F auid!=unset"
- SYSCALL="rmdir unlink unlinkat rename renameat renameat2"
+ if [ "$AARCH64" = true ] && [ "$ARCH" = "b64" ]; then
+ # aarch64 b64 ABI does not have rmdir, unlink, or rename syscalls
+ # These legacy syscalls were replaced by unlinkat and renameat variants
+ # If we try to write rules for them, auditctl will fail with "Syscall name unknown"
+ SYSCALL="unlinkat renameat renameat2"
+ SYSCALL_GROUPING="unlinkat renameat renameat2"
+ else
+ SYSCALL="rmdir unlink unlinkat rename renameat renameat2"
+ SYSCALL_GROUPING="rmdir unlink unlinkat rename renameat renameat2"
+ fi
KEY="delete"
- SYSCALL_GROUPING="rmdir unlink unlinkat rename renameat renameat2"
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules'
unset syscall_a
unset syscall_grouping
OVAL for rule 'xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification' differs.
--- oval:ssg-audit_rules_unsuccessful_file_modification:def:1
+++ oval:ssg-audit_rules_unsuccessful_file_modification:def:1
@@ -1,4 +1,12 @@
+criteria OR
criteria AND
+extend_definition oval:ssg-system_info_architecture_aarch_64:def:1
+extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_ftruncate:def:1
+extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_openat:def:1
+extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_open_by_handle_at:def:1
+extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_truncate:def:1
+criteria AND
+extend_definition oval:ssg-system_info_architecture_aarch_64:def:1
extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_creat:def:1
extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_ftruncate:def:1
extend_definition oval:ssg-audit_rules_unsuccessful_file_modification_openat:def:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification' differs.
--- xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification
+++ xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification
@@ -1,9 +1,15 @@
# Remediation is applicable only in certain platforms
-if rpm --quiet -q audit && rpm --quiet -q kernel-core && { ( ! ( ( grep -sqE "^.*\.aarch64$" /proc/sys/kernel/osrelease || grep -sqE "^aarch64$" /proc/sys/kernel/arch; ) ) ); }; then
+if rpm --quiet -q audit && rpm --quiet -q kernel-core; then
# Perform the remediation of the syscall rule
# Retrieve hardware architecture of the underlying system
[ "$(getconf LONG_BIT)" = "32" ] && RULE_ARCHS=("b32") || RULE_ARCHS=("b32" "b64")
+
+# Detect if running on aarch64 architecture
+# This remediation script writes audit rules to /etc/audit/rules.d/ or /etc/audit/audit.rules
+# We need runtime detection because this script must work on any architecture
+AARCH64=false
+[ "$(uname -m)" = "aarch64" ] && AARCH64=true
for ARCH in "${RULE_ARCHS[@]}"
do
@@ -12,9 +18,17 @@
ACTION_ARCH_FILTERS="-a always,exit -F arch=$ARCH"
OTHER_FILTERS="-F exit=-EACCES"
AUID_FILTERS="-F auid>=1000 -F auid!=unset"
- SYSCALL="creat open openat open_by_handle_at truncate ftruncate"
+ if [ "$AARCH64" = true ] && [ "$ARCH" = "b64" ]; then
+ # aarch64 b64 ABI does not have creat or open syscalls
+ # These legacy syscalls were replaced by openat variant
+ # If we try to write rules for them, auditctl will fail with "Syscall name unknown"
+ SYSCALL="openat open_by_handle_at truncate ftruncate"
+ SYSCALL_GROUPING="openat open_by_handle_at truncate ftruncate"
+ else
+ SYSCALL="creat open openat open_by_handle_at truncate ftruncate"
+ SYSCALL_GROUPING="creat open openat open_by_handle_at truncate ftruncate"
+ fi
KEY="access"
- SYSCALL_GROUPING="creat open openat open_by_handle_at truncate ftruncate"
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules'
unset syscall_a
unset syscall_grouping
@@ -327,9 +341,17 @@
ACTION_ARCH_FILTERS="-a always,exit -F arch=$ARCH"
OTHER_FILTERS="-F exit=-EPERM"
AUID_FILTERS="-F auid>=1000 -F auid!=unset"
- SYSCALL="creat open openat open_by_handle_at truncate ftruncate"
+ if [ "$AARCH64" = true ] && [ "$ARCH" = "b64" ]; then
+ # aarch64 b64 ABI does not have creat or open syscalls
+ # These legacy syscalls were replaced by openat variant
+ # If we try to write rules for them, auditctl will fail with "Syscall name unknown"
+ SYSCALL="openat open_by_handle_at truncate ftruncate"
+ SYSCALL_GROUPING="openat open_by_handle_at truncate ftruncate"
+ else
+ SYSCALL="creat open openat open_by_handle_at truncate ftruncate"
+ SYSCALL_GROUPING="creat open openat open_by_handle_at truncate ftruncate"
+ fi
KEY="access"
- SYSCALL_GROUPING="creat open openat open_by_handle_at truncate ftruncate"
# Perform the remediation for both possible tools: 'auditctl' and 'augenrules'
unset syscall_a
unset syscall_grouping
Platform has been changed for rule 'xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification'
--- xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification
+++ xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification
@@ -1 +1 @@
-oval:ssg-proc_sys_kernel_osrelease_arch_aarch64:def:1
+ |
Fixes rules audit_rules_file_deletion_events and audit_rules_unsuccessful_file_modification on aarch64. Both rules generate /etc/audit/rules.d/*.rules files that include syscalls which do not exist on aarch64 (rmdir, unlink, rename, creat, open). When auditd loads these rules, it fails because the kernel rejects the nonexistent syscalls. The aarch64 architecture replaced these legacy syscalls with "at" variants (unlinkat, renameat, openat). The rules now detect aarch64 and write only the syscalls that exist on that architecture: - Bash remediations detect aarch64 at runtime with uname -m - On aarch64: write unlinkat, renameat, renameat2 (for file deletion) and openat (for file modification) - On other architectures: write all syscalls - OVAL checks split into aarch64 branch and other-arch branch, using the cpe:/a:machine CPE definition to detect aarch64 Profiles like rhel9/profiles/default.profile select these rules. If we excluded them from aarch64, auditd would not log any file deletion or modification events on aarch64 systems. Resolves: ComplianceAsCode#14196 Resolves: ComplianceAsCode#14372
06e5155 to
d53653c
Compare
|
@macko1: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Fixes rules
audit_rules_file_deletion_eventsandaudit_rules_unsuccessful_file_modificationon aarch64.Both rules generate
/etc/audit/rules.d/*.rulesfiles that include syscalls which do not exist on aarch64 (rmdir,unlink,rename,creat,open). When auditd loads these rules, it fails because the kernel rejects the nonexistent syscalls.The aarch64 architecture replaced these legacy syscalls with "at" variants (
unlinkat,renameat,openat).The rules now detect aarch64 and write only the syscalls that exist on that architecture:
Bash remediations:
uname -munlinkat,renameat,renameat2(for file deletion) andopenat(for file modification)rmdir,unlink,rename,unlinkat,renameat,renameat2for file deletion;creat,open,openatfor file modification)OVAL checks:
unlinkat,renameat,renameat2,openatonly) and other-arch branch (checks for all syscalls)cpe:/a:machineCPE definition to detect aarch64 and select the correct branchRules fixed:
audit_rules_file_deletion_events:rmdir,unlink,renameunlinkat,renameat,renameat2audit_rules_unsuccessful_file_modification:creat,openopenat,open_by_handle_at,truncate,ftruncateplatforms: - not aarch64_archrestriction fromrule.yml(rule was completely excluded from aarch64)Rationale:
Profiles like
rhel9/profiles/default.profileselectaudit_rules_file_deletion_eventsandaudit_rules_unsuccessful_file_modification, not the individual syscall-specific rules. If we excluded these rules from aarch64 (via platform restrictions), auditd would not log any file deletion or modification events on aarch64 systems.Instead, the rules now work on aarch64 and log the events using the syscalls that exist on that architecture.
Review Hints:
Build on aarch64:
Apply the generated rules and verify:
unlinkat,renameat,renameat2)openat)