Skip to content

Commit 0e95e92

Browse files
authored
Merge pull request #11246 from marcusburghardt/audit_rules_privileged_commands_dracut
Include dracut filter to audit_rules_privileged_commands
2 parents 2c289dc + 17edecc commit 0e95e92

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

linux_os/guide/system/auditing/auditd_configure_rules/audit_privileged_commands/audit_rules_privileged_commands/oval/shared.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
operation="equals">noexec</linux:mount_options>
3838
</linux:partition_state>
3939

40-
4140
<!-- This object is created mainly to improve performance when collecting file objects.
4241
Here all mount points are collected and filtered to include only devices under /dev in
4342
order to ignore special file systems. Then, the mount options are checked to exclude
@@ -61,6 +60,10 @@
6160
<unix:sgid datatype="boolean">true</unix:sgid>
6261
</unix:file_state>
6362

63+
<unix:file_state id="state_dracut_tmp_files" version="1">
64+
<unix:filepath operation="pattern match">^/var/tmp/dracut.*</unix:filepath>
65+
</unix:file_state>
66+
6467
<!-- This file_object will only find privileged commands located only in file systems that allow
6568
their execution. The recurse_file_system parameter is set to defined in order to make sure
6669
the probe doesn't leave the scope of that mount point. For example, when probing "/", the
@@ -74,6 +77,7 @@
7477
var_ref="var_audit_rules_privileged_commands_exec_mountpoints"/>
7578
<unix:filename operation="pattern match">^\w+</unix:filename>
7679
<filter action="include">state_setuid_or_setgid_set</filter>
80+
<filter action="exclude">state_dracut_tmp_files</filter>
7781
</unix:file_object>
7882

7983
<local_variable id="var_audit_rules_privileged_commands_priv_cmds" version="1"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
# packages = audit
3+
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8
4+
5+
./generate_privileged_commands_rule.sh {{{ uid_min }}} privileged /etc/audit/rules.d/privileged.rules
6+
echo "-a always,exit -F path=/usr/bin/notrelevant -F perm=x -F auid>={{{ uid_min }}} -F auid!=unset -F key=privileged" >> /etc/audit/rules.d/privileged.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# packages = audit
3+
# platform = multi_platform_fedora,multi_platform_rhel,Oracle Linux 7,Oracle Linux 8
4+
5+
./generate_privileged_commands_rule.sh {{{ uid_min }}} privileged /etc/audit/rules.d/privileged.rules
6+
7+
# Create some files simulating dracut temporary files. See:
8+
# - https://github.com/ComplianceAsCode/content/issues/10938
9+
# - https://bugzilla.redhat.com/show_bug.cgi?id=1852337
10+
# - https://bugzilla.redhat.com/show_bug.cgi?id=2230306
11+
mount -o remount,suid,exec /var/tmp/
12+
for file in mount umount; do
13+
path="/var/tmp/dracut.ksbFYD/initramfs/usr/bin"
14+
filepath="$path/$file"
15+
mkdir -p $path
16+
touch $filepath
17+
chmod 4755 $filepath
18+
done

0 commit comments

Comments
 (0)