← 03 — Blog

auditd is losing events, and it tells you only if you ask

Tooling2 min read

The Linux audit system has a queue between the kernel and the auditd daemon. When the queue fills faster than the daemon drains it, the kernel drops records, increments a counter and moves on. Nothing in your SIEM shows a gap; the events simply never existed.

Symptom

On a busy server — a build agent, a web server under load, a box running a backup — execve records for some commands you know ran are missing. Other hosts with the same rules look complete.

Cause

The kernel buffers audit records in a backlog with a fixed maximum size, backlog_limit. If it fills, what happens next depends on the failure mode (-f): 0 drops silently, 1 (the default) drops and writes a kernel message, 2 panics the machine. Rules that log every execve on a host that starts thousands of short processes are the classic way to fill it. Bursts at boot are another, because the backlog fills before auditd has started and loaded your rules.

Check

sudo auditctl -s

The fields to read:

  • lost — records dropped since boot. Anything above zero means gaps.
  • backlog — records currently queued.
  • backlog_limit — the queue size.
  • failure — the failure mode, as above.

Then look for the kernel’s own complaints:

sudo dmesg | grep -i 'audit: backlog limit exceeded'
sudo journalctl -k | grep -i audit_lost

Check lost twice, a few hours apart. A number that grows during working hours tells you when the queue overflows; one that only grew at boot points at the early-boot case.

Fix

  • Raise the backlog. Most rule sets start with -b 8192; busy servers may need more. Kernel memory use grows with it, so raise it in steps and watch lost.
  • Cover early boot with the kernel parameter audit_backlog_limit=8192 on the boot command line, so the queue is large before auditd loads its rules.
  • Reduce volume at the source. Exclude known-noisy, known-good activity in the rules themselves — the build user’s compiler runs, the monitoring agent’s checks — instead of logging everything and filtering in the SIEM. The auditd baseline is written with that in mind.
  • Check the daemon side too. If auditd itself cannot write fast enough, or the disk fills, its auditd.conf actions (disk_full_action, space_left_action) decide what happens. Make sure those are set to something you would choose, not left at defaults nobody reviewed.
  • Monitor the counter. Ship auditctl -s output, or just lost, to your SIEM on a schedule and alert when it increases.

Takeaway

An audit trail with silent gaps is worse than a smaller one without them. Read lost on every host you rely on, and treat a growing number as a broken log source.