BlogLinux & scripting

Auditd rules that matter for compliance

Watch the files and syscalls auditors actually ask about, tune rules by key, and keep signal high without drowning auditd in noise nobody reads.

Dec 17, 2024·4 min readIntermediate·By the SecOpsLog team · command-tested

auditd is the Linux kernel audit framework's userspace daemon. It records security-relevant events — who changed /etc/sudoers, who loaded a kernel module, who exec'd /usr/bin/passwd — as immutable-ish log lines with timestamps, uids, and syscalls. Compliance frameworks name specific objects to monitor; the art is covering those without generating gigabytes of useless noise nobody reads before retention expires.

Start with CIS benchmark watch lists for your distro, then subtract rules your SIEM already covers via FIM or EDR to avoid duplicate alerts.

This note configures rules in /etc/audit/rules.d/, groups them by key for reporting, and tunes exclusions for high-volume paths. For log shipping and search, pair with Linux detection engineering and journal forwarding; Linux hardening covers the broader host baseline audit supports.

Audit rule deployment

Rules load at boot from rules.d. Use keys per compliance control. Test with auditctl before reboot persistence.

1Identify controlsPCI, CIS, internal policy2Map topaths/syscalls/etc/shadow, module load3Write .rules file-a always, -F key=4auditctl -R fileload without reboot5Trigger eventtouch watched file6ausearch -k keyconfirm single clean line7augenrules --loadpersist + restart auditd

Rules that auditors actually ask for

Watch identity files (/etc/passwd, /etc/group, /etc/shadow), privilege escalation (/etc/sudoers, setuid execs), and kernel module loads. Use -F arch=b64 on x86_64 for clarity. Assign a -k key per control so ausearch -k identity pulls a report without grep gymnastics.

Immutable rules (-e 2 in audit.rules on supported systems) prevent runtime tampering without reboot — useful for high-assurance hosts. Pair watched files with file integrity monitoring alerts when audit volume is too high for real-time SIEM ingest. Map each -k key to a compliance control id in your SOC runbook.

/etc/audit/rules.d/50-identity.rules
-D
-b 8192
-f 1
-w /etc/passwd -p wa -k identity
-w /etc/group -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/sudoers -p wa -k priv_esc
-w /etc/sudoers.d/ -p wa -k priv_esc
-a always,exit -F arch=b64 -S init_module,delete_module -k module_load

Raw /var/log/audit/audit.log is hostile to humans. ausearch filters by key, uid, time window, and executable. Ship logs to SIEM with the key field extracted — your detections become identity change alerts instead of regex on paths.

aureport --summary gives weekly stats for capacity planning — if execve events dominate, your filters need tightening before the disk fills. Rotate logs with logrotate or audisp-remote forwarding; audit logs must not be world-readable. Test rules in staging with production-like workload noise before enabling globally.

bash — test a rulelive
auditctl -R /etc/audit/rules.d/50-identity.rules
auditctl -l | grep identity
watch=/etc/passwd perm=wa key=identity
sudo touch /etc/passwd # triggers watch
ausearch -k identity -ts recent
type=PATH name="/etc/passwd" ... key=identity
Unfiltered execve rules will fill your disk
A blanket `-a always,exit -S execve` on a busy app server generates millions of events daily. Start with file watches and high-value syscalls. Exclude known-noisy binaries (monitoring agents, health checks) with `-F exe!=/usr/bin/metric-agent` after measuring volume in staging.
High signal vs high noise rules
Keep
Identity file writes
sudoers changes
Module load/unload
Failed access (EAUTH)
Avoid or narrow
Global execve without filters
Watching /tmp or app log dirs
Duplicate rules in multiple files
No log rotation / backpressure plan

Where this goes next

Forward audit logs via rsyslog or the audit dispatcher to your SIEM. Correlate priv_esc keys with SSH session logs from journald pipelines. Linux detection engineering builds detections on audit fields; Linux hardening ensures the rules you audit actually match a locked-down host.

CIS and PCI mappings change — revalidate watched paths after major distro upgrades (/etc/authselect, renamed PAM files). Automate auditctl -l drift checks in configuration management so a reboot never loads an empty ruleset silently.

Go deeper in a courseLinux detection engineeringauditd, journald, and detection rules that survive compliance audits.View course

Related posts