TMAegisBeta
More rules for linux

Linux distributions

TMA-ROCKY9-6.2.3.35

Ensure the audit configuration is immutable

LowLevel 2Automatedlinux

Description

Set system audit so that audit rules cannot be modified with auditctl . Setting the flag "-e 2" forces audit to be put in immutable mode. Audit changes can only be made on system reboot. Note: This setting will require the system to be rebooted to update the active auditd configuration settings.

How it is checked

Audit method: Shell command

shell
alt0() { command -v grep >/dev/null 2>&1 || { echo "step1: grep not installed"; return 1; }; command -v tail >/dev/null 2>&1 || { echo "step1: tail not installed"; return 1; }; o=$(bash -c 'grep -Ph -- '"'"'^\h*-e\h+2\b'"'"' /etc/audit/rules.d/*.rules | tail -1' 2>&1); printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- '-e 2' || { echo step1: missing '-e 2'; return 1; }; command -v auditctl >/dev/null 2>&1 || { echo "step2: auditctl not installed"; return 1; }; command -v grep >/dev/null 2>&1 || { echo "step2: grep not installed"; return 1; }; o=$(bash -c 'auditctl -s | grep '"'"'enabled'"'"'' 2>&1); printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'enabled 2' || { echo step2: missing 'enabled 2'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'A running value of enabled 2 confirms the configuration is currently immutable. If step' || { echo step2: missing 'A running value of enabled 2 confirms the configuration is c'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- '1 returns -e 2 but this returns enabled 1, the immutable flag is configured on disk but' || { echo step2: missing '1 returns -e 2 but this returns enabled 1, the immutable fla'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'not yet active in the running kernel; it takes effect when the audit rules are reloaded at' || { echo step2: missing 'not yet active in the running kernel; it takes effect when t'; return 1; }; }; if alt0; then echo compliant; fi
Expected output
compliant

How it is fixed

Fix method: Guidance or infrastructure patch

Edit or create the file /etc/audit/rules.d/99-finalize.rules and add the line -e 2 at the end of the file: Example: # printf '%s\n' "" "-e 2" >> /etc/audit/rules.d/99-finalize.rules Load audit rules Merge and load the rules into active configuration: # augenrules --load Check if reboot is required. # if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot required to load rules\n"; fi

Properties

Operating systems
rocky-9
Tags
cis-convertedlinux
Reference
CIS Rocky Linux 9 Benchmark v3.0.0 - 6.2.3.35

Check this host

Run this on a machine you are allowed to audit. The scan is read-only.

shell
tmaegis scan --target linux --level 2