# Inside Firecracker's defense in depth: KVM, the device model, seccomp and the jailer

> A plain walk through the layers Firecracker uses to contain a guest, from the KVM boundary to per-thread seccomp filters and the jailer, based on Firecracker's own design documents.

A plain walk through the layers Firecracker uses to contain a guest, from the KVM boundary to per-thread seccomp filters and the jailer, based on Firecracker's own design documents.

November 23, 2026 · · The Sandscale team

“It runs in a Firecracker microVM” is a sentence you see a lot in the agent sandbox space, including from us. It is worth knowing what that sentence actually buys you, layer by layer, because the answer is more interesting than “it’s a VM”.

Everything below comes from Firecracker’s public documentation, mainly its [design document](https://github.com/firecracker-microvm/firecracker/blob/main/docs/design.md), the [jailer guide](https://github.com/firecracker-microvm/firecracker/blob/main/docs/jailer.md) and the [seccomp notes](https://github.com/firecracker-microvm/firecracker/blob/main/docs/seccomp.md). We link the source for each claim so you can check it.

## The starting assumption: the guest is hostile

Firecracker’s design document is blunt about its threat model. Under “Threat Containment”, it says all vCPU threads are considered to be running malicious code as soon as they have been started. Containment is achieved by nesting trust zones, from the least trusted (guest vCPU threads) to the most trusted (the host), separated by barriers.

That framing is a good fit for AI agent code. You start the sandbox expecting the code inside to be hostile, not hoping it is friendly.

## Layer 1: the KVM virtualization boundary

The design document names the first layer of isolation: Linux KVM and the Firecracker virtualization boundary. The guest runs its own kernel on virtual CPUs created through KVM. Code in the guest makes system calls to the guest kernel, not to the host’s.

Compare this with a container, where every system call from the workload goes straight to the host kernel. The host kernel’s whole system call interface is the attack surface. In a microVM, a guest that wants to attack the host first has to find a way out through the much narrower interface between the virtual machine and its monitor.

## Layer 2: a deliberately small device model

What the guest can talk to on the host side is the virtual hardware Firecracker emulates. The design document lists it: VirtIO network and block devices, a vsock device, a serial console, and a partial keyboard controller whose purpose in Firecracker is to let the guest signal a reboot. Beyond that, guests see the interrupt controllers and timer that KVM itself supports.

That short list is the point. Every emulated device is code in the host process that parses input from the guest. Fewer devices means less code an attacker can feed malformed input to. There is no emulated USB, no GPU, no sound card, no BIOS full of legacy hardware.

Each Firecracker process also runs exactly one microVM, so a bug that crashes or corrupts one monitor process affects one guest.

One thing the device model does not do is decide where network traffic may go. The design document says Firecracker does not perform any network traffic filtering, and that all egress traffic from a guest should be considered untrusted and filtered at the host level. Network policy is a separate layer that whoever runs Firecracker has to build.

## Layer 3: seccomp filters on the monitor itself

Suppose an attacker does find a bug in a device emulator and gets code running inside the Firecracker process on the host. What can that process do?

Firecracker limits it with seccomp. Per its documentation, seccomp filters are installed by default and allow only the bare minimum set of system calls and arguments that Firecracker needs to function. The filters are loaded per thread: for the VMM thread right before guest code runs on the vCPU threads, for the API thread right before its HTTP server starts, and for each vCPU thread right before it executes guest code.

The documentation includes two warnings worth repeating if you run Firecracker yourself. Debug builds and experimental targets ship without the default filters. And a `--no-seccomp` flag exists for prototyping, with an explicit instruction not to use it in production.

## Layer 4: the jailer

Seccomp limits which system calls the process can make. The jailer limits what those system calls can reach.

The design document says that in production, Firecracker should be started only through the `jailer` binary. The jailer guide describes what it does before handing control to Firecracker. In order, roughly:

1. Closes every inherited file descriptor except standard input, output and error, and clears the environment variables it received.
2. Creates a dedicated chroot directory for this microVM and copies the Firecracker binary into it, so the process does not share memory with any other Firecracker process.
3. Applies resource limits (for example file size and number of open files) with `setrlimit`.
4. Sets up cgroups for the process.
5. Enters a new mount namespace, uses `pivot_root` to make the chroot directory the new root, and chroots into it.
6. Creates only the device nodes Firecracker needs inside the jail, such as `/dev/kvm` and `/dev/net/tun`, and hands their ownership to an unprivileged user and group.
7. Optionally joins a given network namespace and starts the binary in a new PID namespace.
8. Drops privileges to that unprivileged user and group, and execs Firecracker.

After that, as the design document puts it, Firecracker can only access resources that a privileged third party grants it, for example by copying a file into the chroot or passing a file descriptor.

So an attacker who escaped the guest and compromised the monitor lands in a process running as an unprivileged user, in an almost empty filesystem, in its own namespaces, with a short list of permitted system calls.

## Layer 5: cgroups and quotas

The last layer is about fairness rather than escape. Each microVM can be placed in its own cgroup, pinned to CPUs and given a CPU quota, and Firecracker applies rate limiters to each disk and network interface using token buckets. One guest busy-looping or flooding its disk should not starve the guest next to it. For agent workloads, where runaway loops are common and usually not malicious, this matters day to day.

## What none of this covers

Defense in depth is not invulnerability. Some things stay outside these layers:

- **The host kernel and KVM.** Bugs there are outside Firecracker’s control and need patching like any kernel.
- **Firecracker’s own bugs.** It has had them; [CVE-2019-18960](https://nvd.nist.gov/vuln/detail/CVE-2019-18960) was a buffer overflow in its vsock implementation in versions 0.18.0 and 0.19.0. Layers 3 and 4 exist precisely so that a bug like that is not the end of the story.
- **What the guest can reach over the network.** That is the operator’s job, as the design document says.
- **What you put inside the guest.** A secret you hand to the guest is available to code in the guest. Isolation keeps it from the next run, not from this one.
- **Side channels.** Firecracker publishes a [production host setup guide](https://github.com/firecracker-microvm/firecracker/blob/main/docs/prod-host-setup.md) with host-level recommendations for running untrusted guests, including mitigations for hardware side channels. Running Firecracker safely is more than running the binary.

## Where Sandscale fits

Sandscale gives each agent run its own Firecracker microVM with its own kernel, and controls the network with an egress allowlist at a separate layer, which is what Firecracker’s design asks of anyone running it. For how this compares with containers and gVisor on cost and startup, see our [isolation comparison](https://sandscale.dev/blog/isolating-ai-agent-code-containers-gvisor-firecracker). For what happens to the secrets you do pass in, see [keeping secrets out of agent prompts](https://sandscale.dev/blog/secrets-out-of-agent-prompts-vault-dlp).

---
Source: https://sandscale.dev/blog/firecracker-jailer-and-seccomp-explained
