WebAssembly Sandboxes vs Micro-VMs for Agent Code Execution
Wasm isolates through runtime sandboxing; micro-VMs isolate through hardware virtualization.

A Docker container gets called isolated. A micro-VM gets called isolated. A WebAssembly module gets called isolated. The word has been stretched across three mechanisms that share almost nothing in how they actually work, and that stretching is doing real damage to how teams choose infrastructure for agent code execution. WebAssembly and Firecracker-style micro-VMs enforce fundamentally different isolation boundaries, one at the language runtime level and one at the hardware level, and that architectural difference decides which one can run a given workload, not a vendor's claim about how "secure" its sandbox is. Every isolation technique, regardless of marketing, is trying to answer the same question: how much of the host kernel's roughly 340 syscalls, backed by tens of millions of lines of C, does untrusted code get to touch? Get the answer wrong in either direction and the cost is concrete: a boundary that simply cannot run the workload, as with Wasm facing a native dependency it cannot compile against, or an entire operating system's worth of overhead spun up where a sandboxed function call would have done the job, paid repeatedly on every tool invocation at agent volume. The two approaches are not rivals on a single security scale. Wasm trades away broad capability for density and near-zero per-call cost, while a micro-VM trades some of that density and startup speed for the ability to run anything Linux can run, behind a wall enforced by the CPU itself.
Linear Memory, Capability Imports, and the Absence of Ambient Authority in WebAssembly's Boundary
WebAssembly enforces its boundary inside the language runtime itself, through bounds-checked linear memory and a capability model that denies everything by default. The only way out of the sandbox is through imported functions the host chose to expose, so a module might receive one pre-opened directory, one socket, or none. Wasmtime, the runtime most production deployments build on, layers further protection on top of this design: guard regions placed before linear memory, guard pages around native thread stacks, and memory zeroed out between instances.
The distinguishing feature of this model is the absence of ambient authority. Wasm starts code with none of that by default. The Component Model builds on this foundation by letting multiple Wasm modules compose through typed interfaces, where each component interacts with the others only through declared imports and exports, making fine-grained, least-privilege tooling a natural architecture.
None of this makes the boundary immune to every attack class. Because an attacker and its victim share a single address space inside a Wasm runtime, this in-process boundary carries more exposure to speculative side channels than a hardware-separated one. Software-enforced and hardware-enforced are different categories of guarantee, not points on the same scale, and that distinction carries directly into the next boundary.
Firecracker's Hardware Virtualization and Minimal Device Model
A Firecracker micro-VM isolates an entire guest operating system behind a boundary enforced by the CPU's own virtualization extensions, through KVM and hardware features like Intel VT-x/EPT or AMD-V/NPT. Because the guest runs a real kernel, it can run anything Linux can run, and the host kernel is reachable only through a minimal, auditable virtual machine monitor interface, not the broad syscall surface a container shares directly with its host. A default-on seccomp filter restricts the host syscalls Firecracker can make to a minimal set, and further building blocks, vCPU and memory configuration, rate limiters, cgroups, and namespaces, add defense in depth rather than asking any single layer to hold the whole boundary.
Firecracker's threat model treats every guest vCPU thread as hostile from the instant it starts and contains it with these stacked layers. A kernel escape inside the guest still has to break through both KVM and the jailer before it reaches the host. The authority model here looks different from Wasm's. The hardware boundary secures the perimeter between guest and host. It says nothing about what a hijacked process can reach once it is already inside that guest, unless the operator has gone further and restricted it. On speculative side channels, the VM boundary is generally considered stronger than an in-process one, because attacker and victim occupy separate address spaces. Stronger is not the same as immune: KVM has had real guest-to-host escape vulnerabilities disclosed as CVEs, and a hardware wall is a strong deterrent, not a guarantee. That ambient-authority gap inside the guest is where the next section's argument begins.
Wall Strength Versus Least Authority in the Agent Threat Model
A hardware wall and a capability model solve different problems, and most real attacks against agents exploit the gap a wall was never built to close. Firecracker's KVM boundary stops a compromised guest from escaping to the host kernel. Four attack patterns common to agent deployments make this concrete. Tool poisoning happens when a malicious MCP tool executes precisely as designed but carries hidden instructions, and without capability scoping it inherits the full filesystem, every environment variable, and whatever network access the host process already has. Prompt injection can turn into file exfiltration when an agent reading a document is instructed to open a private key and the execution environment happens to expose the host filesystem. Credential theft occurs when a compromised MCP server responds to tool discovery with a payload built to capture environment variables such as AWS_SECRET_ACCESS_KEY. Lateral movement follows when a compromised agent holds code execution and no network isolation, so it scans internal services and pivots using credentials the service mesh handed it by default.
All four trace back to the same underlying failure: an agent's legitimate authority gets misused by an instruction it should never have trusted. An LLM acting as a trusted deputy can be talked into using its own legitimate permissions to carry out a destructive command it was never meant to issue, and traditional role-based access control cannot catch this because it checks identity, not the provenance of an instruction. The root is ambient authority itself, the fact that an agent process inherits every permission sitting in its execution environment whether it needs them or not. Wasm's capability model answers this threat directly: a tool granted access only to api.github.com cannot exfiltrate a local file it was never given a path to, because no import exists through which it could even ask for one. A micro-VM's hardware wall answers a different threat: the one posed by kernel escapes, multi-tenant interference, and workloads where the code's behavior cannot be constrained at the language level. Handing a micro-VM's full internal authority to an unrestricted agent still lets that authority be misused by an untrusted instruction. It just relocates it one layer down.
What each boundary can and cannot execute: the workload compatibility split
The choice between these two boundaries often resolves on a single, binary question: does the code even run in the sandbox being considered? What Wasm cannot run is just as clear. And any code that needs an arbitrary Linux syscall surface, the kind of model-generated script that might shell out to a utility, spawn a background process, or lean on OS-level tooling, simply has nowhere to run.
A micro-VM's compatibility profile is the mirror image: if it runs on Linux, it runs inside a Firecracker guest. Wasm has no mechanism to contain that kind of workload. A micro-VM does. The compatibility between workload and boundary, more than any abstract security comparison, actually decides the architecture for most agent builders.
The overhead trade-off: per-call instantiation cost versus system startup cost

