gVisor vs Firecracker: which isolation fits untrusted agent code

gVisor puts a second kernel in user space; Firecracker gives the code a kernel of its own on KVM. What each costs, and how to choose for agents.

Hidde KehrerHidde Kehrer15 min readDeep dive
A workshop split in two: on the left a small round creature works a counter hatch, answering slips pushed through by a sparking wind-up contraption; on the right an identical contraption is bolted inside its own small machine while a creature walks away with a mug.
On this page · 15 min

Why a container doesn't hold agent code

A container doesn't hold agent code because it shares its kernel with the host. Take an agent that is fixing a failing test. It reads an issue comment that says the fix needs a helper package, installs the package and runs the tests. The package's install script now runs as the agent's process. You never read that script, and neither did the model. It can do two kinds of damage: use what the process can already reach, which a later section covers, or try to break out to the host.

If that process sits in a Docker container, the only thing between the script and your host is the Linux kernel. A container is an ordinary process that the kernel shows a private view of files, processes and the network. Docker is not a hypervisor: it asks the kernel to set up that view and then steps aside. Every system call the script makes, such as "open this file" or "send this packet", goes straight to the same kernel that runs the host and every other container on it.

That leaves two ways out, and they are different bugs. One is a bug in the container runtime, the program that sets the container up. In 2024, runc, the runtime Docker uses by default, leaked an internal file descriptor (an open handle to a file or directory) into new containers, which gave code inside access to the host filesystem. The runc advisory lists the fix in version 1.1.12. The other is a bug in the kernel itself. Because the kernel is shared, a flaw in any system call is reachable from inside any container.

Whether this matters depends on two separate questions: whose code runs, and whose machine it runs on. If the code is yours and the hosts are yours, a container is fine. This article is about the other case, where a model or a user wrote the code and the host also serves other users or holds your keys. gVisor and Firecracker both put something between that code and the host kernel: gVisor a second kernel, Firecracker a virtual machine.

What gVisor does: a kernel in user space

gVisor answers the container's system calls itself instead of handing them to the host kernel. Its main part is the Sentry, a kernel written in Go that runs in user space, which means it runs as a normal program and not as part of the operating system. The Sentry implements the Linux interface: processes, memory, files and its own network stack. When the code in the container makes a system call, gVisor intercepts it and the Sentry does the work. In the words of the gVisor docs, "gVisor never passes through any system call to the host."

The Sentry is itself boxed in, because it is the thing the untrusted code talks to. It runs under a seccomp filter, a kernel feature that limits which system calls a process may make, and it may make only a limited set of calls to the host. It starts without access to the host's filesystem. A second process, the Gofer, provides the files the container is allowed to see.

So gVisor is not a VM. It boots no guest kernel and emulates no hardware, and a sandbox is a few processes on the host. The path from the code to the host kernel gets longer, though. Code that wants out has to find a bug in the Sentry first and then a bug in the host kernel, through the few calls the Sentry is allowed. gVisor's docs point out that the two kernels share no code, so one bug rarely works on both.

gVisor plugs in as a container runtime called runsc, so Docker and Kubernetes use it the way they use runc. After sudo runsc install and a Docker restart, you pick it per container:

Terminal
docker run --runtime=runsc --rm hello-world
docker run --runtime=runsc -it ubuntu dmesg

The first command runs a normal image inside gVisor. The second prints the kernel log as the container sees it, which starts with "Starting gVisor..." and not with your host's boot messages.

gVisor's practical strength is that it runs anywhere a container runs. Its default way of intercepting system calls, called systrap, needs no virtualization support, so it works inside an ordinary cloud VM too. Google uses it in Cloud Run, App Engine and GKE Sandbox.

What gVisor gives up

gVisor gives up some Linux compatibility and some speed. The Sentry is a second implementation of Linux, and it is not complete. When we read it in November 2026, gVisor's system call table for 64-bit x86 listed 385 system calls, of which 295 were fully or partly implemented and 90 were not. A program may never touch a missing call, and it may trip on one that is only partly there. Some features are off by default, io_uring among them. The docs say what that means in practice: "The only real way to know if it will work is to try."

That advice works when you choose the workload, but an agent chooses its own. It installs whatever build tool, database or browser the task calls for, and when one of them hits a missing system call, the agent sees an odd error and may spend its turns debugging code that was never broken.

The speed cost falls on system calls, because each one takes a longer path through the Sentry. gVisor's production guide names file I/O as the most affected area and networking as the second. Plain computation pays nothing, since the code runs directly on the CPU. So a numeric job runs at full speed, while a dependency install that writes thousands of small files is slower. How much slower depends on the workload, and gVisor's published benchmarks were run on a platform it has since retired, so time your own install before you rely on a figure.

Google built gVisor, and its own products offer a virtual machine where compatibility comes first. The first generation of Cloud Run is based on gVisor and emulates "most, but not all operating system calls". The second generation, per the Cloud Run docs, "is a microVM and provides full Linux compatibility".

