Repository navigation
Linux kernel sensor: audit netlink, Tetragon reader, minimal capabilities (#59) - #70
Conversation
Compares Tetragon, Falco and auditd netlink and picks audit netlink in the agent, with Tetragon's JSON export as an optional source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
platform/linux/audit.zig reads NETLINK_AUDIT as the audit daemon (or the read-only multicast group when auditd owns it, or auditd's log), joins SYSCALL, EXECVE, CWD, PATH, SOCKADDR and PROCTITLE records by serial and maps them to v2 process_start, process_exit, network_connect and file_create with entity ids. Parsing, joining, mapping and rule encoding are pure and tested against captured records in testdata/, with a pin test for the kernel constants. platform/linux/tetragon.zig maps Tetragon's export (process_exec, process_exit, tcp_connect kprobes) to the same events. collectors/linux_sensor.zig picks the source, reports it in sensor_health and agent_health.sensors (source, status, events per minute), and keeps the /proc poller as a 10 minute reconciliation pass beside a complete source, or as the fallback with degraded health. --linux-sensor-dump prints events without a server for CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AmbientCapabilities and CapabilityBoundingSet list CAP_AUDIT_CONTROL, CAP_AUDIT_READ, CAP_DAC_READ_SEARCH, CAP_KILL and CAP_SYS_PTRACE. User=tawny and every other hardening line stay. The dry run prints the unit and test-install.sh checks the exact set and each hardening line. Each capability is documented in production-agent-hardening.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent (linux-x64) runs --linux-sensor-dump as an unprivileged user with exactly the five unit capabilities through sudo setpriv, runs /bin/true 50 times and expects at least 50 process_start events with entity ids from audit netlink. If the runner refuses audit netlink it proves the auditd log path instead and warns. With no capabilities the sensor must fall back to the poller and report degraded. A watch rule for a missing folder no longer stops the agent registering as the audit daemon. nftables isolation is left for a follow-up; isolate_host keeps its not-supported message on Linux. Closes #59 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
*.log is ignored repo-wide, so testdata/audit.log never reached the branch and every agent job failed at @embedfile. Recreated it to the shape testdata/README.md and the test describe (node= prefix, enriched \x1d suffix, a split hex argument, execveat with only PROCTITLE, a connect, creates under PARENT and CWD, exit_group). Addresses use documentation ranges. Ran in an ubuntu:26.04 container: 183/193 pass, 10 skipped, and the test fails when the fixture is altered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The agent aborted under setpriv on the runner, but its output went to a file the step never showed, so the panic message was lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
windows-x64 runs the Linux parser tests too. std.fs.path.join uses the host separator, so a created file came out as /etc/cron.d\backdoor and the auditd log test failed. Audit and Tetragon records always carry Linux paths, so use POSIX-only helpers, with a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Linux runner aborted the agent: std.Thread.spawn hit 'reached unreachable code' starting the audit reader under setpriv with the audit capabilities (it treats EPERM and EINVAL from pthread_create as unreachable). Call pthread_create directly, log the errno, and return an error so the sensor falls back to polling. On that error, unload the rules and unregister before returning, without a double free. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ath test - The audit reader thread is still refused on the runner. Health now says which pthread_create errno it was instead of "failed to start". - The fallback CI path chowned the log to tawny-ci, so the runner could no longer append to it (Permission denied). The runner keeps ownership; tawny-ci only needs to read it. Checked in an ubuntu:26.04 container: 50 process_start events from the log path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shared log dir
- The runner refused pthread_create with EINVAL for the reader thread's
attributes. Retry once with libc defaults before falling back.
- The log-path fallback read a file under /home/runner, which tawny-ci
can't traverse ("audit log not readable"). Use a 0755 dir under
/tmp. Checked in ubuntu:26.04 with a 0750 home: 50 process_start.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Live audit capture now works on the runner: 54 process_start and 54 process_exit with entity IDs, 50 of them for /bin/true. On Ubuntu 26.04 /bin/true resolves to /usr/bin/gnutrue, so the check counted 0. It now matches readlink -f /bin/true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Status: all 11 CI checks pass on The agent ran as The step's grep count reads 100, not 50, because each matching line counts twice in the output file. The check is "at least 50", so this doesn't change the result, but the count is overstated. It's a small follow-up. Fixed after the PR opened:
Not done: nftables isolation ( Decisions for Justin:
Stacked on #68. It's independent of #69, so merge either first. |
…check The check matched the image path on any line, so each /bin/true run was counted on both its process_start and its process_exit, giving 100. Count process_start lines only. Checked against the runner's real output from the last run: 50. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Status: all 11 CI checks pass on |
# Conflicts: # .gitignore
Stacked on #68.
Linux kernel-backed process, network and file events for the agent (#59). The agent reads the kernel audit subsystem over
NETLINK_AUDITitself and can optionally read Tetragon's JSON export. The/procpoller stays on as the fallback and as a reconciliation pass.Acceptance criteria
docs/architecture/linux-sensor.md(audit netlink in the agent, optional Tetragon reader, Falco not used)process_startwith entity ids/bin/trueruns, at least 50 events with entity ids). See "What ran where" for the container limitnetwork_connectwith the owning processconnectrecords joined withSOCKADDR, owning processentity_idand pid. Tested on captured records (IPv4, IPv6, v4-mapped,EINPROGRESS). Unix sockets and refused connects are droppedtawnywith only the documented capabilities, all other hardening keptAmbientCapabilitiesandCapabilityBoundingSetlistCAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_DAC_READ_SEARCH CAP_KILL CAP_SYS_PTRACE.test-install.shchecks the exact set and every hardening line. Each capability is documented indocs/production-agent-hardening.mdsensor_health(sensor: linux_kernel,status: degraded,reason) at start, andagent_health.sensorscarrieslinux_kernelwithsource,statusandevents_per_minute. CI checks it with no capabilitiesagent (linux-x64)andagent-cross (linux-arm64)What changed
agent/src/platform/linux/audit.zig: netlink reader (registers as audit daemon and loads rules keyedtawny, or joins the read-only multicast group when auditd owns the socket), an auditd log tail, and pure functions for record parsing, joining by serial (SYSCALL,EXECVE,CWD,PATH,SOCKADDR,PROCTITLE,EOE), mapping to v2 events andaudit_rule_dataencoding. Captured samples are intestdata/. A pin test checks the message types, field ids, arch values and syscall numbers againstlinux/audit.hand the std syscall tables.agent/src/platform/linux/tetragon.zig: mapsprocess_exec,process_exitandprocess_kprobe(tcp_connect) export lines to the same events, with pure tests.agent/src/collectors/linux_sensor.zig: picks the source (linux_sensor = auto | audit | audit_log | tetragon | proc), drains it each loop, reports health and drops poller events the kernel source already sent. With audit netlink or Tetragon running the poller runs every 10 minutes; with a partial source (multicast, log) it keeps its normal interval.tawny-agent --linux-sensor-dumpprints events with no server, for CI and operators.agent/install/install.sh: the unit is written by a function so the dry run prints it; two capability lines added, nothing else changed.agent (linux-x64).Not in this PR
isolate_hoststill answers "isolate_host is not supported on linux yet", whichci/agent_e2e.pyand the contract suite depend on. NoCAP_NET_ADMINis granted.Commands run and results
zig build -Doptimize=ReleaseSafezig build test --summary allx86_64-linux,aarch64-linux,x86_64-windows,x86_64-macos(ReleaseSafe)zig build test --summary allinubuntu:26.04(agent only mounted)schemas/)bash agent/install/test-install.shubuntu:26.04--linux-sensor-dump --source audit_logwithtestdata/audit.logappended liveprocess_start, 1network_connect, 2file_create, 1process_exitsudoshimmedsetprivrecipe from the docsCapEff,CapAmb,CapBndall0000002040080024(exactly the five)cd server && zig test src/main.zig -lcSafeAllocatorlines/tmp/run-e2e.shheartbeat_ok,event_ok,schema_v2_ok,isolate_result_ok,e2e_okWhat ran where, and the gap
Docker containers (OrbStack, including
--privileged --pid=host) refuse audit netlink (auditctlgetsEPERMadding a rule), because the kernel only allows it from the initial namespaces. So live audit netlink was not proved locally. The CI step on the hosted VM is the live proof. If the hosted runner also refuses it, the step warnsaudit netlink was not available to the sensorand proves the auditd log path instead. I will note the result here once checks finish.🤖 Generated with Claude Code