- Go 79.1%
- HTML 14.3%
- Shell 2.7%
- Python 2.4%
- Makefile 1.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| cmd/corvo | ||
| deploy | ||
| design | ||
| docs | ||
| internal | ||
| testdata | ||
| .gitignore | ||
| .version | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| README.md | ||
Sees, stores and sends.
corvo is an auditd plugin that turns Linux audit's raw fragments into coherent events and delivers them as JSON to an HTTP endpoint. A single command executed arrives from the kernel as five separate records. corvo regroups them, resolves the identifiers into names, and sends the whole thing as a single event. Between capture and delivery there's a durable on-disk queue: if the endpoint goes down, events wait there and arrive whole and in order once it's back. Nothing leaves the queue before confirmation.
The five records are SYSCALL, EXECVE, CWD, PATH, and PROCTITLE,
joined only by the sequence number: without regrouping, the endpoint
receives useless fragments.
Primary target: AlmaLinux 9 (audit 3.x). Also supported:
Debian 12+ and Ubuntu 22.04+, which ship audit 3.x with the plugin at the
same /etc/audit/plugins.d/ path. Go 1.27 or later.
Why a plugin, and not direct netlink
The kernel delivers audit events to a single registered PID. A process that registers on netlink unicast knocks auditd out.
Multicast mode coexists with auditd, but silently drops events under load
and offers no backpressure at all. It only exists here as corvo tail, for
debugging, and is marked lossy in the help text.
As a plugin, auditd stays the owner of the rules and the kernel buffer, writes every line to corvo's stdin, and restarts the process if it dies.
Installation
From the RPM
Packages are built with nfpm, which doesn't
need rpmbuild on the build machine and produces both architectures from a
single deploy/nfpm.yaml:
make rpm
# dist/corvo-0.1.0-1.x86_64.rpm x86_64 servers
# dist/corvo-0.1.0-1.aarch64.rpm Raspberry Pi 3/4/5 on a 64-bit system
sudo dnf install dist/corvo-*.$(uname -m).rpm
The package installs the binary at /usr/bin/corvo, marks the three
configuration files as noreplace (an upgrade won't overwrite what you
edited), applies the SELinux labels in %post, and prints the remaining
steps. An upgrade also runs service auditd restart so the new binary
replaces the running plugin (auditd only re-execs the plugin on a restart,
and the durable queue means nothing is lost). Uninstalling takes the plugin
down before the binary disappears, and
preserves /var/lib/corvo/queue: there may be an audit event there
that hasn't been delivered yet.
One detail uninstalling warns about but doesn't fix on its own: the RPM
deletes corvo.rules, but the rule stays loaded in the kernel until an
augenrules --load or a reboot. In the meantime auditd keeps generating
those events into audit.log, now with nobody to deliver them. Reloading
the rules from a scriptlet would be worse: augenrules --load reloads the
entire set, and the distro's 10-base-config.rules starts with -D, and
an uninstall shouldn't touch rules that aren't corvo's.
Only Go needs to be installed. Cross-compilation is handled by the
toolchain itself (CGO_ENABLED=0), so the aarch64 RPM comes out of an
x86_64 machine with no emulation at all.
From the .deb
The same deploy/nfpm.yaml produces the Debian package:
make deb
# dist/corvo_0.1.0_amd64.deb x86_64 servers
# dist/corvo_0.1.0_arm64.deb Raspberry Pi 3/4/5 on a 64-bit system
sudo apt install ./dist/corvo_*_$(dpkg --print-architecture).deb
It installs to the same paths as the RPM, marks the config files as
conffiles, and depends on auditd. There is no AppArmor profile: auditd
on Debian/Ubuntu doesn't confine its plugins, so the process runs as root
with no LSM restriction and delivery over HTTPS works with no policy, which
is the one thing the SELinux module has to grant on AlmaLinux. Upgrade and
uninstall behave like the RPM: an upgrade restarts auditd to swap the running
plugin, an uninstall pulls the plugin before the binary and preserves
/var/lib/corvo/queue.
Requires audit 3.x (Debian 12+, Ubuntu 22.04+), where the plugin lives in
/etc/audit/plugins.d/. Older releases (Debian 11, Ubuntu 20.04) ship audit
2.x with the plugin in /etc/audisp/plugins.d/ and are not supported.
From source
sudo make install # PREFIX=/usr/local by default
The install target rewrites corvo.conf's path to the chosen PREFIX:
the file ends up pointing at /usr/bin/corvo, which is where the package
puts it.
Then, on both paths:
# 1. Token (0600 root, the plugin runs as auditd's child, i.e. as root).
printf '%s' "$TOKEN" | sudo tee /etc/corvo/token >/dev/null
sudo chmod 0600 /etc/corvo/token
# 2. Endpoint in /etc/corvo/corvo.yaml.
# 3. SELinux: see the section below, this is where it usually fails.
# The RPM already does this on its own.
# 4. Validate BEFORE touching auditd. Exits != 0 on any problem.
sudo corvo check
# 5. Load the rules and reload auditd. Some RHEL/Alma builds refuse
# `systemctl restart auditd`, use the service command.
sudo augenrules --load
sudo service auditd restart
# 6. Check.
sudo auditctl -l | grep cmds
pgrep -af '/usr/bin/corvo' # should show up as auditd's child
sudo journalctl -u auditd -n 50 # corvo's stderr lands here
Watch the path. On AlmaLinux 9
audispdwas merged into auditd, so plugins live in/etc/audit/plugins.d/. Almost every tutorial online still shows/etc/audisp/plugins.d/, which is the RHEL 7/8 one.
Set
log_format = ENRICHEDin/etc/audit/auditd.confif the machine has users outside/etc/passwd(SSSD, LDAP, AD). corvo's binary is static (CGO_ENABLED=0), so its own uid-to-name lookups only read/etc/passwd: a domain user would reach the endpoint as a bare number. WithENRICHED, auditd resolves the names (it links libc) and corvo passes them through.corvo checkwarns when this is missing. The cost is auditd doing one cachedgetpwuidper new id and a slightly largeraudit.log.
Audit rule
-a always,exit -F arch=b64 -S execve -F auid>=1000 -F auid!=unset -k cmds
-a always,exit -F arch=b64 -S execve -F auid=0 -k cmds-root
The -F filters are evaluated inside the kernel, before the event is
generated. That's why they matter for performance: they cut the cost at the
source instead of generating the record and discarding it afterward. The
deploy/corvo.rules file carries these two rules plus the 32-bit variants.
Both keys are active by default. cmds catches regular users and
cmds-root catches whoever logged in as root, over the console or direct
SSH. Auditing root is the entire point of a trail, since the administrator
is exactly who could otherwise erase their own tracks. Daemons don't get
swept in: systemd and whatever it starts have auid=unset, which doesn't
match auid=0.
The case that's still left out is auid=unset. What sets auid is
pam_loginuid, present in AlmaLinux 9's /etc/pam.d/login and
/etc/pam.d/sshd. If an interactive session shows up with auid=unset
(hypervisor console, agetty with no PAM, docker exec), the fix is in
PAM, not in a rule: with no auid the event holds nobody accountable. To
check the current session, corvo check shows its auid, and cat /proc/self/loginuid gives the raw answer. To validate collection
end-to-end from a session like that, the file carries the commented-out
cmds-all rule, which audits every execve and generates heavy volume.
SELinux
The plugin runs in auditd's domain, not your shell's. A corvo check run
by hand passes, and the same binary started by auditd fails: that's the
classic symptom of a wrong label. This holds for networking too: check
delivers the probe because your shell can dial 443, and the plugin can get
connect: permission denied on the same endpoint. That's why check reports
which context it's running in itself, and why it doesn't replace looking at
journalctl -t corvo after the plugin comes up.
What needs a label is the queue. The type is auditd_log_t, the same
one used by the files auditd creates, writes, and rotates under
/var/log/audit. It's the right type because the plugin runs in the
auditd_t domain, and that's the type that domain manages in full. The
label doesn't change where the queue lives, so auditd's space monitoring
keeps watching the log_file's filesystem.
Don't use audit_spool_t, however much the name of the spool for
undelivered events might seem to describe corvo's queue. That type belongs
to the audisp_remote_t domain, and with it applied auditd_t gets denied
already on the directory's search.
Through the RPM this is already done in %post. For an install from
source:
sudo semanage fcontext -a -t auditd_log_t '/var/lib/corvo(/.*)?'
sudo restorecon -Rv /var/lib/corvo
semanage ships in the policycoreutils-python-utils package, which isn't
on a minimal AlmaLinux 9 install. Without it, chcon -R -t auditd_log_t /var/lib/corvo fixes it right away, but is lost on a full system relabel.
The binary keeps the bin_t it inherits from /usr/bin. With no domain
transition, the plugin runs as auditd_t, the domain of whoever executed
it. Switching to audisp_exec_t would change the plugin's domain and, with
it, the entire permission set: that's a decision to make with the
machine's policy in hand.
If there's still a denial, it names exactly what's missing:
sudo ausearch -m avc -ts recent
The line carries scontext (who tried), tcontext (what was touched), and
the denied permission. As a last resort, ausearch -m avc -ts recent | audit2allow -M corvo-local && semodule -i corvo-local.pp, versioning the
module. What you don't do is setenforce 0.
Configuration
Three layers, in increasing order of precedence:
YAML file -> CORVO_* variables -> flags.
The commented example is at deploy/corvo.yaml. The
minimum:
endpoint:
url: https://logs.example.com/v1/audit
token_file: /etc/corvo/token # 0600 root, reread on every SIGHUP
queue:
dir: /var/lib/corvo/queue
Environment overrides use the field's path in uppercase:
CORVO_ENDPOINT_URL, CORVO_BATCH_MAX_EVENTS, CORVO_LOG_LEVEL.
An unknown CORVO_* variable brings down the process at startup, on
purpose: a misspelled CORVO_ENDPIONT_URL needs to fail loudly, not keep
silently sending data to the old endpoint. An unknown key in the YAML does
too.
Which events get delivered
The -k cmds rule doesn't limit what corvo receives. auditd hands the
plugin every audit event on the machine: SELinux AVC, CRYPTO_KEY_USER
from every SSH connection, SERVICE_START from every systemd unit. The
rule's -F filters only what the kernel generates for that rule. What
auditd itself produces doesn't go through any rule, and the dispatcher
doesn't know how to filter by type. That's why events show up on a server
where nobody is logged in.
The cut happens here, by record_type:
filter:
exclude: [crypto_key_user, crypto_session, service_start, service_stop, netfilter_cfg]
excludebeatsinclude. An emptyincludelets through everything not inexclude. With no section, nothing is filtered.- The command executed comes out as
syscall, which isexecvealready coalesced with theEXECVE,PATH,CWD, andPROCTITLErecords. Theuser_*ones are the session trail that gives it context. - A
record_typethat doesn't exist brings down the process at startup, instead of silently filtering. - Use one list or the other. Filling in both only makes sense to say "this whole family, except this type".
- Watch out for a composite event's type: it comes from the first
record, not from
SYSCALL. Anexecvethat triggers a SELinux denial comes out asavc, withpathsandprocessintact. That's why anincludewithoutavcand anexcludewithavcdrop the same command. If AVC volume is a problem, the fix is SELinux policy, not the filter. - The filter runs after coalescing, so the whole event is dropped: a half
event never ends up in the queue. What it cut shows up in
corvo_events_filtered_total.
What each record_type carries is documented in
design/api-contract.md, in
the event types section.
To see what your machine generates before deciding the list:
corvo tail -json | jq -r .event.record_type | sort | uniq -c | sort -rn
tail ignores filter on purpose: it's how you find out what to filter.
Filtering in corvo costs CPU: the event gets built and then thrown away.
When it can be cut in the kernel instead (a specific user's commands, a
whole syscall), the rule's -F is cheaper. filter exists for what the
rule can't reach.
SIGHUP
auditd sends SIGHUP when it reloads its plugins, and corvo applies the
new configuration without losing the queue or closing stdin. That's how
you rotate a token, change the endpoint, or adjust a filter without
stopping collection.
| Section | Applies with SIGHUP |
|---|---|
endpoint (url, token, headers, TLS, timeout, gzip) |
yes |
batch and retry |
yes |
filter |
yes, starting with the next event |
log.level |
yes |
queue, metrics, shutdown |
no, need an auditd restart |
The queue is left out because swapping the directory live would abandon events already written in the old one. Metrics and shutdown are left out because the server and the deadline are assembled once, at startup. In all three cases corvo logs a warning that the new value wasn't applied, instead of letting you believe it was.
An invalid new configuration is rejected in full: corvo logs the error and keeps the previous one, because an audit plugin that dies over a typo is worse than a plugin with a stale configuration.
To apply it, send the plugin a SIGHUP, no need to touch auditd:
corvo reload # or: pkill -HUP -x corvo
journalctl -t corvo -n 5 # confirm "configuration reloaded"
corvo reload signals every running corvo process and prints how many it
reached. systemctl reload auditd does not work: the auditd unit
refuses it.
How losing an event is avoided
Five barriers, each covering a different failure mode.
- auditd owns the buffer, not corvo. If corvo gets slow or dies, auditd buffers and restarts it.
- 1 MiB line buffer.
bufio.Scanner's 64 KiB default fails silently on overflow, and would drop exactly the longEXECVElines. Maintain()ticker every 500ms. Without it, an event whose lines never complete stays stuck in the reassembler forever.- On-disk queue before the network. Capture never blocks waiting on the endpoint.
- Clean shutdown.
SIGTERMstops the input, drains the reassembler, tries to empty the queue within the deadline, and syncs. Whatever doesn't fit stays on disk.
The queue
/var/lib/corvo/queue/
seg-00000042.jsonl active segment, rotates at 16 MiB
seg-00000043.jsonl
offset "seg-00000042 1048576"
dead/ permanently rejected batches
- Survives a restart of the process and of the machine.
- A write interrupted by a crash is repaired on open: since the format
is one JSON per line, the partial record is whatever comes after the
last
\n, and it gets truncated. - The offset only advances after the 2xx, and is written with a
writeto a temp file plus arename(atomic). It can be behind (which causes a resend), never ahead, which would skip events. - Inspectable during an incident:
tail -1 seg-00000042.jsonl | jq.
This makes delivery at-least-once. Every event carries a stable id
(<host>-<sequence>-<timestamp>) and the endpoint needs to treat a
repeated id as idempotent. That's a hard requirement of the delivery
contract.
When the queue fills up
queue.on_full |
Behavior |
|---|---|
drop_oldest (default) |
Erases the entire oldest segment (os.Remove, O(1), disk freed immediately) and counts corvo_events_dropped_total. Loses the past, preserves the present, the process stays alive. |
block |
Stops consuming stdin. auditd buffers, and if the outage lasts the kernel drops at the source, which shows up in corvo_events_lost_total. No event is dropped by corvo: the loss, if any, is the kernel's and stays visible. It's the right choice for strict compliance, and the cost is real. |
With block, it's worth raising q_depth in /etc/audit/auditd.conf and
deciding on the overflow_action.
The wait of block ends on shutdown. Once the input stops, what corvo
still holds in memory (a few thousand events at most) is written even past
max_bytes: stopping the agent with the endpoint down neither hangs nor
throws those events away.
When the endpoint is down
The endpoint being unavailable doesn't touch capture.
- The POST fails, the batch isn't confirmed, the offset doesn't advance, nothing is erased.
- Exponential backoff with jitter (1s -> 2s -> 4s -> ... up to 5min, ±30%). The jitter keeps an entire fleet from hitting the endpoint together once it's back. No attempt limit by default: giving up means losing an audit trail.
429and503respectRetry-Afterin both formats (seconds and HTTP date), capped byretry.maxso an absurd header doesn't freeze the agent.- The queue grows on disk.
corvo_queue_depth_bytesandcorvo_send_failures_totalclimb. That's the alert that fires before any loss happens. - Once the endpoint is back, the backlog drains fully and in order.
- A machine restart in the middle of the outage changes nothing: segments and offset are on disk.
What retry doesn't fix
400, 404, 413, and 422 don't improve by retrying, and a malformed
batch in infinite retry would freeze the queue forever. These go to
queue/dead/<timestamp>-<status>.jsonl along with the response in .err
(two batches rejected in the same millisecond get a counter after the
status, -1, -2, so neither overwrites the other),
corvo_events_dead_lettered_total climbs, and the pipeline continues.
Nothing is erased:
jq . /var/lib/corvo/queue/dead/*.jsonl
corvo replay /var/lib/corvo/queue/dead/20260904T120000.000Z-400.jsonl
replay resends the file as it was stored, with the same id on every
event, and exits 0 only when the endpoint confirmed all of them. Delete
the files from dead/ after that, not before.
401 and 403 are the exception: they're usually an expired token, not
bad data. They stay in retry for retry.auth_retry_window (15min by
default), giving a SIGHUP a chance to fix it on its own, and only then
become a dead letter.
The JSON sent
POST with a JSON array, Content-Type: application/json,
Content-Encoding: gzip when enabled, and Authorization: Bearer <token>.
{
"v": 1,
"id": "srv-web-01-2841-1756938610123000000",
"host": "srv-web-01",
"event": {
"@timestamp": "2026-09-04T12:30:10.123Z",
"sequence": 2841,
"category": "audit-rule",
"record_type": "syscall",
"result": "success",
"session": "5",
"tags": ["cmds"],
"summary": {
"actor": { "primary": "root", "secondary": "root" },
"action": "executed",
"object": { "type": "file", "primary": "/usr/bin/id" },
"how": "/usr/bin/id"
},
"user": {
"ids": { "auid": "0", "uid": "0", "gid": "0" },
"names": { "auid": "root", "uid": "root", "gid": "root" },
"selinux": { "user": "unconfined_u", "role": "unconfined_r", "domain": "unconfined_t" }
},
"process": {
"pid": "48213", "ppid": "48044", "title": "id -u",
"name": "id", "exe": "/usr/bin/id", "cwd": "/root",
"args": ["id", "-u"]
},
"data": { "arch": "x86_64", "syscall": "execve", "exit": "0", "tty": "pts0" },
"paths": [ { "name": "/usr/bin/id", "nametype": "NORMAL", "inode": "1049" } ],
"ecs": { "event": { "category": ["process"], "type": ["start"] } }
}
}
The full, verified example is at
testdata/execve-completo.json, frozen by
a test: changing the format breaks the suite instead of breaking someone's
endpoint.
Three traps for whoever receives it:
categoryandrecord_typeare strings, not numbers.- Almost everything is a string, including
pid,uid, andinode, since audit delivers those values in varied formats (decimal, hex,unset,4294967295), and the library doesn't risk converting them. dataandpathsare maps with open keys, which vary by syscall. In an Elasticsearch with strict mapping, they needdynamic: falseorflattened, or an exotic syscall creates new fields in the index.
Commands
corvo run plugin mode: reads stdin. This is what auditd calls.
corvo tail multicast, prints to the terminal. LOSSY, debugging only.
corvo replay <file> reads an audit.log, or a .jsonl from dead/, and sends it. Exit 0 only if all of it was delivered.
corvo check validates config, tests the endpoint, reports on the queue. Exit != 0 on failure.
corvo reload sends SIGHUP to the running plugin so it re-reads its config.
corvo check is useful in ExecStartPre and in CI:
$ corvo check
ok config https://logs.example.com/v1/audit
ok token /etc/corvo/token (0600)
ok queue /var/lib/corvo/queue: 0 pending event(s), 0 B on disk, 1 segment(s)
ok dead-letter empty
ok dns logs.example.com -> 10.0.0.5
ok endpoint HTTP 200 in 42ms
All good.
Use --offline to skip the networking part.
Observability
Off by default. With metrics.enabled: true, it exposes /metrics
(Prometheus text format) and /healthz.
| Metric | What to watch |
|---|---|
corvo_events_lost_total |
> 0 means the kernel dropped events before reaching corvo. Raise -b in auditd's rules. |
corvo_queue_depth_bytes |
Sustained growth = the endpoint isn't keeping up. |
corvo_events_dropped_total |
The queue filled up and drop_oldest kicked in. Real loss. |
corvo_events_dead_lettered_total |
Batches the endpoint permanently rejected. Someone needs to look at dead/. |
corvo_events_filtered_total |
Events cut by filter. If it's almost everything, the list is too tight, or auditd's rule is generating what nobody wants. |
corvo_send_failures_total |
Send failures. Climbs before any loss happens. |
corvo_post_duration_seconds |
POST latency. |
/healthz doesn't check the endpoint on purpose: corvo stays healthy with
the endpoint down, that's exactly what the queue is for.
Cost
Measured, not estimated. A replay of 50 thousand execve events (300
thousand lines, 49 MB of audit.log) on an i7-11800H, from parse to
writing the queue:
| Metric | Value |
|---|---|
| CPU per event | ~100µs (4.8s of user + 0.4s of sys for 50 thousand events) |
| Throughput per core | ~10 thousand events/s |
| Idle RSS | ~12 MB |
| Peak RSS, with the queue filling up | ~20 MB |
On a modest ARM VM, expect 2 to 3 times more CPU per event. In practice: an
interactive session generates somewhere between 5 and 50 execve per
second, which is under 1% of a core. A burst of dnf update or make -j
reaches hundreds per second for a few seconds, and it's the on-disk queue
that absorbs it, not memory. Reproduce with go test ./internal/pipeline -bench Pipeline.
Writing lines to the pipe isn't the bottleneck. It's a 1 to 2µs
memcpy. The real costs, in order, and three of them aren't corvo's:
- The audit rules (dominant).
-S execvemakes the kernel generate a record on every exec on the machine. Whoever writes-S alltanks performance even with no plugin at all. - auditd itself writing
/var/log/audit/audit.log. ParseLogLine: the biggest cost inside corvo. About 27% of the agent's CPU time is inregexp, inside go-libaudit's parser, and nothing in corvo works around that without switching parsers.- uid-to-name resolution, cached with a 60s TTL. Without a cache it
would be a
getpwuidper event, which on a machine with SSSD/LDAP would turn into a directory server query per command executed. Withlog_format = ENRICHEDcorvo reuses the name auditd already resolved and only falls back to its own lookup (/etc/passwd) for what's missing. - JSON and gzip, once per batch and not per event.
Disk. The default queue.fsync: none is the cheapest I/O policy: a
sequential append, flushed in batches by the kernel. It survives a process
crash, kill -9, and an auditd restart. A power loss loses the
not-yet-written window. batch and always exist in the config
for when the requirement changes.
Under normal conditions the queue holds almost nothing: segments are consumed and erased within seconds. It only grows during an outage, at 1.5 to 2.5 KB per event:
| Rate | Usage | max_bytes: 1 GiB covers |
|---|---|---|
| 10 ev/s | ~70 MB/h | ~14h of outage |
| 100 ev/s | ~700 MB/h | ~1.5h of outage |
| 1000 ev/s | ~7 GB/h | ~9min of outage |
Two honest notes: the queue is a second copy (auditd already writes
audit.log, so the volume written roughly doubles), and it stores
uncompressed JSONL even with gzip: true, because the gzip happens on
the POST body. This is deliberate: being able to run tail | jq on a
segment during an incident is worth the space, and the space only exists
during outages.
Development
make test # tests
make race # with the race detector
make cover # coverage in cover.html
make lint # go vet + golangci-lint if present
make build-all # static binaries for amd64 and arm64 in dist/
make rpm # the RPMs for both architectures
The version lives in .version (just the number, e.g. 0.1.0). That's
where both the RPM version and what corvo version shows come from, the
latter with the commit hash appended. To release a new version, edit
.version and create the tag.
No test requires auditd running or a real network. The audit.log
fixtures and the JSON golden live in testdata/. Rewrite the golden with:
go test ./internal/pipeline -update
Dependencies
Only two, each with a reason:
github.com/elastic/go-libaudit/v2: reimplementing audit's parser isn't worth it.gopkg.in/yaml.v3: the stdlib has no YAML.
Left out: cobra (a switch handles four subcommands), viper (the
explicit override fails loudly on a misspelled variable, viper stays
silent), bbolt (pure FIFO doesn't need a B+tree, and the file never
shrinks, which would make drop_oldest useless), prometheus/client_golang
(drags in protobuf and procfs, and the text format is three lines per metric).
License
MIT.