Blog / 26 November 2026
Deep dive · 26 November 2026 · 8 min read
Container vs microVM vs Zero Trust sandbox for AI agents
A container, a microVM and a Zero Trust sandbox are three different answers to "where should my AI agent's code run?". A container shares the host's kernel. A microVM gives the agent its own kernel behind a hypervisor. A Zero Trust sandbox is a microVM plus the controls that decide what the agent may do with its network, keys and tools, all enforced outside it. Here is how they compare, and how to choose.
01Three terms, defined
These words get used loosely, so here is what we mean by each.
- Container. A process, or group of processes, that the host kernel fences off with namespaces, control groups and syscall filters. Docker and Kubernetes pods are the usual examples. Every container on a host shares one kernel.
- MicroVM. A small virtual machine with its own guest kernel, run by a lean virtual machine monitor such as Firecracker or Cloud Hypervisor on hardware virtualization. The shared layer is the hypervisor, not the kernel. More in What is a microVM?.
- Zero Trust sandbox. A microVM, or another strong boundary, combined with controls that live outside it: a closed network with an allow-list, credentials kept on the host, approvals for risky actions, a tamper-evident log and a short lifecycle. It assumes the agent is compromised. The full design is in Zero Trust sandboxes for AI agents.
02The comparison table
The first four rows are about the wall. The rest are about what a hijacked agent can do without crossing it. Most agent incidents happen in those rows.
| Container | MicroVM | Zero Trust sandbox | |
|---|---|---|---|
| Kernel | Shared with the host | Its own guest kernel | Its own guest kernel |
| Main shared attack surface | Host kernel and container runtime | Hypervisor and virtual devices | Hypervisor and virtual devices |
| Root inside means | One bug from the host kernel | Root in the guest only | Root in the guest only; host rules still apply |
| Start-up | Fastest | Fast; a fraction of a second is typical | Same as the microVM underneath |
| Network rules | Optional; often inside the same kernel | Optional; you build them | Closed by default, enforced on the host, DNS for listed names |
| API keys | Usually environment variables the agent can read | Same, unless you add a broker | Placeholder inside; broker adds the real key outside |
| Risky actions | Whatever the agent decides | Whatever the agent decides | Held for a named person, once |
| Record of actions | Container logs, written from inside | Whatever you add | Hash-chained log written on the host |
| Undo | Rebuild from the image | Snapshot, if your VMM supports it | Checkpoint and rewind the whole machine |
| Good fit | Your own trusted code and tests | Untrusted code where you control egress yourself | Autonomous agents with real keys, tools and data |
03What containers get right, and where they stop
Containers are fast, cheap and supported by every tool. For code you wrote and trust, they are the right choice. They can also be hardened a long way. Docker documents rootless mode, user namespace remapping and seccomp profiles. Kubernetes lets you pick a stronger runtime per pod with RuntimeClass, for example gVisor or Kata Containers.
The limit is the shared kernel. Every hardening step shrinks what a process inside can ask the kernel to do, but the kernel and the runtime are still shared. When one of them has a bug, the wall has a hole. CVE-2024-21626, a file descriptor leak in runc, let a container process reach the host filesystem. An AI agent is the worst neighbour for a shared kernel: it writes and runs new code all day, on instructions from text it read. We go into the details in Docker vs microVM for AI agents.
04What a microVM adds, and what it does not
A microVM moves the boundary from the kernel to the hypervisor. The agent can be root in its own kernel and still be inside a virtual machine. Firecracker was designed to run code from many tenants side by side on one host; its NSDI 2020 paper describes the trade-offs. For the differences between Firecracker, gVisor and Kata, see our comparison.
But a microVM is only a better wall. Out of the box it says nothing about what leaves the VM over the network, which secrets are inside it, or which actions need a person. If you pass the agent an API key as an environment variable, the key is just as readable in a microVM as in a container. If the VM can reach the internet, a prompt-injected agent can send your code anywhere. That is Simon Willison's lethal trifecta, and no hypervisor fixes it.
05What makes a sandbox Zero Trust
NIST SP 800-207 says no subject is trusted because of where it sits, and every request is decided by policy before access. Applied to an agent, the sandbox must make its decisions outside the agent's machine, where root in the guest cannot reach them. In practice that means five controls on top of the microVM:
- Egress closed by default, with DNS answered on the host for listed names only. See How AI agent egress control really works.
- Credentials brokered, so the sandbox holds a placeholder and never the real key. See Prompt injection, API keys and the egress broker.
- Approvals for destructive and access-widening actions, by a named person, once.
- A tamper-evident log of every decision, allowed or refused, written on the host.
- A short lifecycle: a fresh machine per task, a time limit, and checkpoints before risky steps.
06How to choose
Choose by what the code can reach, not by how much you trust the model. Three questions settle most cases.
- Is the code yours, reviewed, and without secrets or network access to sensitive hosts? A hardened container is fine.
- Is the code untrusted, but the job has no keys and no network? A microVM with networking off is a strong answer. Many code-execution and evaluation workloads look like this.
- Does an agent run on its own, with real keys, tools, repositories or customer data? You need the full Zero Trust sandbox. The wall alone will not stop the agent misusing what you gave it.
Whatever you pick, write down where the boundary is and what runs on each side of it. A control that runs inside the agent's machine is a control the agent can turn off.
07Where kosa8 sits
kosa8 is Zero Trust cybersecurity infrastructure for AI agents, so it sits in the third column. kosa8 sandbox and kosa8 agent run give each workload its own microVM with its own Linux kernel: Apple's Virtualization framework on Apple-silicon Macs, Cloud Hypervisor on KVM on Linux. Network rules, the egress broker, approvals and the hash-chained audit log run on the host. kosa8 sandbox create agent --egress deny boots a sandbox with no network at all; --egress-allow names the hosts it may reach.
Two honest exceptions. The Docker-compatible kosa8 run shares one VM between containers unless a signed policy sets require_sandbox, so it sits between the first and second columns. And on kosa8 Cloud, short-lived plain sandboxes can overflow to Cloudflare Containers, which are not kosa8 microVMs, unless you name a region. A sandbox you create by hand is also open to the network until you, or your organization, set egress rules.
Takeaways
- A container shares the host kernel; a microVM has its own; a Zero Trust sandbox adds host-side controls.
- Hardened containers suit trusted code. Untrusted agent code needs a stronger wall.
- A microVM alone does not keep keys out, close the network or hold risky actions for a person.
- Choose by what the code can reach: keys, tools, repositories and data.
- Any control that runs inside the agent's machine can be turned off by the agent.
Where kosa8 fits · Zero Trust cybersecurity infrastructure for AI agents
kosa8 gives each agent its own microVM with network rules, a secret broker, approvals and a hash-chained audit log on the host, out of the agent's reach. It runs on Apple-silicon Macs and x86-64 Linux, on your own servers 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
You move an agent from a Docker container to a microVM but still pass its API key as an environment variable. What changed?
The microVM gives the agent its own kernel, so a kernel or runtime bug no longer reaches the host directly. But anything inside the VM can still read the key and send it to any host the VM can reach. Keeping the key out takes a broker on the host.
Questions people ask
Is a microVM more secure than a container for AI agents?
For untrusted code, yes: a microVM has its own kernel, so the shared layer is the hypervisor, not the host kernel. But it only improves the wall. It does not close the network, keep keys out or hold risky actions for a person.
What is a Zero Trust sandbox?
A strong boundary such as a microVM, plus controls enforced outside it: a closed network with an allow-list, credentials brokered on the host, approvals for risky actions, a tamper-evident log and a short lifecycle. It assumes the agent may already be hijacked.
Can I make Docker safe enough for AI agents?
You can harden it a lot with rootless mode, user namespaces, seccomp and a stronger runtime such as gVisor or Kata. That helps the wall. You still need network rules, brokered keys, approvals and an outside log for an agent that holds real access.
Is gVisor a container or a microVM?
Neither exactly. gVisor runs a kernel in user space that answers the container's system calls, so the host kernel sees far fewer of them. It is stronger than a plain container and a different kind of boundary from a virtual machine.
Sources
- Rootless mode — Docker docs
- Isolate containers with a user namespace — Docker docs
- Seccomp security profiles for Docker — Docker docs
- Runtime Class — Kubernetes docs
- CVE-2024-21626 (runc) — NIST National Vulnerability Database
- Firecracker: Lightweight Virtualization for Serverless Applications (NSDI 2020) — USENIX
- The lethal trifecta for AI agents — Simon Willison
- SP 800-207, Zero Trust Architecture — NIST
- What is gVisor? — gVisor 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.