Blog / 26 November 2026
Deep dive · 26 November 2026 · 14 min read
Zero Trust sandboxes for AI agents: what they are and how to build one
A Zero Trust sandbox for an AI agent is an isolated machine that assumes the agent is already compromised. The agent runs in its own microVM. Everything that decides what it may do (the network rules, the keys, the approvals and the log) runs outside that machine, where the agent cannot reach it. This guide maps NIST's Zero Trust tenets to agents, explains why a container alone falls short, and walks through the six controls you need, with a checklist.
01What is a Zero Trust sandbox for AI agents?
An AI agent is a model in a loop with tools. It reads a task, runs a command, reads the result and decides again. A plain sandbox answers one question: can the agent's code touch my computer? A Zero Trust sandbox answers a harder one: what can a hijacked agent do with everything I gave it on purpose?
That matters because agents are easy to steer. Anything the agent reads can carry instructions: a README, an issue, a web page, a tool description. OWASP ranks this first in its Top 10 for LLM Applications, and its Top 10 for Agentic Applications opens with Agent Goal Hijack. You cannot filter every bad instruction out of the world, so assume the agent will sooner or later do what an attacker wants.
A Zero Trust sandbox is built on that assumption. It has a strong wall, a virtual machine with its own kernel, and a set of decisions made outside the wall: which hosts the agent may reach, which keys it may use without seeing them, which actions need a person, and a record of everything. For the basic definition of an agent sandbox, start with What is an AI agent sandbox?.
02NIST's Zero Trust tenets, applied to an AI agent
NIST SP 800-207 defines Zero Trust as a set of tenets, not a product. It was written for users, devices and services, but it fits agents well. An agent is a non-human subject that asks for access to resources, all day, at machine speed. Here are the seven tenets from section 2.1, in our words, with what each one means for an agent.
| NIST tenet (paraphrased) | What it means for an AI agent |
|---|---|
| Every data source and service is a resource. | The model API, the registry, the Git host, each MCP tool and the workspace are resources the agent must be granted one by one. |
| All communication is secured, whatever the network location. | Running on your laptop or in your VPC earns the agent nothing. |
| Access is granted per session. | Access lasts for one task. Approvals are single-use. |
| Access is decided by dynamic policy. | Rules look at the request: which host, which tool, which arguments. |
| The integrity and posture of every asset are monitored. | You know what image the sandbox booted and what it installed. |
| Authentication and authorization are enforced before access. | Every packet and tool call is decided before it happens, not reviewed later. |
| Collect as much information as possible and use it to improve. | Every decision, allowed or refused, goes to a log the agent cannot edit. |
NIST also names the parts that decide. A policy engine decides, a policy administrator carries the decision out, and a policy enforcement point stands in the path of the request. The design rule for agents follows: none of those parts may run inside the agent's machine. A rule the agent can edit is only a suggestion. For identity and secrets under this model, see our Zero Trust for AI agents guide.
03Why containers alone are not enough
Every container on a host shares that host's kernel. Docker's own security documentation explains how much of a container's safety rests on namespaces, control groups and the capabilities you leave on. That is fine for code you wrote. It is a thin wall for code a hijacked agent writes, because one kernel or runtime bug can reach the host. CVE-2024-21626 in runc, for example, let a container process get a working directory on the host filesystem.
The bigger problem is that a better wall does not solve the rest. Suppose the wall is perfect. An agent can still leak the API key in its environment, send your code to any host it may reach, or call a permitted tool with harmful arguments. None of these cross the wall. Simon Willison calls the dangerous mix the lethal trifecta: private data, untrusted content and a way to send data out.
Real cases follow that pattern. CVE-2025-55284 in Claude Code let an injected agent read a file and send it out through DNS lookups, with commands approved by default. In the AGENTS.md hijack, a markdown file talked a coding agent into running a malicious package. Isolation is the floor. The controls around it stop the damage.
04The six controls of a Zero Trust sandbox
Each control answers a different way a hijacked agent can hurt you. Only the first one is about the wall. The other five live on the host.
- 1. MicroVM isolation. The agent's code runs in a virtual machine with its own kernel. It sees one workspace folder and nothing else on the host.
- 2. Deny-by-default egress. Nothing leaves the sandbox unless it goes to a host you named. DNS is answered on the host, for listed names only.
- 3. Brokered credentials. Real keys stay on the host. The sandbox holds a placeholder, and a broker adds the real key on the way out, only to the right host.
- 4. Approvals. Destructive or boundary-widening actions wait for a named person. Approvals cover one exact action, once.
- 5. Tamper-evident audit. Every decision, allowed or refused, is written outside the sandbox, in a chained log where edits and deletions show.
- 6. Ephemeral and snapshot lifecycle. Each task starts from a clean machine and ends with it deleted. A checkpoint before a risky step lets you rewind the whole machine.
Numbers match the six controls. The tool gateway and approvals together make control 4.
05Control 1: microVM isolation
A microVM is a small virtual machine with its own guest kernel and few virtual devices. It keeps the hardware boundary of a full VM but boots in well under a second. Firecracker was built by AWS to run untrusted code from many tenants on one host; its NSDI 2020 paper explains the design. Cloud Hypervisor and Apple's Virtualization framework fill the same role elsewhere. User-space kernels such as gVisor are a middle ground.
Require one VM per agent or per task, never one shared by many agents. The agent should see one workspace folder and no host paths, sockets or credential files. For the trade-offs, read What is a microVM? and Firecracker vs gVisor vs Kata Containers.
06Control 2: deny-by-default egress
Most data theft by agents is just network traffic. So the network starts closed, and you open only the hosts the task needs, usually the model API and a package registry. Three details decide whether this works.
First, enforce it outside the VM: root in the guest can turn off a guest firewall, and you must assume the agent has root. Second, answer DNS on the host and refuse unlisted names, or a lookup that encodes your data leaks it, as CVE-2025-55284 showed. Third, an allow-list limits where data goes, not what is sent. Any allowed host that accepts uploads is still a way out; MITRE ATT&CK calls this exfiltration over a web service. More in How AI agent egress control really works.
07Control 3: brokered credentials
If a key is an environment variable in the sandbox, then the agent, every package it installs and every script it is tricked into running can read it. Anything that can read a key can send it somewhere.
So keep the key out. The sandbox gets a placeholder that is worthless anywhere else. A broker on the host swaps in the real key on requests to the right host. An injected agent that prints its environment prints nothing useful.
The limit: while the sandbox runs, the placeholder can still spend the key on allowed routes. Scope each key at its provider, give each agent its own key, and limit methods and paths. The full pattern is in Prompt injection, API keys and the egress broker.
08Control 4: approvals for risky actions
Some actions cannot be undone: deleting data, merging to main, spending money, widening the sandbox's own access. OWASP calls this failure Excessive Agency. Put a person in the loop for those actions, and only those. Ask for everything and people click yes without reading.
A good approval system classifies actions by blast radius, shows the exact command and target, covers that one action once, and never lets an agent approve. For tool calls, pin each tool's definition so a changed description is held for review (see MCP tool poisoning), and write rules that look at a call's arguments, not only its name.
09Control 5: tamper-evident audit
After an incident, the first question is what the agent did. The log must answer it, and the agent must not be able to edit the answer. So the host writes the log, not the guest. It records allowed actions as well as refusals: the actor, the action, the target, the rule and the result. It leaves out secrets and request bodies.
Chaining makes tampering visible. Each entry includes a hash of the one before, so changing or removing an entry breaks the chain. A signature lets others check it without trusting you. Send a copy to your SIEM. See what an audit log for AI agents should record.
10Control 6: ephemeral and snapshot lifecycle
Zero Trust says access is per session. For a sandbox, the machine itself is per task. Start from a known image, delete the machine at the end, and give every sandbox a time limit. Anything a compromised task planted goes away with it.
A checkpoint before a risky step saves the whole machine: disk, memory and running processes. If the step goes wrong, rewind. That undoes more than Git can, as we explain in AI coding agents need a whole-machine undo. One rule: a snapshot must never hold a real secret.
11How to build one yourself
You can assemble a Zero Trust sandbox from open parts. A typical Linux build:
- Isolation: Firecracker or Cloud Hypervisor on KVM, one microVM per task, one shared folder.
- Network: a tap device per VM, host firewall rules that drop by default, and a host DNS resolver for allow-listed names only.
- Credentials: a host proxy that matches the destination and injects the real header; the VM gets a placeholder.
- Approvals: a gateway in front of MCP tools that pins definitions, checks arguments and queues risky calls for a person.
- Audit: an append-only, hash-chained, signed log on the host, forwarded to your SIEM.
- Lifecycle: a controller that boots clean images, enforces time limits, snapshots and deletes.
The hard parts are the seams: keeping DNS and firewall in sync, making the proxy impossible to bypass, and logging every layer's decisions. Lighter options exist: Anthropic describes OS-level isolation plus a proxy in Claude Code sandboxing, and we compare it in Claude Code's built-in sandbox, explained. Match the level to what the agent can reach.
12The Zero Trust sandbox checklist
Use this to review any agent sandbox, bought or built. A "no" is not always wrong, but it should be a choice someone wrote down.
- Each agent or task runs in its own VM with its own kernel.
- The agent sees one workspace folder and no host paths, sockets or credential files.
- Network egress is closed unless a host is on a written allow-list.
- Egress rules are enforced on the host, so root in the guest cannot lift them.
- DNS is answered on the host, for listed names only.
- No allowed host accepts arbitrary uploads, or you accept that risk in writing.
- No real API key, token or password exists inside the sandbox.
- Destructive and access-widening actions always wait for a named person.
- Approvals cover one exact action, once, and no agent can approve.
- Tool definitions are pinned, and changes are held for review.
- Every decision, allowed or refused, is logged on the host in a hash chain you can verify.
- Logs go to your SIEM, and you can export evidence for one sandbox.
- Every sandbox has a time limit and is deleted at the end of its task.
- You have a kill switch that stops every agent at once.
13How kosa8 implements each control
kosa8 is Zero Trust cybersecurity infrastructure for AI agents. Its threat model is the one above: assume an attacker controls what the agent reads and has root inside its machine. Here is how each control maps, with the limits stated plainly.
| Control | In kosa8 | Limit to know |
|---|---|---|
| MicroVM isolation | kosa8 sandbox and kosa8 agent run give each workload its own VM and Linux kernel: Apple's Virtualization framework on Macs, Cloud Hypervisor on KVM on Linux. One workspace folder is visible. | The Docker-compatible kosa8 run shares one VM unless a signed policy sets require_sandbox. Cloud overflow sandboxes run on Cloudflare Containers unless you name a region. |
| Deny-by-default egress | Every packet is decided on the host; root in the guest cannot lift the rules. DNS answers listed names only. Agent-created and brokered sandboxes start closed. | A sandbox you create by hand is open unless you pass --egress deny or --egress-allow, or your organization sets a default. Bodies to allowed hosts are not inspected. |
| Brokered credentials | The sandbox holds a placeholder; the egress broker adds the real key only for the named host. Cloud secrets can be limited to methods and paths. | The placeholder can spend the key on its allowed route while the sandbox runs. |
| Approvals | Destructive and boundary-widening actions ask every time and cannot be auto-approved. kosa8 mcp approve ID approves one held tool call, once, for ten minutes. Named approvers sign approvals; replays are refused. | A rule you did not write protects nothing. |
| Tamper-evident audit | A hash-chained log written on the host, checked by kosa8 audit verify, with CEF export. kosa8 Cloud keeps a SHA-256 chained log you can read by API and stream to a SIEM. | Bodies, query strings and the environment are never recorded, on purpose. |
| Lifecycle | --ephemeral, --ttl and --auto-stop on create; kosa8 checkpoint and kosa8 rewind for the whole machine. | Sandboxes holding Cloud secrets cannot be checkpointed, so secrets never land in a snapshot. |
A short example: kosa8 agent run -w ~/code/api claude starts Claude Code in its own microVM, with your project as the only visible folder, the network closed except through the broker, and the Anthropic key kept on the host. Add --dry-run to see the plan first. Then run kosa8 audit verify. On kosa8 Cloud, kosa8 cloud freeze is the kill switch.
The full map is in the Securing an agent guide. kosa8 bounds what a hijacked agent can do; it does not stop prompt injection itself. Its SOC 2 Type II audit is in progress, with the report expected in January 2027, and it has not had an external penetration test yet. The trust page keeps that status current.
Takeaways
- A Zero Trust sandbox assumes the agent is compromised and makes every decision about it outside its machine.
- Isolation is the floor. Most agent damage uses the keys, network and tools the agent was given.
- The six controls: microVM isolation, deny-by-default egress, brokered credentials, approvals, tamper-evident audit, and an ephemeral lifecycle with snapshots.
- Enforce egress and DNS on the host. An allow-list limits where data goes, not what is sent.
- Keep real keys out of the sandbox, scope them at the provider, and log every decision where the agent cannot edit it.
Where kosa8 fits · Zero Trust cybersecurity infrastructure for AI agents
kosa8 gives every AI agent its own microVM, with network rules, a secret broker, approvals and a hash-chained audit log enforced on the host, out of the agent's reach. It runs on your Mac or Linux machine, your own servers, air-gapped, or on kosa8 Cloud. Start free with no card.
Read next: AI security for the enterprise · AI for cybersecurity · Cybersecurity for AI agents, topic by topic
Check yourself · +100 XP
An agent runs in a perfect microVM, but its API key is an environment variable inside it. Which control is missing?
The VM stops the agent reaching your host, but anything inside it can read the key. A broker on the host keeps the real key outside and gives the sandbox a placeholder. Egress rules help, but the agent can still send the key to any host it is allowed to reach.
Questions people ask
What is a Zero Trust sandbox for AI agents?
It is an isolated machine, usually a microVM, where an AI agent's commands run, combined with controls that live outside that machine: deny-by-default network rules, brokered credentials, approvals for risky actions, a tamper-evident audit log and a short lifecycle. It assumes the agent may be hijacked at any time.
How does NIST SP 800-207 apply to AI agents?
Treat each agent as a non-human subject that gets no trust from where it runs. Grant access per task and per request, decide it by policy that looks at the request, enforce it before access, and log everything. The policy decision and enforcement points must sit outside the agent's machine.
Is a Docker container a Zero Trust sandbox?
Not on its own. A container shares the host kernel, so a kernel or runtime bug can reach the host. Even with a stronger wall, you still need network rules, credentials kept outside, approvals and an audit log, because most agent damage uses what the agent was given.
Does a Zero Trust sandbox stop prompt injection?
No. It limits what a hijacked agent can do, not what it reads. An injected agent in a good sandbox can only reach listed hosts, holds no real keys, needs a person for risky actions and leaves a record of every attempt.
What is the difference between deny-by-default egress and an allow-list?
They are the same idea seen from two sides. Deny by default means nothing leaves the sandbox unless a rule allows it, and the allow-list is that rule. It must be enforced outside the VM, including DNS, to hold against root in the guest.
Sources
- SP 800-207, Zero Trust Architecture — NIST
- LLM01:2025 Prompt Injection — OWASP Gen AI Security Project
- LLM06:2025 Excessive Agency — OWASP Gen AI Security Project
- OWASP Top 10 for Agentic Applications for 2026 — OWASP Gen AI Security Project
- The lethal trifecta for AI agents — Simon Willison
- Docker Engine security — Docker docs
- CVE-2024-21626 (runc) — NIST National Vulnerability Database
- Permissive default allowlist enables unauthorized file read and network exfiltration in Claude Code (CVE-2025-55284) — GitHub Security Advisory
- Firecracker: Lightweight Virtualization for Serverless Applications (NSDI 2020) — USENIX
- What is gVisor? — gVisor docs
- Exfiltration Over Web Service (T1567) — MITRE ATT&CK
- Beyond permission prompts: making Claude Code more secure and autonomous — Anthropic Engineering
- Securing an agent — kosa8 docs
Written by the kosa8 team. Every kosa8 command was checked against the CLI, and every claim about another product links to that product's own documentation. Spotted a mistake? Tell us.
Try it on your own machine
Give your next agent its own sealed machine.
One line installs kosa8 on your own machine. Start free with no card; plans from $29 a month.