Linux auditd Rules: Capture Security-Relevant Changes Without Drowning in Logs

The Linux Audit subsystem records security-relevant events such as changes to selected files, identity actions, and system calls. auditd writes audit records, while rules determine which events the kernel sends to the daemon. A useful audit policy captures evidence needed for investigations and compliance without creating so much volume that storage fills or analysts ignore the alerts.

Audit rules do not automatically make logs tamper-proof. A privileged attacker may alter local configuration, stop services, or delete local files depending on host controls. Treat local audit as one source of evidence and forward important records to a separately administered collector with access control, retention, and monitoring. Define the response to audit loss before relying on the records during an incident.

Choose events based on a threat model

Begin with the questions the organization needs to answer: who changed privileged access, when did security configuration change, which process executed an administrative command, and did audit collection stop? Select a small number of high-value events, such as writes to privilege configuration, changes to audit rules, authentication configuration updates, and use of sensitive administrative tools. Confirm that your Linux distribution and workload actually use those paths; containerized and immutable operating systems may store configuration differently.

File-watch rules can record writes or attribute changes on paths such as /etc/sudoers or a controlled application configuration directory. System-call rules can capture events such as executions or identity changes, but they need architecture-aware filters and careful testing. Excessively broad syscall rules can produce large volumes and degrade host performance. Use distribution guidance and test with representative workloads before enforcing broad policy.

Separate runtime rules from persistent configuration

auditctl -l lists the rules currently loaded into the kernel. A command entered with auditctl may not persist after reboot. On systems using the common audit userspace tooling, persistent rules are stored in files under /etc/audit/rules.d/ and compiled or loaded through the distribution's supported mechanism, such as augenrules --load. Service names, package layouts, and rule loaders vary, so verify the method for the target distribution and version.

An illustrative watch rule is:

-w /etc/sudoers -p wa -k privilege-policy

This asks the audit subsystem to watch writes and attribute changes and attach a key that helps searches group the records. Confirm support and syntax on the deployed system with the local auditctl manual. Protect the rule file itself and audit changes to the audit configuration. Avoid copying a large ruleset from a different system without understanding each syscall and filesystem path.

After applying a rule, inspect auditctl -l, perform a controlled test change in a disposable environment, and search the audit log for the expected key. Check that the event includes the user identity, process, object path, timestamp, and result needed for investigation. An audit message that merely says a rule matched but lacks useful context may not answer the operational question.

Test volume, disk use, and failure behavior

Measure event volume during normal activity and during package upgrades, deployment bursts, and authentication load. Test what happens when the disk approaches capacity, the remote collector is unavailable, or auditd cannot write records. The daemon configuration and kernel backlog settings influence behavior. A host that silently drops records during a burst creates a monitoring blind spot; a host configured to stop critical workloads on audit failure may create an availability incident. Set the failure behavior based on risk and document it with operations.

Set a rotation and retention plan that meets investigative and regulatory needs. Monitor disk usage, daemon health, backlog or lost-event counters, rule loading, and log forwarding latency. Alert when expected events stop arriving, not only when a process exits. Consider clock synchronization because event timelines from unsynchronized hosts are difficult to correlate.

Protect the evidence beyond the host

Forward audit records over an authenticated channel to a separate security logging service. Restrict who can change collectors, retention, and audit policy. If tamper-evidence is needed, use append-only or immutable storage controls managed outside the host's root account, and retain integrity checks according to the incident response plan. Hashing a log file on the same compromised machine does not protect it if an attacker can rewrite both the file and the hash.

Limit sensitive fields to the minimum needed. Audit data can include usernames, command arguments, paths, and other personal or confidential information. Apply access control, encryption in transit and at rest, retention limits, and documented access procedures. Review whether command-line arguments may contain passwords or tokens before capturing every execution event.

A controlled rollout checklist

  1. Record distribution, kernel, audit userspace version, and current rule loader.
  2. Define the security questions and map them to a limited set of files and events.
  3. Test rule syntax in staging and confirm the expected events with benign changes.
  4. Measure volume and verify behavior during log rotation and collector outage.
  5. Persist rules through the distribution's supported configuration mechanism.
  6. Forward records off-host and alert on lost events, rule changes, and delivery gaps.
  7. Review policy after service, path, kernel, or compliance changes.

Safe-testing and maintenance note

Run audit-rule tests only on systems you own or administer with authorization. Use disposable files and avoid changing critical production policy merely to generate a test event. Audit records may contain sensitive information; treat them as protected operational data. Last updated: 2026-11-09. Change log: Initial publication; rule examples checked against audit userspace manual pages.

References