Kernex
Zero-trust kernel-level execution sandbox for AI agents
How it works
The problem
Autonomous agents are no longer a curiosity, they're running shell commands, reading files, and making network requests on a user's behalf. The security model most people apply to them is implicit trust: if the agent was invoked by our system, it must be safe.
That assumption is wrong. A prompted agent can be steered, injected, or simply buggy, and it holds the same keys you do.
Kernex started from a different premise: every action authorized at the kernel level, every invocation auditable, no agent more capable than its current task requires.
The approach
Kernex is a single static Rust binary that wraps the agent's process. Nothing about the agent changes; you prefix the command:
kernex run -- python my_agent.pyOn Linux it builds a Landlock ruleset, installs a seccomp BPF filter, and calls landlock_restrict_self() before execve(), so the restrictions are in place before the agent's first instruction and are inherited by everything it spawns. No root, no daemon; on kernels older than 5.13 it falls back to seccomp alone. On macOS it registers for Endpoint Security AUTH events instead (beta).
What the agent may touch is declared in a kernex.yaml policy:
filesystem:
allow_read: ["./src", "./data"]
allow_write: ["./output"]
block_hidden: true # .ssh, .aws and every other dot-directory
network:
allow_outbound:
- host: api.anthropic.com
port: 443
block_all_other: true
environment:
allow_read: ["ANTHROPIC_API_KEY"]
block_all_other: trueWith --mcp, every MCP server the agent talks to gets its own filesystem and network boundary, separate from the agent's.
If the agent tries something the policy doesn't allow, the kernel refuses it. Not the model, and not a Python wrapper the model could rewrite. The kernel.
The surface
kernex init # interactive wizard, writes a starter kernex.yaml
kernex run # run an agent under full enforcement
kernex audit # observe a run, generate or update kernex.yaml
kernex diff # compare two policies or two audit sessions
kernex status # summarise the active policy and its scoreFive commands, and that's a security property, not an aesthetic choice. A small surface means fewer attack vectors, easier auditing, and clearer reasoning about what the system can and cannot do.
Audit mode writes the policy
Hand-writing a least-privilege policy for an agent you didn't write is guesswork. So the first run is an observation: kernex audit -- python my_agent.py records every file read, write, and network request, and when the process exits it writes a kernex.yaml scoped to exactly that. From then on, kernex run enforces it.
Strict rules shouldn't crash unpredictable agents either. When an agent hits a boundary during a run, Kernex pauses the system call and asks the operator in the terminal, who can grant a one-shot exception or let the denial stand. That's the gate in the diagram above.
Results and what I learned
- A 5-command CLI covers the entire lifecycle: init, run, audit, diff, status.
- Zero-trust moves from a compliance word to an enforcement mechanism: the kernel is the policy engine.
- Audit-then-enforce beats hand-written policy. One observed run produces a tighter
kernex.yamlthan guessing, andkernex diffshows exactly what changed between runs. - Rust was the right call for a security boundary: one static binary with no runtime to trust, and the type system keeps policy declarations honest.
The next iteration is exploring GPU-passthrough fences, so agents running inference inside a Kernex cell get the same guarantees as everything else.