AI agent security
Production agents should be unable to misbehave, by design
A containment architecture where security is structural, not aspirational.
Kevin Keller · kevinkeller.org
Why it matters
LLM judgement is not a security control
- Generic agents get Bash, file access, web fetching and MCP.
- They can run any command, read any file and call any discovered tool.
- That works for development. In production it is a liability.
Not "can the agent do the right thing?" but "can the agent do the wrong thing?"
Sandboxes are not enough
A sandbox limits where damage happens, not whether
- Inside the sandbox the agent still has a shell and dynamic tool discovery.
- A tricked agent can still exfiltrate through an allowed network path.
- An MCP server can add tools after the sandbox was reviewed.
A perimeter around an unbounded capability set.
Layer 1: the custom agent
It can only do what its code allows
- Tools are a fixed set of functions, for example three.
- No shell tool, no file tool, no general HTTP tool.
- The runtime rejects any hallucinated tool call.
- A fixed tool set makes the agent fully integration-testable.
The idea
Not a guardrail. The absence of capability.
Build the agent fit for purpose, then add the sandbox as defence in depth.
Layer 2: the container
Network, files and resources are bounded
| Destination | Allowed |
|---|---|
| Inference proxy | Yes |
| Platform API | Yes |
| Public internet | No |
| Internal services, other containers | No |
Read-only /app, limited /tmp, resource limits, immutable signed images.
Layer 3: the inference proxy
One control plane for every prompt
- Prompt policy: fast pattern matching, then a judge model, to block, warn or log
- FinOps: tokens per agent and team, budgets, anomaly alerts
- Observability: latency, errors, model degradation
- Audit: every prompt, response and policy result in one place
Combined
No single layer is sufficient
| Threat | Agent | Container | Proxy |
|---|---|---|---|
| Code execution | No shell tool | No shell | None |
| Exfiltration | No HTTP tool | Egress blocked | Pattern detection |
| Prompt injection | Fixed tools limit impact | None | Policy engine |
| Runaway costs | Scoped tools | Resource limits | Budget quotas |
In sequence
Each layer catches what the last one missed
- The agent cannot run arbitrary commands.
- If it could, the network would not let it reach unintended destinations.
- If the network allowed it, the proxy would block the malicious prompt.
Checklist highlights
Where to start
- A fixed, enumerated tool set with input validation.
- Egress only to the inference proxy and the platform API.
- All inference through the proxy, with cost attribution and logging.
- An evaluation suite in CI, agent identity in the identity provider, least privilege.
The takeaway
Build agents that cannot misbehave, because you didn't give them the tools to.
Kevin Keller · kevinkeller.org