Kprobe
Docs › Start › How the sensor works

How the sensor works

Kprobe watches one process tree, not the whole machine. When you start an agent with kprobe run, the CLI creates a cgroup v2 directory for it (/sys/fs/cgroup/kprobe/run-PID), moves the agent into it before exec, and scopes every BPF program to that cgroup id. Children inherit the cgroup, so a subshell, a background job or a postinstall script is still the agent.

agentclaude, bash, cat, curl
cgroup v2kprobe/run-PID, inherited by every child
file policylsm/file_open | ksyscall/openat + security_file_open | seccomp
egress policycgroup/connect4, connect6, sendmsg4, sendmsg6
ring bufferJSON lines to stdout and --log
Where each part of the policy is enforced.

Files

The file policy picks the strongest backend the kernel offers:

BackendWhenWhat it does |
lsm/file_openBTF present and "bpf" in the active LSM listA real LSM hook. Protected inodes return -EACCES. |
ksyscall/openat, openat2, open + kprobe/security_file_openBTF and the kprobe PMU present (stock Ubuntu, Debian, Fedora, GitHub runners)Path and basename match at syscall entry with bpf_override_return(-EACCES). The syscall entries are on the kernel's error-injection list. security_file_open checks the inode as a backstop and sends SIGKILL to an opener that got through by a link. |
seccomp user-notifyKernels without BPF tracing, such as Firecracker microVMsA seccomp filter installed before exec sends open and exec calls to the supervisor, which resolves the path (cwd, dirfd, realpath) and answers -EACCES or lets the call continue. |

Egress always runs in eBPF, on every backend.

Egress

cgroup/connect4, connect6, sendmsg4 and sendmsg6 programs are attached to the agent's cgroup. Each connect is looked up in an LPM trie of allowed addresses. Host names in the policy resolve when the run starts. UDP to port 53 is only allowed to the first resolver in /etc/resolv.conf, which closes DNS tunnelling from inside the tree.

Timeline

Events go through a BPF ring buffer to the CLI, which prints one JSON object per line on stdout and to --log.

{"t":1751.1,"ev":"open","pid":1614,"comm":"cat","path":"/var/lib/agent/.ssh/id_ed25519","verdict":"denied","rule":"KP-0001","hook":"seccomp:openat"}
{"t":1793.4,"ev":"connect","comm":"curl","addr":"203.0.113.7","port":8443,"verdict":"denied","rule":"policy/arena","hook":"cgroup/connect4"}
{"t":1797.2,"ev":"kill","reason":"secret-then-egress","rule":"KP-0007","scope":"process tree"}
FieldMeaning |
tmilliseconds since the run started |
evstart, exec, open, connect, sendmsg, kill, exit |
verdictallowed, denied, would-deny (audit mode), killed |
rulethe id of the rule or policy that answered |
hookthe kernel hook that produced the event |
← QuickstartPolicy reference →