What Firecracker does: a small VM on KVM

Firecracker gives each workload a virtual machine with its own Linux kernel. It builds on KVM, the part of the Linux kernel that uses the CPU's virtualization features to run a guest operating system directly on the processor, walled off in its own memory. KVM only handles the CPU and memory. The program that creates the VM, loads its kernel and plays the part of its disk and network card is called a virtual machine monitor, or VMM. Firecracker is a VMM, written in Rust, and it was built at Amazon Web Services for Lambda and Fargate. So Firecracker is the program that runs a VM, not a VM itself, and there is one Firecracker process per microVM.

The "micro" is about how little hardware the guest sees. A general-purpose VMM emulates a long list of devices, and every emulated device is code the guest can attack. Firecracker's FAQ lists six, among them a network card, a disk and a serial console. The Firecracker process is confined too: a helper called the jailer isolates it the way a container is isolated and drops its privileges, and seccomp filters limit its system calls.

In a microVM, the untrusted code's system calls go to the guest kernel, and that kernel belongs to this one workload. A kernel bug there gives an attacker the guest, which they could already run anything in. To reach the host they have to break KVM or one of those few devices, and then get out of the jail around the Firecracker process. And because the guest is real Linux, whatever its kernel supports works, including io_uring and Docker inside the VM.

Both designs make an attacker chain more than one bug, so the count doesn't settle which is stronger. The size of the first target does. In gVisor that target is the Sentry, which has to reimplement most of Linux's interface in software. In a microVM it is KVM and a handful of devices, with the CPU's own virtualization hardware enforcing the wall. That smaller first target is why we rank a VM as the stronger boundary.

A small device model also makes the VM light. Firecracker's specification promises at most 125 ms from the start call to the guest's first user-space process, measured with a minimal kernel and root filesystem, and at most 5 MiB of memory overhead for the VMM of a guest with 1 CPU and 128 MiB of RAM. Those figures describe a VM booting on its own host. A hosted service's create time, measured from your client, also includes its API and the network, so don't set a provider's create time next to them.

Firecracker is one VMM on KVM among several. GKE Sandbox, which offers a microVM option beside gVisor, builds those microVMs with Kata Containers and Cloud Hypervisor. The boundary is the same in each case: a guest kernel behind hardware virtualization.

What a microVM asks of you

A microVM asks for KVM first, and many hosts don't have it. (If you rent your sandboxes, the provider carries the costs in this section.) Firecracker needs read and write access to /dev/kvm, which exists on bare-metal servers and on cloud VMs with nested virtualization, where a VM is allowed to run VMs of its own. AWS supports it on a list of instance families and you turn it on per instance. Google Cloud excludes some machine types and warns that CPU-bound work in a nested VM may run 10% or more slower. Firecracker's own guide gives the check to run on a host:

Terminal
[ -r /dev/kvm ] && [ -w /dev/kvm ] && echo "OK" || echo "FAIL"

It prints OK if your user can use KVM. FAIL means KVM is missing on this host or your user has no access to it, and missing is the answer on many cloud VMs. That gap is one reason gVisor exists.

The second cost is the machine image. gVisor runs the container image you already have. Firecracker boots a Linux kernel binary and a root filesystem image that you supply, and you also wire up each VM's network on the host.

The third is GPUs. gVisor supports NVIDIA GPUs for most CUDA applications, with a caveat from its own docs: it is "much less effective" at containing bugs in the NVIDIA driver, which still runs on the host. Firecracker doesn't pass devices through to the guest yet. Its tracking issue for that is open, and a maintainer described it as in active development in November 2026. If the untrusted code needs a GPU today, that points to gVisor or to a different VMM.

gVisor vs Firecracker side by side

gVisor is the lighter boundary that runs anywhere, and a Firecracker microVM is the stronger one that needs KVM.

Plain containergVisorFirecracker microVM
Who answers the code's system callsThe host kernelThe Sentry, a kernel in user spaceA guest kernel of its own
What an escape takesOne runtime or kernel bugA Sentry bug, then a host kernel bugA bug in KVM or a device, then a way out of the jailed VMM
Linux compatibilityFullPartial: test your workloadFull: the guest is Linux
Where it runsAnywhereAnywhere containers runHosts with KVM
Where it is slowerNowhereSystem calls, file I/O, networkingBoots a kernel before the code starts
NVIDIA GPUsYesYes, for most CUDA applicationsNot yet
What you run yourselfA container runtimeThe runsc runtimeKVM hosts, kernel and disk images, VM networking

If you rent the sandbox instead of running it, you are still in one of these columns, and the vendor's page should say which. boxd machines are KVM microVMs, each with its own kernel, on our own VMM. E2B runs each sandbox in a Firecracker microVM. Modal runs sandboxes on gVisor or in a VM, and picks the runtime if you leave it unset.

The boundary is half of an agent sandbox

