Back to blog posts

10 min

The complete guide to Firecracker: AWS's microVM technology

Learn what Firecracker is, how its microVMs isolate untrusted AI agent code with KVM, the jailer, and snapshots.

Nicolas LecomteNico is a founder of Blaxel, who usually writes about AI, agentics, and the future of AI runtimes.

Running untrusted, LLM-generated code safely on shared infrastructure is one of the biggest challenges in modern AI application design. Firecracker microVMs run on the Linux Kernel-based Virtual Machine (KVM). Each microVM boots its own guest kernel behind a hardware virtualization boundary.

AWS built Firecracker so AWS Lambda and AWS Fargate could pack customers onto shared hosts. AI agents raise the same multi-tenant isolation problem. An agent writes unreviewed code, then runs it on your infrastructure.

Firecracker keeps that code in a separate guest kernel, away from the host.

Key takeaways

  • Firecracker is an Apache 2.0 VMM, written in Rust, that runs microVMs on KVM.
  • Each microVM has its own guest kernel, so a guest exploit must also escape the VMM to reach the host.
  • The Firecracker specification targets guest boot in 125ms or less and VMM overhead of 5 MiB or less.
  • Firecracker needs a Linux host with KVM or, since v1.18, AWS Nitro Enclaves. It doesn't support GPU passthrough yet.
  • Baseten Sandboxes run each sandbox as a Firecracker microVM that resumes from standby with its state intact.

What is Firecracker?

Firecracker is an open-source virtual machine monitor (VMM) from Amazon Web Services (AWS). It runs Firecracker microVMs on the Linux Kernel-based Virtual Machine (KVM). Each microVM boots its own guest kernel behind a hardware virtualization boundary.

Firecracker keeps KVM for hardware virtualization and replaces QEMU with a much smaller VMM. A VMM is the user-space process that creates a virtual machine, emulates its devices, and runs its virtual CPUs (vCPUs).

AWS started with crosvm and built a minimal device model. The Firecracker launch post says the goal was lower overhead and secure multi-tenancy. The code is 50,000 lines of Rust.

The repository says AWS built Firecracker "to accelerate the speed and efficiency of services like AWS Lambda and AWS Fargate." Before Firecracker, Lambda isolated customers on dedicated EC2 instances.

Fargate also ran each task's containers in a dedicated EC2 VM, per AWS's 2018 open-source announcement. AWS announced Firecracker at re:Invent 2018 and released it under Apache 2.0.

Treat Firecracker as a building block. It gives you a VMM and no scheduler, image pipeline, or network fabric.

Firecracker vs containers vs full VMs

A microVM has the same kernel boundary as a full VM, with most of the startup and memory cost removed. The NSDI 2020 paper measured the gap against QEMU on an m5d.metal host. NSDI is the USENIX Symposium on Networked Systems Design and Implementation.

In those tests, pre-configured Firecracker booted twice as fast as QEMU. VMM overhead was around 3 MB for Firecracker, 13 MB for Cloud Hypervisor, and 131 MB for QEMU. As a result, one host can pack more microVMs into the same memory.

Oversubscription means assigning guests more virtual memory and vCPUs than the host physically has. The authors tested it above 20x and report running up to 10x in production.

On cold starts, containers skip kernel boot because they reuse the host kernel. A fresh microVM still boots its own kernel. Snapshot restore skips guest-kernel boot and application setup such as loading runtimes and dependencies. A fresh container repeats that setup every time.

AxisFirecracker microVMsContainersFull VMs (QEMU/KVM)
Isolation boundaryOwn guest kernel behind KVM, minimal VMMShared host kernel, namespaces and cgroupsOwn guest kernel behind KVM, large device model
StartupGuest kernel boot, or snapshot restore that skips itNo kernel boot, app setup repeatsBIOS plus guest kernel boot
OverheadSmallest VMM footprint in NSDI testsNo per-workload kernel or VMMHighest VMM footprint in NSDI tests
DensityHigh, per NSDI evaluationNo per-workload guest kernel or VMMLimited by per-VM overhead
Best fitUntrusted multi-tenant code, agent sandboxesTrusted code your team wroteGuests that need broad device emulation

The guide to microVMs versus Docker goes deeper on container isolation. A second guide compares serverless, containers, and microVMs for agent workloads.

Why Firecracker suits AI agent code

Treat AI-generated code as untrusted third-party code. Containers give that code direct access to the host kernel's system call interface. A kernel bug reachable from a container is a host bug.

Common Vulnerabilities and Exposures (CVE) records show runtime and kernel bugs reaching the host:

  • CVE-2019-5736 let a malicious container overwrite the host runc binary, the container runtime, and gain host root.
  • CVE-2024-21626 let a new container process start with a working directory in the host filesystem.
  • Dirty Pipe (CVE-2022-0847) let an unprivileged user write to the page cache backed by read-only files.

