DEV Community

Sandscale
Sandscale

Posted on Edited on Originally published at sandscale.dev

Firecracker sandbox for AI agents: what you get, what you still decide, and where to start

Short answer: a Firecracker sandbox is a small virtual machine (a microVM) started by Firecracker, the open source virtual machine monitor AWS built for Lambda and Fargate. Each sandbox boots its own Linux kernel on top of KVM, so code inside it does not share a kernel with your host or with other sandboxes. That is why agent platforms use it for code a model wrote: a kernel bug inside one sandbox is a much smaller problem than a kernel bug in a shared container host. Firecracker gives you the isolation boundary; network policy, secrets, limits and records are still yours to decide.

This post is the starting point for our Firecracker material. Each section links to a longer piece.

What Firecracker is

From the Firecracker project and its design document, read in November 2026:

  • A virtual machine monitor written in Rust that uses Linux KVM.
  • A deliberately small device model: virtio network and block devices, vsock, a serial console and a minimal keyboard controller. Fewer emulated devices means less code an attacker in the guest can reach.
  • A process per microVM, meant to run under the jailer with a seccomp filter, so a compromised VMM process is still confined on the host.
  • An API over a Unix socket to configure and start each microVM.

The longer read is Inside Firecracker's defense in depth: KVM, the device model, seccomp and the jailer. If KVM itself is unfamiliar, start with KVM for application engineers.

Why agents, specifically

A coding agent runs commands nobody reviewed: package installs with install scripts, test suites from a pull request, code pasted from a web page. Containers share the host kernel, so their isolation is only as good as the kernel's namespaces, cgroups and seccomp profile. A microVM puts a hardware-virtualization boundary between that code and the host. Containers, gVisor or Firecracker compares the three approaches, and container escape CVEs shows why the shared kernel matters.

What Firecracker does not decide for you

A microVM boundary is one layer. Running agent code well still needs:

Whether to build that yourself or use a hosted service is its own question: self-hosting Firecracker vs a hosted microVM sandbox.

Running agent code in a Firecracker sandbox with Sandscale

Each Sandscale sandbox is a Firecracker microVM with its own kernel and the network access your plan and your organization's policy allow. Three ways in, all from the live docs:

TypeScript SDK (npm install @sandscale/sdk, Node.js 22 or later):

import { Sandscale } from '@sandscale/sdk';

const sandscale = new Sandscale(); // reads SANDSCALE_API_KEY
const box = await sandscale.sandboxes.create({ template: 'builtin:python', timeoutSeconds: 600 });
try {
  const run = await sandscale.sandboxes.run(box.id, ['python3', '-c', 'print(6 * 7)'], { region: box.region });
  console.log(run.exitCode, run.stdout);
} finally {
  await sandscale.sandboxes.stop(box.id, { region: box.region });
}
Enter fullscreen mode Exit fullscreen mode

CLI (macOS and Linux):

sandscale sandbox create --template-id builtin:base --yes
sandscale sandbox run SANDBOX_ID --yes -- python3 -c "print(6 * 7)"
sandscale sandbox terminate --id SANDBOX_ID --yes
Enter fullscreen mode Exit fullscreen mode

create returns the sandbox id, run runs the command in it, streams its output and exits 0 or 1, and terminate ends the sandbox. How to run your test suite in a clean microVM with the Sandscale CLI goes through uploading a project and the exit codes.

MCP, for a coding agent: add https://mcp.sandscale.dev/mcp as a remote MCP server, and the agent can start sandboxes, run commands, move files and stop them, as you and inside your policy. See remote vs local Sandscale MCP server.

Around the microVM, Sandscale adds what the list above says you would otherwise build: plan and policy limits, Vault for secrets, approvals, a kill switch and a hash-chained audit log.

FAQ

What is a Firecracker sandbox?

A Firecracker sandbox is a lightweight virtual machine started by Firecracker, an open source virtual machine monitor that uses Linux KVM. Each one boots its own kernel, so code inside it does not share a kernel with the host or other sandboxes.

Is Firecracker more secure than Docker for running AI-generated code?

It gives a stronger boundary. A Docker container shares the host kernel, while a Firecracker microVM runs its own kernel behind hardware virtualization, with a small device model and a jailed, seccomp-filtered VMM process. You still need network, secret and resource controls on top.

Does Firecracker handle network policy?

No. Firecracker gives the guest a network device and rate limiters. Which hosts the guest may reach is a policy you add, for example an egress allowlist.

Do I have to run Firecracker myself?

No. You can self-host it on KVM-capable hosts, or use a hosted service such as Sandscale, where each sandbox is a Firecracker microVM started with the SDK, CLI, API or MCP.

Sources

Originally published on the Sandscale blog.

Top comments (0)