gVisor and Firecracker protect the host from the code. Neither one decides what the code can reach from inside the sandbox. The install script from the first section has no need to escape. If the agent's API key is in an environment variable and the network is open, the script reads the key and posts it to a server of its choosing.

So a sandbox for agent code needs more than a boundary, whichever one you chose:

  • Egress limits. A list of hosts the sandbox may reach, enforced outside it. gVisor can switch a sandbox's network off entirely and otherwise leaves filtering to you; Firecracker hands the VM a network device and leaves the rest to the host. A list limits where data can go. It doesn't stop data leaving to an allowed host that accepts writes, such as a Git host.
  • Secrets that stay out. The code should be able to use a key without holding it. You can keep the key in the service that calls the sandbox, hand the sandbox short-lived tokens with a narrow scope, or put a proxy outside the sandbox that adds the real value to requests for the hosts you named.
  • State. An agent's task can run for hours, and its files and running processes are its context. Both tools can save and restore a sandbox, but storing and resuming those saves safely is your work.

How much of this you need depends on a choice agent builders often make without noticing: whether to sandbox only the code the agent runs, or the whole agent. If only a code-execution tool runs in the sandbox, the loop and the keys stay in your service, the sandbox is short-lived and holds nothing worth stealing, and gVisor's limits matter less. If the whole agent lives in the sandbox with its tools and credentials, it needs a full Linux for hours and tight control of the network, which is where a VM with a hardware boundary fits better.

How to choose between gVisor and Firecracker

Choose by answering the two questions from the start, whose code and whose machine, and then by what your hosts can run.

  • Your code, your hosts: a plain container. It keeps workloads apart, and nothing inside is trying to get out.
  • Untrusted code, and no KVM or a need for GPUs: gVisor. Run the real workload on it before you commit, because the missing system calls show up only in practice, and expect file-heavy work to be slower.
  • Untrusted code that needs a full Linux, and you have KVM hosts and people to run them: Firecracker or another VMM on KVM. You get the stronger boundary and take on images, networking and host operations.
  • Either need without the hosts: a hosted sandbox on the boundary the rules above point to. Check how long a sandbox may live before you build a long task on it.

For a hosted microVM you can use boxd or E2B. Ask any provider about the kernel boundary, the network limits and where secrets live. These are our answers. boxd runs every machine as a KVM microVM with its own kernel, so agent code never makes a system call to a kernel that another tenant shares. Each machine has an egress allowlist enforced outside it, and a change applies within a second without a restart, so you can open a host for one step of a task and close it again. With host-bound secrets the machine holds only a placeholder, and the real value is swapped in on HTTPS requests to the hosts you named. Code in the machine can still use the key on those hosts, but it can't read it or take it elsewhere.

To try the boundary on one machine, install the CLI:

Terminal
curl -fsSL https://boxd.sh/downloads/install.sh | sh

Then create a sandboxed machine and limit where it can connect:

Terminal
boxd machine new agent-task --isolated
boxd machine egress agent-task pypi.org,files.pythonhosted.org

The first command creates a machine that never joins your default network and carries none of your logins or credentials. The second replaces its allowlist, so the machine reaches the Python package index and nothing else. A bad package can still be installed, but its install script can only talk to the package index. That list suits a machine that only runs the agent's code. A machine that runs the whole agent needs more hosts on it, and each one you add is another place data can go. Both commands are in the command reference, and the agent sandbox page has more on locking a machine down.

Frequently asked

What is the difference between gVisor and Firecracker?
gVisor is a kernel written in Go that runs in user space and answers a container's system calls itself, so the code never calls the host kernel directly. Firecracker is a virtual machine monitor that runs small virtual machines on KVM, each with its own Linux kernel. gVisor runs anywhere containers run but implements only part of Linux. A Firecracker microVM runs full Linux but needs a host with KVM.
Is gVisor a VM?
No. gVisor boots no guest kernel and emulates no hardware. A gVisor sandbox is a few processes on the host: the Sentry, which implements the Linux system call interface in user space, and the Gofer, which handles file access for it.
Is Firecracker a VM?
Firecracker is the program that runs a VM, called a virtual machine monitor. It uses KVM in the Linux kernel to create microVMs, with one Firecracker process per microVM. Each microVM is a real virtual machine with its own kernel.
How safe is gVisor?
Safer than a plain container, because code in the sandbox talks to gVisor's own kernel and not to the host kernel. To escape, an attacker needs a bug in gVisor and then a bug in the host kernel. gVisor's documentation says it does not protect against hardware side channels, and a sandbox still needs network and secret controls around it.
Is Docker a hypervisor?
No. Docker asks the Linux kernel to give a process a private view of files, processes and the network. The container still shares the host's kernel. A hypervisor such as KVM runs a separate guest kernel for each virtual machine.
Hidde KehrerHidde Kehrer
PostShare
Published
Nov 30, 2026
Reading time
15 min
Words
3,003
Topic
Deep dive

Read next

Field notes

Subscribe for release notes and architecture write-ups

No spam, ever. Unsubscribe anytime.

Your inbox