Inside a Firecracker microVM, a kernel bug compromises only that guest's kernel. Reaching the host takes a second exploit against Firecracker or KVM, then a way past the jailer's restrictions. Hardware virtualization enforces that boundary, but the boundary can't stop an authorized process from sending data out. Add an egress allowlist for each workload.

gVisor takes a third route to isolation. Its Sentry is a user-space kernel that intercepts the sandbox's system calls. Without networking, the Sentry needs 53 host system calls. Interception mainly slows syscall-bound applications, per gVisor's performance guide. gVisor accepts that slowdown for stronger isolation than a container, without a separate guest kernel.

How Firecracker works

Each microVM is one Firecracker process, with KVM running the guest's vCPUs in the host kernel. The jailer confines that process, and a socket API controls it. Snapshots let a new process skip boot on restore.

The specification's boot target runs from the InstanceStart API call to the guest's /sbin/init. The target assumes a disabled serial console, a minimal kernel, and a minimal root filesystem. It applies to m5d.metal and m6g.metal hosts. The overhead target assumes 1 vCPU and 128 MiB of RAM. Actual overhead grows with workloads such as many vsock connections.

Firecracker creates five microVMs per host core per second for single-core, 128 MiB guests, per its design document. A 36-core host works out to 180 per second.

KVM and the minimal device model

KVM exposes the CPU's virtualization extensions as a kernel interface that a VMM drives. Firecracker uses it to run a full Linux guest kernel inside each microVM.

System calls from an agent's code land in that guest kernel. The host only sees the narrow interface between Firecracker, KVM, and the CPU.

The emulated device list is short. The project FAQ lists six emulated devices: virtio-net, virtio-balloon, virtio-block, virtio-vsock, a serial console, and a minimal keyboard controller. The keyboard controller exists only to stop the microVM.

The project site lists five, without the balloon device. Optional devices include virtio-pmem and an entropy source. Firecracker also starts with the serial console disabled to save boot time.

Fewer devices mean less emulation code parsing guest-controlled input. The NSDI 2020 slides describe a "Simplified device model" with "no BIOS, no PCI, etc." The slides also claim "96% fewer lines of code than QEMU."

The NSDI slides predate Firecracker's optional PCI (Peripheral Component Interconnect) transport. List the devices your guest image uses before you plan around Firecracker.

The jailer and the API socket

Firecracker's design assumes every vCPU thread runs malicious code from the moment it starts. KVM is the first barrier. The jailer adds defense in depth around the Firecracker process.

The jailer documentation describes this setup order for each Firecracker process:

  • The jailer starts as root and copies the Firecracker binary into a fresh chroot directory.
  • It creates a control group (cgroup) for the microVM when the cgroup options call for one.
  • Next, it unshares into a new mount namespace and pivots root into the jail.
  • Inside the jail, it creates /dev/kvm and /dev/net/tun nodes and hands them to a dedicated user.
  • Optionally, it joins a network namespace and a new process ID (PID) namespace.
  • Finally, it drops to that user and group ID and execs Firecracker.

Inside the process, seccomp (Linux secure computing mode) filters load per thread. The filters restrict host system calls to the minimum Firecracker needs. The design document says production hosts should start Firecracker only through the jailer.

Firecracker's OpenAPI spec defines the REST API that controls each microVM over a Unix domain socket. The getting-started guide uses --api-sock /tmp/firecracker.socket as its example path.

Before boot, you call PUT /machine-config, PUT /boot-source, PUT /drives/{drive_id}, and PUT /network-interfaces/{iface_id}. A PUT /actions request with InstanceStart then powers on the guest. InstanceStart succeeds only once per process. Run these calls by hand before you write any orchestration.

Snapshots and restore

A snapshot saves a booted microVM through the same API. You pause the guest and call PUT /snapshot/create. Firecracker writes a microVM state file and a memory file that backs guest RAM.

To restore, you call PUT /snapshot/load on a fresh Firecracker process before configuring anything else. The guest comes back paused and runs when you resume it. AWS applies the same idea in Lambda SnapStart, which snapshots an initialized execution environment.

The changelog marks full snapshots as generally available as of release 1.13. Diff snapshots, still in developer preview, save at least the memory touched since the last snapshot.

Cloning one snapshot into many microVMs copies state that should be unique to each one. On resume, Firecracker updates a VM generation ID (VMGenID) and notifies the guest. Linux 5.18 and later reseed the kernel random number generator on that signal.

A race window remains between resume and reseed. Identifiers, cached random numbers, and cryptographic tokens still replicate across clones.

Each clone also resumes with the same TAP (virtual network interface) device names and IP addresses. The snapshot docs require identical software and hardware for restores, with no guarantee across host kernels. Generate secrets and IDs after restore.

Where Firecracker runs in production

AWS runs Firecracker under Lambda. The Lambda security whitepaper says Lambda workers host microVMs created by Firecracker. AWS launched Lambda MicroVMs in 2026. The AWS News Blog credits Firecracker with over 15 trillion monthly Lambda function invocations.

