Most Linux detection gaps are not missing logs but misread ones: an analyst sees a SYSCALL line, misses the EXECVE and PATH records that share its serial number, and loses the command line and the file that was touched. This reference explains how the Linux Audit system groups records into events, what the record types defenders rely on actually contain, field by field, and how to query them with ausearch and aureport. It covers the kernel records (SYSCALL, EXECVE, PATH, CWD, PROCTITLE, SOCKADDR, CONFIG_CHANGE), the PAM and login records written by user-space programs (USER_AUTH, USER_ACCT, USER_LOGIN, CRED_ACQ, USER_START and their pairs) and the account and anomaly records that flag persistence. It is for Linux defenders and detection engineers who already run auditd; rule sets, buffers, shipping and tamper protection are covered in the Linux Logging and auditd for Defenders Guide, which this page builds on.
Key takeaways
- An event is a group of records, not a line. Every record from one syscall shares the same msg=audit(timestamp:serial) value; parse and correlate on that pair.
- auid is the field that answers "who". The login user ID is set at login and survives su and sudo, so a root process still carries the original user's auid and ses.
- EXECVE and PROCTITLE are not interchangeable. EXECVE holds every argument (split across records when long); PROCTITLE is capped at 128 bytes in the kernel and hex encoded.
- Authentication has its own record family. USER_AUTH, USER_ACCT, CRED_ACQ, USER_LOGIN, USER_START, USER_END and CRED_DISP come from PAM-aware programs, carry res=success or res=failed, and tell the story of a session in order.
- CONFIG_CHANGE and DAEMON records watch the watcher. Rule deletions, audit being disabled and auditd stopping are themselves audited and should be high-priority alerts.
How auditd records work
The kernel evaluates audit rules and emits records; auditd writes them to /var/log/audit/audit.log and passes them to dispatcher plugins. User-space programs such as sshd, login, sudo and PAM modules send their own records through the same channel. Each line starts with type=NAME and a msg=audit(1732612345.123:4821) stamp: seconds since the epoch, milliseconds, and an event serial. The ausearch man page describes the serial as the event ID: all records from one application's syscall share it, and the next syscall gets a different one.
Anatomy of a multi-record event
Red Hat's documentation walks through a failed read of /etc/ssh/sshd_config by an unprivileged user, triggered by a watch with key sshd_config. The event has four records:
- SYSCALL: arch=c000003e (x86_64), syscall=2 (open on that architecture), success=no, exit=-13 (EACCES), a0 to a3 (first four arguments in hex), items=1 (one PATH record follows), ppid, pid, auid, uid, gid, euid, suid, fsuid, egid, sgid, fsgid, tty, ses, comm, exe, subj (SELinux context) and key="sshd_config".
- CWD: the working directory, which turns relative names in PATH records into absolute paths.
- PATH: item=0, name, inode, dev, mode, ouid, ogid, rdev, obj, nametype and file capability fields (cap_fp, cap_fi, cap_fe, cap_fver).
- PROCTITLE: the full command line, hex encoded; ausearch -i decodes it to cat /etc/ssh/sshd_config.
An execve call adds an EXECVE record, a socket call adds SOCKADDR, and some syscalls add several PATH records (rename produces items for the source, target and parent directories). In the kernel's numbering, EOE (1320) marks the end of a multi-record event, and the auparse library also treats an event as complete once it is end_of_event_timeout seconds older than co-located events (default 2 seconds, set in auditd.conf). Any parser that treats one line as one event, or that does not wait for the full group, loses the command line and the target file. The upshot for SIEM ingestion is simple: reassemble by node, timestamp and serial before you write detections.
Identity fields that matter
| Field | Meaning | Why defenders care |
|---|---|---|
| auid | Login user ID (loginuid), set at login and inherited by every child process | Identifies the human or service login behind a root action; unset appears as 4294967295 (-1) |
| ses | Login session ID | Groups everything done in one login; search with ausearch --session |
| uid, euid, suid, fsuid | Real, effective, saved and filesystem user IDs | euid=0 with auid of a normal user shows privilege use; uid differing from euid flags setuid execution |
| gid, egid, sgid, fsgid | Matching group IDs | Group-based access to sensitive files |
| tty, terminal | Terminal (pts/0, ssh, cron, or none) | Interactive versus scheduled or daemon activity |
| comm, exe | Command name from the task structure, and the executable path | comm can be changed by the process; prefer exe for allowlists |
| key | Free text from the rule that fired | Your own label; the main way to select meaningful events |
Service accounts and daemons started at boot usually have auid unset, which is why upstream guidance writes user rules with -F auid>=1000 -F auid!=unset (adjust 1000 to UID_MIN in /etc/login.defs). A process with an unset auid that suddenly runs interactive tools is worth a look; so is a service account whose auid is set, which means someone logged in as it. For managing those accounts, see the How to Find ssh authorized keys across a server fleet guide.
Core record types
Numeric IDs below are from the kernel header include/uapi/linux/audit.h and the audit-userspace record definitions. ausearch -m accepts either the name or the number, and a comma-separated list without spaces.
| Type (ID) | Source | Key fields | Defender use |
|---|---|---|---|
| SYSCALL (1300) | Kernel, on a matching syscall rule or watch | arch, syscall, success, exit, a0 to a3, items, pid, ppid, auid, uid, euid, ses, tty, comm, exe, key | The anchor record of an event: who did what, whether it worked |
| EXECVE (1309) | Kernel, on execve and execveat | argc, a0, a1 ... (hex when the value contains spaces or special characters); a1_len and a1[0], a1[1] chunks when an argument is long | Full command line for process execution detections (T1059.004 Unix Shell) |
| PATH (1302) | Kernel, one per path the syscall touched | item, name, inode, dev, mode, ouid, ogid, nametype | The file read, written, created or deleted; nametype shows the role (for example NORMAL, PARENT, CREATE, DELETE) |
| CWD (1307) | Kernel | cwd | Resolve relative paths; spot execution from /tmp or /dev/shm |
| PROCTITLE (1327) | Kernel | proctitle (hex, truncated at 128 bytes) | Quick view of the command line; use EXECVE when completeness matters |
| SOCKADDR (1306) | Kernel, for connect, bind, accept and similar | saddr (hex sockaddr; decoded by ausearch -i or log_format=ENRICHED) | Outbound connections from unexpected binaries, reverse shells |
| CONFIG_CHANGE (1305) | Kernel, on audit rule or setting changes | auid, ses, op (for example add_rule, remove_rule), key, list, res, audit_enabled | Rule removal or audit disabled: T1685.004 Disable or Modify Linux Audit System Log |
| KERN_MODULE (1330) | Kernel, on module load | name | Rootkit and driver loading (T1547.006 Kernel Modules and Extensions) |
| BPF (1334) | Kernel, on BPF program load and unload | BPF program ID and operation | Unexpected eBPF programs on hosts where none are expected |
| NETFILTER_CFG (1325) | Kernel, on netfilter table changes | Table, address family and operation | Host firewall rules changed outside change control |
| AVC (1400) | SELinux | denied or granted, scontext, tcontext, tclass | Confinement violations; aureport -a summarises them |
| ANOM_PROMISCUOUS (1700), ANOM_ABEND (1701) | Kernel | dev, prom; sig, comm, exe | Sniffing and crashing processes (exploitation attempts); aureport -n |
| DAEMON_START (1200), DAEMON_END (1201), DAEMON_ABORT (1202) | auditd | auid, pid, res | Audit service stops and failures; a gap between END and the next START is a blind window |
Authentication and session records
These come from PAM and login-aware programs and occupy the 1100 to 1199 range reserved for user-space messages. They carry op (the operation), acct (account name), exe, hostname, addr (remote address), terminal and res. PAM records also list grantors, the PAM modules that approved the action.
| Type (ID) | Written when | What to look for |
|---|---|---|
| USER_AUTH (1100) | Authentication step (password, key, MFA module) | res=failed bursts from one addr (T1110 Brute Force); successes for accounts that should never log in interactively |
| USER_ACCT (1101) | Account authorisation (expiry, access rules) | Failures for locked or expired accounts still being tried |
| CRED_ACQ (1103), CRED_REFR (1110), CRED_DISP (1104) | Credentials established, refreshed and disposed (for example by su, sudo, sshd, cron) | Pairs that bracket a privileged action |
| USER_LOGIN (1112), USER_LOGOUT (1113) | Interactive login completed or ended | New source addresses, logins at odd hours, root logins over SSH (T1021.004 SSH) |
| LOGIN (1006) | Kernel, when loginuid is set (via pam_loginuid) | old-auid and auid: the moment a session gets its identity |
| USER_START (1105), USER_END (1106) | PAM session opened and closed | Session duration; sessions with no matching end |
| USER_CMD (1123) | sudo runs a command | cmd (hex), cwd, terminal, res: privileged commands by user (T1548.003 Sudo and Sudo Caching) |
| USER_CHAUTHTOK (1108) | Password or token changed | Password changes on service accounts |
| ADD_USER (1114), DEL_USER (1115), ADD_GROUP (1116), USER_MGMT (1102), GRP_MGMT (1132) | Account and group changes by shadow-utils tools | New local accounts (T1136.001 Local Account) and additions to wheel or sudo groups |
| ANOM_LOGIN_FAILURES (2100), ANOM_ROOT_TRANS (2117) | Failure limit reached; user became root | High-signal anomalies; check which programs emit them on your distribution |
| SOFTWARE_UPDATE (1138) | Package installs and removals where the package manager plugin is present (rpm-plugin-audit on RHEL) | Tooling installed on servers outside patch windows |
On a typical PAM-based system, an SSH password login produces records along the lines of USER_AUTH, USER_ACCT, CRED_ACQ, LOGIN, USER_START and USER_LOGIN, then USER_END, CRED_DISP and USER_LOGOUT at the end. Each uses its own serial, so correlate the session with ses, pid and addr rather than the serial. Keys are not the whole story: these records do not show which authorised key was used, which is why many baselines raise sshd LogLevel to VERBOSE and keep journald alongside audit records.
Rules that generate useful records
Kernel records only exist when a rule matches; the user-space authentication records above appear whenever auditd is running. Write rules with keys so every SYSCALL carries a meaningful label, and give related rules a common key, as the audit.rules man page advises.
| Goal | Rule pattern (illustrative) | Records produced |
|---|---|---|
| Process execution by logged-in users | -a always,exit -F arch=b64 -S execve -F auid>=1000 -F auid!=unset -k exec | SYSCALL, EXECVE, CWD, PATH (binary and interpreter), PROCTITLE |
| Credential file access | -w /etc/shadow -p rwa -k identity | SYSCALL, CWD, PATH, PROCTITLE (T1003.008) |
| SSH key persistence | Watch on /root/.ssh and authorised key paths -p wa -k sshkeys | SYSCALL, PATH with nametype CREATE or NORMAL (T1098.004 SSH Authorized Keys) |
| Scheduled tasks | -w /etc/cron.d -p wa -k cron | SYSCALL, PATH (T1053.003 Cron) |
| Kernel modules | -a always,exit -F arch=b64 -S init_module,finit_module,delete_module -k modules | SYSCALL, KERN_MODULE |
| Failed access attempts | -a always,exit -F arch=b64 -S open,openat,openat2 -F exit=-EPERM -k access | SYSCALL (success=no), PATH |
| Audit configuration | -w /etc/audit/ -p wa -k auditconfig | SYSCALL, PATH, plus CONFIG_CHANGE when rules load |
Add matching -F arch=b32 rules on 64-bit hosts that can run 32-bit binaries, or a process can avoid the b64 rule by using the 32-bit syscall table. Test each rule in a lab, confirm with auditctl -l, trigger it and check the record set with ausearch -k. Upstream sample rule files and the performance side are covered in the Linux Logging and auditd for Defenders Guide.
Parsing and forwarding
ausearch
- By type: ausearch -m USER_LOGIN -sv no -ts today returns today's failed logins; -m accepts lists such as -m USER_AUTH,USER_ACCT.
- By key: ausearch -k identity -i -ts recent (recent is the last ten minutes).
- By event: ausearch -a 4821 returns every record with that serial; add -ts if serials repeat across reboots.
- By session or user: ausearch --session 12 or ausearch -ua 1001 (any of uid, euid or auid).
- Output: -i interprets numeric fields and hex; --format csv or text produces normalised output; --raw keeps original records for piping into aureport.
The ausearch man page warns that interpreting unenriched logs on another machine uses that machine's account database and can mislead. Set log_format = ENRICHED in auditd.conf, which resolves uid, gid, syscall, architecture and socket address information before the record is written or forwarded.
aureport
- Start broad: aureport with no options gives the summary of logins, authentications, anomalies and AVCs; the audit.rules man page suggests starting any investigation here.
- Targeted reports: -au authentication attempts, -l logins, -m account modifications, -n anomalies, -k keys, -x executables, -tm terminals; add --failed, --success or --summary.
- Chain with ausearch: ausearch --start this-week -k access --raw | aureport --file --summary lists the files with denied access; every aureport line carries an event number you can open with ausearch -a.
Forwarding to a SIEM
Ship records with the audisp syslog plugin, a log agent that reads audit.log, or a collector that understands multi-record events. Whatever the path, the pipeline should group records by node, timestamp and serial, decode hex fields (proctitle, EXECVE arguments, cmd, saddr), keep raw values for evidence, and alert on DAEMON_END or DAEMON_ABORT without a following DAEMON_START. Retention and integrity are covered in the CIS Control 8 Audit Log Management Guide; detection design in the Detection Engineering Guide.
Measuring coverage
- Share of Linux hosts sending SYSCALL, EXECVE and USER_LOGIN records to the SIEM in the last 24 hours.
- Share of events correctly reassembled (SYSCALL with items=N has N PATH records attached).
- Lost record count from auditctl -s, trending to zero.
- Time from a CONFIG_CHANGE or DAEMON_END on a production host to an analyst acknowledging it.
- Number of detections that use auid rather than uid for attribution.
Framework mapping
| Framework | Reference | Records that provide evidence |
|---|---|---|
| NIST SP 800-53 Rev. 5 | AU-2 Event Logging, AU-3 Content of Audit Records, AU-12 Audit Record Generation | SYSCALL identity and outcome fields, keyed rules |
| NIST SP 800-53 Rev. 5 | AU-6 Audit Record Review, AU-9 Protection of Audit Information | aureport reviews; CONFIG_CHANGE and DAEMON records |
| NIST CSF 2.0 | DE.CM-09 | Execution, file and module records on hosts |
| MITRE ATT&CK | T1059.004, T1548.003, T1136.001, T1098.004, T1685.004 | EXECVE, USER_CMD, ADD_USER, PATH on key files, CONFIG_CHANGE |
Common failure patterns
- Line-by-line parsing: detections on SYSCALL alone fire without the command line, and EXECVE records arrive without the user.
- Trusting PROCTITLE for full commands: long arguments are cut at 128 bytes; attackers can push the interesting part past the limit.
- Attributing by uid: every sudo action looks like root; auid and ses show who it really was.
- No b32 rules: 64-bit-only execve rules miss 32-bit binaries on the same host.
- Raw logs read elsewhere: interpreting RAW logs on an analysis host maps UIDs to the wrong names.
- Ignoring the watcher: no alert on CONFIG_CHANGE with remove_rule or on auditd stopping, so tampering goes unseen.
Practitioner checklist
- Reassemble events by node, timestamp and serial before any detection runs.
- Set log_format = ENRICHED on hosts whose logs are analysed centrally.
- Attribute actions with auid and ses, and treat auid unset on interactive tools as suspicious.
- Use EXECVE for command-line detections and decode hex arguments, including split a1[0] style chunks.
- Alert on USER_AUTH failure bursts, new USER_LOGIN sources, ADD_USER and group changes.
- Alert on CONFIG_CHANGE, DAEMON_END and DAEMON_ABORT, and on gaps in a host's records.
- Add b32 counterparts to execve and key syscall rules on 64-bit systems.
- Keep keyed rules for credential files, SSH keys, cron, modules and the audit configuration, and test each one.
Standards and references
- Linux kernel: include/uapi/linux/audit.h (audit message types)
- Linux Audit project: audit-records.h (user-space record types)
- Linux Audit project: ausearch(8)
- Linux Audit project: aureport(8)
- Linux Audit project: audit.rules(7)
- Linux Audit project: auditd.conf(5)
- Linux Audit project: audit field dictionary
- Red Hat: RHEL 9 Security hardening, Auditing the system
Related NHI Mgmt Group resources: Linux Logging and auditd for Defenders Guide · Detection Engineering Guide · CIS Control 8 Audit Log Management Guide · How to check a Linux server for signs of compromise