AI Code Execution Sandbox Isolation for Untrusted LLM Output
Firecracker micro-VMs offer VM-level isolation for untrusted AI-generated code.

A security researcher demonstrated an attack against one vendor's computer-use agent feature in which a single poisoned web page caused the agent to download a binary, change its permissions, execute it, and connect to a command-and-control server. The chain worked on the first attempt, and it worked because the agent had the standing authority to do each of those things on request. That incident is a useful starting point because it shows the actual failure mode: not a bug in the model, but a system built to trust code it generated or encountered, the same way it might trust code a developer wrote by hand.
The shift that created this risk is simple to state. Agents used to generate text. An LLM acting as an authorized process carries whatever ambient authority that process holds, database credentials, network reach, filesystem access, and a prompt injection doesn't need to find a flaw in that authority to exploit it. It only needs to ask the process to use the authority it already has.
The attack surface extends into the tool ecosystem itself. Research has started to formalize this threat model directly. SANDBOXESCAPEBENCH, built by Marchand and colleagues, tests whether LLM agents can exploit seeded vulnerabilities and break out of containers nested inside virtual machines. The premise of that benchmark is itself the point: the attacker is no longer just the person who wrote the prompt. The attacker model now has to include the model.
The five-level isolation spectrum

Isolation is not a switch with an on and off position. It runs along a spectrum of five distinct mechanisms, and each one trades security strength against performance and software compatibility differently. Picking the right one depends entirely on how dangerous the code in question is expected to be, and once agents generate and run their own code, the answer tilts hard toward the stronger end of that spectrum.
At the bottom sits the container, the mechanism behind Docker and Podman. Containers suit code a team wrote and trusts. They do not suit code an LLM produced on the fly.
One step up is the user-space kernel, exemplified by gVisor. The tradeoff appears in compatibility: syscall emulation is never complete, and some Linux software hits gaps that break it.
The third level is the micro-VM, the category that includes Firecracker, Kata Containers, and libkrun. A kernel exploit inside one micro-VM has nowhere to go: it cannot reach the host, and it cannot reach any other VM on the same machine. This is the current gold standard for executing code that cannot be trusted, and it's the level the rest of this piece builds its argument around.
Beyond that sit two levels this piece touches only briefly, because they solve problems adjacent to the one agent code execution raises. Confidential computing, built on technologies like AMD SEV-SNP, Intel TDX, and ARM TrustZone paired with OP-TEE, encrypts memory at the hardware level so that even the host operating system and the hypervisor cannot read what's inside the sandbox. That guarantee matters enormously for regulated industries handling health records, financial data, or other personally identifiable information, but it answers a different question than the one agent sandboxing is trying to answer day to day.
The structural reason shared-kernel containers fall short for agent code execution
Containers don't fall short because teams configure them poorly or skip a hardening step. They fall short because of what a container is. A container escape is an exploit that crosses the boundary between a workload and the host's kernel, and because every container on that host shares the same kernel, one successful escape doesn't just compromise the container it started in. It compromises every tenant running on that machine. It is the architecture working exactly as designed, and the design was never built to hold against code actively trying to break out of it.
A comparative security study of AI code sandboxes (arXiv:2606.08433) lays out the engine-level properties that separate microVM, userspace-kernel, and OCI container approaches, looking at attack surface, leakage potential, how these layers stack together, CVE history, patch cadence, and how they hold up under fuzzing. The pattern that falls out of that analysis is straightforward: the shared kernel's attack surface grows with every additional container placed on the host. Each additional workload grows the exposure, regardless of how well each individual container is configured.
The usual mitigations help, but they don't change that underlying math. seccomp and eBPF logging only tell you what happened after the fact unless seccomp runs in KILL mode, actively terminating any process that attempts a forbidden syscall like opening a network connection. Kubernetes compounds this problem by defaulting to allow-all networking when no policy is defined, so unless a team explicitly sets a NetworkPolicy with egress: [], the default posture is wide open.
None of this means hardened container runtimes are worthless. But hygiene reduces the blast radius of an escape. It leaves in place the kernel attack surface that makes the escape possible. And agent code execution is the clearest case of this: an agent that installs packages and manipulates file descriptors, which is to say an agent doing anything actually useful, is exercising exactly the capabilities that make a shared kernel a liability.
How Firecracker micro-VMs close the gap containers leave open
Firecracker answers the structural problem containers can't solve by giving each workload its own kernel, enforced through hardware virtualization. A compromised guest kernel simply does not cross into the host kernel, an isolation guarantee a shared-kernel container, no matter how carefully configured, structurally cannot offer.
What makes Firecracker notable is that it provides VM-level isolation at a speed that approaches container performance. A Firecracker micro-VM boots with its own kernel in under 150 milliseconds and adds less than 5MB of memory overhead, numbers that put real distance between it and the assumption that strong isolation always means slow, heavy virtual machines. This is the isolation model so central to serious agent deployment that infrastructure platforms like Maritime build their entire scheduling architecture around it, pairing per-agent micro-VM isolation with snapshot-restore so agents stay available without paying for idle compute the whole time they sit unused.
Firecracker is not without friction. Docker arrives with mature, well-documented CNI plugins for networking, while Firecracker requires manual management of TAP interfaces, IP tables, and host routing, an operational burden real enough that it has driven demand for managed layers sitting above raw Firecracker deployments. That gap between raw primitive and usable platform is where managed sandbox services have found their footing.
The architecture has already proven itself at production scale. For environments where KVM hardware virtualization isn't available at all, Sandlock (arXiv:2605.26298) offers a fallback, confining agent code with unprivileged Linux primitives like Landlock and seccomp user notification rather than a hypervisor, a reasonable option when hardware isolation is off the table but a substitute for the real thing when the code a system is running might actually be hostile.
What a production-grade agent sandbox must enforce beyond isolation
Choosing micro-VM isolation settles where the kernel boundary sits, leaving the rest of the sandbox still to be addressed. A VM that isolates the kernel while leaving network egress open, credentials exposed, and syscalls unmonitored has relocated the problem rather than closed it, and a production agent sandbox needs several more layers built on top of that VM boundary.
Sandbox tutorials commonly recommend memory ceilings around 256MB for analysis scripts and 512MB for code generation tasks, tight enough to prevent an out-of-memory kill from dragging on past the window in which anyone is still watching.
And the evaluation environment itself needs scrutiny. SandboxEval (arXiv:2504.00018) frames this directly: the sandbox has to protect the host from the code running inside it, but the test environment also has to be trustworthy on its own terms, or the results coming out of it mean nothing regardless of how well the isolation held.
Snapshot-restore scheduling as the mechanism that makes per-agent VM isolation economically viable
The obvious objection to giving every agent its own VM is cost, and that objection holds only if the VM runs continuously. It dissolves once snapshot-restore scheduling enters the picture, because most agents spend most of their time idle, waiting on model inference rather than doing anything that needs compute, and a VM that's paused rather than running pays for storage instead of CPU and memory.
Perpetual scale-to-zero is the mechanism that makes this work. Rather than deleting a sandbox when it goes idle, the platform pauses it, preserving filesystem state, memory, and running processes so the agent's persistent disk, credentials, browser sessions, and in-progress context are all still there the moment it wakes back up. That's a meaningfully different guarantee than ephemeral scale-to-zero, which deletes the sandbox and the state along with it, forcing the agent to rebuild its context from nothing on every single invocation.
Recent research has closed much of the latency gap that once made this kind of pausing impractical. DeltaBox (arXiv:2605.22781) shows that checkpoint work can be hidden entirely under the time the agent already spends waiting on the language model to respond, with restore from a template completing in a fraction of a second once the agent needs to resume. By preallocating sandboxes speculatively, tailored to how LLM agent pipelines actually behave, SpecBox cuts tail latency and peak memory use substantially compared to either extreme. Crab (arXiv:2604.28138) approaches the same problem from another angle, watching the OS-visible effects of an agent's actions at the boundaries between conversational turns to decide how and when to checkpoint, again overlapping that work with the time the agent is already spending waiting on the model.
The research points to one conclusion: isolation and low cost aren't in tension once scheduling accounts for how agents actually spend their time. An agent running a Firecracker VM doesn't need that VM fully powered on between turns, and the gap between active computation and total wall-clock time is exactly where snapshot-restore scheduling recovers its savings.
Criteria for a managed micro-VM sandbox platform for agent workloads
Building and operating raw Firecracker infrastructure is a real undertaking, and most teams shouldn't do it themselves. For teams evaluating a managed platform instead, the criteria follow directly from the architecture this piece has laid out: isolation type, wake latency, state persistence model, idle cost structure, and compliance posture.
Isolation type comes first, and it isn't negotiable. A platform needs micro-VM or hardware-virtualized isolation per workload, because shared-kernel runtimes don't meet the bar this piece has already established, no matter what other features surround them.
Wake latency matters at the product level, not just the infrastructure level. Subsecond resume from a snapshot is close to a hard requirement for any agent product that needs to feel responsive, because a sandbox that takes several seconds to boot on every tool call makes the whole agent feel broken to the person using it.
Platforms differ in their state persistence model, often in ways you won't see in the marketing copy. Platforms that blur that line force developers to rebuild context from scratch on every invocation, defeating much of the point of running a persistent agent.
The economics work only when idle time bills as snapshot storage rather than compute, which is the entire mechanism the previous section described.
SOC 2 Type II, ISO 27001, and HIPAA coverage all matter when an agent sandbox is handling real user data, and that coverage should be a factor in the evaluation, not an afterthought.
Networking controls round out the list: custom domains, egress filtering, proxy-based secrets injection, and dedicated egress gateways are what complete a sandbox. Isolation without control over what the sandbox can reach on the network is an incomplete answer to the problem this piece opened with.
AWS Bedrock AgentCore, mentioned earlier for its production use of per-session Firecracker microVMs, is a credible managed option for teams already working inside the AWS ecosystem, billed per vCPU and per gigabyte on an hourly basis. Maritime's pricing follows from the same insight this piece has argued throughout, that idle agents should pay for storage rather than compute, landing around $1 per agent per month at scale.
Building agent products where isolation, persistence, and economics reinforce each other
The teams building agent products that last choose a single architecture in which hardware isolation, persistent state, and storage-priced idle time become one decision made once.
The per-user agent model, one VM per user, persistent across every session that user has, is becoming the right default primitive for this category of software.
Persistent state is the precondition for an agent capable of long-running, multi-session work. Files, credentials, browser state, and installed packages all need to survive the agent going to sleep and the platform redeploying underneath it, or the agent never becomes more than a function that forgets everything between calls.
That persistence also makes a pattern like interrupt-based human review possible: pausing an agent at a defined checkpoint and waiting for a person to approve an irreversible action, like sending an email, moving money, or deleting a record, before it continues. A sandbox that can't hold its position at that checkpoint can't support that pattern, because there's nothing to resume.
And the economics tie all of it together. Because snapshot-restore scheduling lets a platform pause a VM rather than delete it, deploying one VM per user doesn't require paying for one VM per user sitting idle around the clock. The result is an agent that can install packages, break things inside its own kernel, and rebuild without risking anything beyond its own boundary, something no shared-kernel environment can offer safely. It is the baseline architecture for any agent expected to do real work across real sessions, today, not at some future point when the tooling catches up.