Fargate's runtime is less clear. AWS's 2018 open source announcement said Fargate tasks then moved onto Firecracker. A re:Invent 2025 session describes each Fargate task running in its own EC2 instance. Treat Fargate's use of Firecracker today as unconfirmed.

Several vendors name Firecracker as their isolation layer in their own docs. E2B's security page says each sandbox runs in its own Firecracker microVM. The Vercel Sandbox documentation says the same for Vercel. Fly.io's architecture docs say application code runs in Firecracker microVMs.

Perplexity built its SPACE agent sandbox on Firecracker. The Firecracker README also lists integration with Kata Containers. The microVM platform comparison covers the managed options.

Limits of Firecracker

While Firecracker offers strong hardware-enforced isolation, it comes with clear trade-offs and operational constraints that teams must evaluate before adopting it:

  • Firecracker needs a Linux host with read/write access to /dev/kvm. Release 1.18 adds Nitro Sandboxes, which use AWS Nitro Enclaves instead of KVM. The getting-started guide uses only .metal EC2 instances because EC2 supported KVM only there.
  • AWS added nested virtualization on C8i, M8i, and R8i instances in 2026. However, a Firecracker maintainer wrote in 2022 that Firecracker doesn't support nested virtualization but doesn't block it. Test nested hosts before you rely on them. Host and guest kernels follow the kernel support policy, which lists 5.10, 6.1, and 6.18.
  • GPU passthrough has not shipped. Release 1.13 added an optional PCI transport for virtio devices, behind the --enable-pci flag.
  • Issue #5679 tracks Virtual Function I/O (VFIO), which device passthrough needs. The issue is open and marked work in progress. A 2024 proof-of-concept branch pre-allocated guest memory whenever it attached VFIO devices, which rules out memory oversubscription.
  • The minimal device model limits what guests can do. The project FAQ also notes no Advanced Configuration and Power Interface (ACPI) power management on x86 and no guest reboot. Guests must run Linux or OSv.

Self-hosting also means running a host fleet. The production host guide calls for regular patching of host and guest kernels and microcode. The guide also recommends turning off simultaneous multithreading (SMT) for tenant separation, and disabling Kernel Samepage Merging.

Firecracker does no packet filtering, so firewall rules live on the host. Scheduling, IP allocation, and image distribution are yours to build. Count that engineering time before you compare per-VM costs.

Where Baseten Sandboxes fit

Baseten Sandboxes provide the infrastructure foundation for autonomous agents. Each sandbox is a Firecracker microVM with its own kernel. The platform is fully managed and runs across US and EU regions.

The sandbox lifecycle works like this:

  • Creation: Creating a new sandbox takes under a second.
  • Standby: A sandbox with no active connection enters standby after about 15 seconds, and compute charges stop.
  • Resume: The sandbox resumes from standby in under 25ms with filesystem, memory, and running processes intact.
  • Retention: Standby has no time limit on higher quota tiers. Tier 0 and Tier 1 cap standby at 7 and 30 days, respectively.

Standby is not durable storage. Use Volumes for data that must outlive a sandbox. Agent Drive, in private preview, shares a filesystem across sandboxes. Batch Jobs split work across isolated sandboxes. For egress, Baseten Sandboxes offer per-workload outbound traffic control and a proxy that injects secrets, both in public preview.

FAQs about Firecracker

Is Firecracker open source?

Yes. AWS publishes Firecracker on GitHub under the Apache 2.0 license. The release policy lists v1.18, released on November 9, 2026, as the latest line. The repository holds the VMM, the jailer, the API specification, and production host guidance.

What is the difference between Firecracker and Docker?

Docker runs containers that share the host's Linux kernel, separated by namespaces and cgroups. Firecracker runs microVMs, each with its own guest kernel behind KVM. So a kernel exploit in a container lands in the shared host kernel. In a microVM, the exploit stops at the guest kernel. Use Docker for code you trust, and run agent-generated code in a microVM.

Does Firecracker support GPUs?

No. Firecracker doesn't support GPU passthrough today. GPUs need VFIO device passthrough, which remains open work on the Firecracker roadmap. Maintainers have said passthrough conflicts with memory oversubscription. Plan GPU work on separate infrastructure for now.

How does Firecracker compare with gVisor?

gVisor intercepts system calls in a user-space kernel called the Sentry, which runs on the host kernel. Firecracker gives each workload its own guest kernel behind hardware virtualization. gVisor's isolation exceeds that of a plain container, though programs that make many system calls run slower.

How do Firecracker microVMs cut startup latency?

Firecracker drops the BIOS and most device emulation, so the guest kernel reaches userspace quickly. Snapshot restore goes further. A restored guest resumes from saved memory, with runtimes and dependencies already loaded. A new container avoids kernel boot, yet still loads its runtime from scratch. Measure restore times on your own images before you commit.

Related articles