Most comparisons between these two approaches fixate on cold-start latency, the time it takes to bring a fresh environment online from nothing. For agent workloads running at volume, that is the wrong number to optimize. Per-call instantiation overhead, the tax you pay every time a tool gets invoked, is what actually drives both cost and responsiveness, and on that metric the two approaches differ by roughly three orders of magnitude. Wasm pays a one-time compilation cost on first load, typically tens of milliseconds, and every instantiation after that runs in well under a millisecond. There is no guest kernel to boot and no process to spawn; the sandbox behaves like a library the host application instantiates in its own process space, and the memory overhead per instance stays minimal because there is no guest OS userland sitting underneath it.
A micro-VM's cost structure runs on an entirely different scale, closer to system startup than to a function call. That gap matters more at agent volume than it would for a conventional web workload, because tool-augmented agents spend a large share of their execution time waiting rather than computing, idle between steps while a model generates its next action. Overhead paid on each tool invocation compounds across every step of every session, and a few hundred milliseconds that seems trivial once becomes expensive run thousands of times across a fleet of agents. That overhead is not a fixed cost, though. The result cuts P99 end-to-end latency by a substantial margin against an on-demand baseline, and it also cuts peak memory consumption substantially. The gap between Wasm's near-zero overhead and a micro-VM's heavier footprint reflects an active target for infrastructure engineering rather than a permanent tax on choosing hardware isolation.
Snapshot-restore scheduling and idle-cost economics for persistent agents
Per-call overhead is not what dominates the cost of a long-running agent. Idle compute is, because an agent that sits resident between user requests burns capacity whether or not it is doing anything useful. Three scheduling approaches handle this differently. A cold boot is correct but measured in seconds, which is too slow for a responsive agent product. A warm pool stays fast because it keeps capacity running continuously, so you pay for idle machines even when most agents spend most of their time doing nothing. Snapshot-restore scheduling avoids both problems: a hibernated agent session gets snapshotted and paused so it costs almost nothing while idle, then wakes on the next request with its full state intact.
What survives that snapshot-restore cycle is substantial: the working directory, every installed dependency, running processes, open file handles, in-memory state, all preserved exactly as they were. That persistence is what makes a micro-VM the right substrate for agents that need to install packages, keep a browser session authenticated, or pick back up on work they were doing days earlier, none of which fits inside Wasm's stateless instantiation model. It also makes branching architectures physically practical: a same-host fork completes in roughly 400 to 750 milliseconds, combining a local reflink with a memory restore, while a cross-host fork takes roughly 1.2 to 3.5 seconds. Each branch is a genuinely separate machine that diverged from shared warm state, and a dead-end branch costs nothing more than a kill() call to discard. Maritime's scheduling approach is built directly on this insight: agents sleep between sessions and restore in under a second, with persistent disk, a real kernel, and installed packages intact, so the per-user agent model charges for storage rather than idle compute and stays economically workable even when utilization is low.
AWS Bedrock AgentCore and Vercel Sandbox as market signals
The infrastructure decisions major providers made through 2026 track the mechanism argument closely. When the workload is arbitrary, agent-generated code that needs session state and full system access, the industry has converged on Firecracker micro-VMs. AWS announced Lambda MicroVMs on June 22, 2026, a new Lambda resource offering dedicated Firecracker-based execution environments capable of running user-supplied or AI-generated code with VM-level isolation, preserved in-session state, dedicated HTTPS endpoints, and direct lifecycle control. AgentCore's broader platform bundles eight composable services, Runtime, Gateway, Memory, Policy, Identity, Browser, Code Interpreter, and Observability, with 8-hour execution windows and full session isolation, placing each user session in its own sandboxed micro-VM. A newer tier, Runtime Instances, launched in August 2026, offers persistent EC2-backed infrastructure where multiple agents share a host and collaborate across sessions lasting up to 14 days, aimed at workloads needing long-running state, multi-agent coordination, or heavier compute than the micro-VM tier is meant for. AgentCore's pricing, confirmed from AWS's pricing page on September 29, 2026, bills Runtime microVMs V1 at $0.0895 per vCPU-hour and $0.00945 per GB-hour, with V2 at $0.1276 per vCPU-hour and $0.0169 per GB-hour; Runtime Instances bill at the underlying EC2 instance cost plus a 12 percent management fee, reduced to 7.8 percent for G-series GPU instances. An AgentCore CLI brings the full lifecycle, scaffolding, configuration, deployment, iteration, management, into the terminal, and the same functionality is exposed through an open-source AgentCore MCP Server that routes through direct boto3 API calls rather than wrapping the CLI, letting coding assistants including Claude Code, Kiro, Cursor, VS Code, and Codex CLI run those workflows from a natural-language prompt.
Applying the decision: a workload-first rule for choosing the right isolation boundary
The choice between Wasm and a micro-VM comes down to one honest question about what the agent's code actually needs to do, and answering it correctly rules out the wrong option before any other factor gets a vote. If the language and the full dependency graph are under the developer's control, and a complete capability set can be declared in advance, Wasm is the right fit: sub-millisecond per-call instantiation, deny-by-default authority, no guest OS overhead, and composition through the Component Model for fine-grained tooling. If the code is model-generated, or needs native dependencies, subprocesses, an arbitrary Linux syscall surface, browser sessions, package installation, or GPU access, only a micro-VM can contain it.
These two approaches are not mutually exclusive, and the strongest agent architectures tend to use both at once. A micro-VM per agent session supplies the hardware boundary and full system access the session needs, while Wasm components run inside that same session and enforce least-authority capability scoping on the individual tool calls whose code you know and control. Matching the boundary to what the code must do determines the rest of the decision.


