Skip to content

Lesson 8 of 14 · 13m

Linux Telemetry That Holds Up

auditd execve and eBPF tracepoints give the honest exec stream; .bash_history is an attacker-authored document.

On Linux, the honest execution source is the kernel — auditd or an eBPF sensor — and everything else is a courtesy log. That distinction is the whole lesson, because the file people reach for first, ~/.bash_history, is the one an intruder controls.

auditd: the exec stream

The rule that matters:

-a always,exit -F arch=b64 -S execve -k exec
-a always,exit -F arch=b32 -S execve -k exec

Every execve logged: the EXECVE record carries argc and a0…aN as hex-encoded arguments, auid records the login UID and survives sudo/su (plain uid changes — auid is the field that tells you whose session this really is), and ppid gives you the parent chain. ausearch -k exec -i renders it human-readable; aureport -x summarizes. The trap: EXECVE truncates at the kernel's argument limits, so a 4KB base64 blob may arrive cut — which is itself a signal, because normal commands are short.

osquery's process_events table rides auditd on Linux, so SELECT * FROM process_events WHERE path LIKE '/tmp/%'; works fleet-wide if audit is running. eBPF sensors — Falco with its rules engine, Tetragon with TracingPolicy CRDs — hook sched_process_exec tracepoints with lower overhead and, unlike auditd, attach container metadata to every exec. Which matters, because containers share the host kernel: auditd sees every containerized exec but can't always tell you which pod it came from. eBPF can.

One honest auditd caveat: it is a netlink pipeline, and under exec-storm load it drops records and logs the drop rather than lying about coverage. If auditctl -s shows a growing lost counter, your exec stream has holes exactly where an attacker would want them. eBPF rings drop differently — silently, unless the sensor reports the metric — so monitor drop counts whichever backend you run.

The auth surface

/var/log/auth.log (Debian family) or /var/log/secure (RHEL family) is your 4624. Accepted publickey for deploy from 203.0.113.9 port 51244 ssh2 gives you account, source, method; with LogLevel VERBOSE in sshd_config it appends the key fingerprint — the join into your key inventory. sudo: lines carry TTY, PWD, USER, and COMMAND, which is a complete audit sentence. journald holds unit lifecycle — but default Storage=auto on many distros means journald dies with the box; set Storage=persistent or forward it, or assume it's gone.

Why bash_history is a trap

Shell history is written when an interactive shell exits cleanly. export HISTFILE=/dev/null, HISTSIZE=0, kill -9 $$ to skip the flush, history -c, a non-interactive shell that never writes it, ssh host 'cmd' that leaves nothing client-side — pick one and the file is empty or curated. An empty .bash_history on a suspected host proves the shell exited, nothing more. The wrong model is treating its contents as ground truth; the right one treats it as an attacker-authored document that occasionally tells the truth.

The xz backdoor is the case study: liblzma 5.6.1 was pulled into sshd through the libsystemd linkage, and the tells were library loads and a tarball that differed from git — nothing in any shell history would have shown it. Exec streams and unit loads would have.

The persistence-adjacent surfaces

Two file surfaces do persistence work and telemetry work simultaneously. Cron spread across /etc/crontab, /etc/cron.d/, /var/spool/cron/, and @reboot lines is auditable with a single find — and since no auditd rule fires on file edits by default, the honest check is a daily diff of those directories against a manifest. Second, authorized_keys files: auditd -w watches or a config-management diff catch new keys, including command= forced-command entries that turn a login key into a launcher. Neither of these surfaces emits an event; you diff them.

Minimum viable coverage

The auditd execve rules, persistent journald, LogLevel VERBOSE, and an exec stream you can query fleet-wide (osquery or eBPF). Then the hunts: Accepted lines versus your config-management key inventory, sudo COMMAND tails on servers that shouldn't have humans, and new unit files — systemd is Linux's service-install event.

And one trap on the auditd side: auid=4294967295 (unset) marks processes spawned outside a login session — daemons, cron children, and anything an intruder launched through a webshell or service exploit. Those processes carry no accountable user, which is not noise; it is a filter that isolates exactly the executions worth pivoting on.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.