Kprobe
Docs › Reference › Policy reference

Policy reference

A policy is a YAML file. Rules use the same format, one file each, with an id.

id: policy/claude-code
name: claude-code
mode: enforce            # enforce | audit
deny_read:
  - ~/.ssh               # a directory or file, and everything under it
  - name: .env           # a file name anywhere on disk
  - name: .env.*         # a name prefix
egress_allow:
  - api.anthropic.com    # a host, resolved at start
  - 10.0.0.0/8           # a CIDR
  - 2606:4700::/32       # IPv6
kill_on: [secret-then-egress]

Paths

deny_read entries that start with / or ~ are paths. ~ expands to the home of the agent's user. A directory protects every file under it; the kernel backends also record the inodes, so a hard link or a symlink to a protected file is refused too.

Names

name: entries match the last path component wherever it is. A trailing * makes it a prefix. Names are limited to 31 bytes.

Egress

Loopback is always allowed. Every other address must match egress_allow. Allowed connects still appear on the timeline.

Sequences

kill_on: [secret-then-egress] kills the whole tree (cgroup.kill) when a denied or would-deny secret read is followed by a connect the policy does not allow. In audit mode the timeline records would-kill instead.

Merging

kprobe run --policy FILE --rules DIR loads the policy, then every .yaml file in DIR in name order. Every event carries the id of the file that matched.

Lint

kprobe policy lint policies/claude-code.yaml /opt/kprobe/rules
← How the sensor worksmacOS, Windows and containers →