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

> What a Firecracker sandbox is, why AI agent platforms use microVMs for untrusted code, what Firecracker does not do for you, and how to run agent code in one with the Sandscale SDK, CLI or MCP.

What a Firecracker sandbox is, why AI agent platforms use microVMs for untrusted code, what Firecracker does not do for you, and how to run agent code in one with the Sandscale SDK, CLI or MCP.

November 27, 2026 · 5 min read · The Sandscale team

**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](https://firecracker-microvm.github.io/) and its [design document](https://github.com/firecracker-microvm/firecracker/blob/main/docs/design.md), 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](https://sandscale.dev/blog/firecracker-jailer-and-seccomp-explained). If KVM itself is unfamiliar, start with [KVM for application engineers](https://sandscale.dev/blog/kvm-basics-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](https://sandscale.dev/blog/isolating-ai-agent-code-containers-gvisor-firecracker) compares the three approaches, and [container escape CVEs](https://sandscale.dev/blog/container-escape-cves-lessons-for-agent-sandboxes) 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:

- **Network policy.** Firecracker gives the guest a network device; what it may reach is your call. See [egress allowlist design](https://sandscale.dev/blog/egress-allowlist-design-for-agent-sandboxes) and [DNS exfiltration](https://sandscale.dev/blog/dns-exfiltration-explained).
- **Resource limits.** vCPU and memory per microVM, plus [rate limiters for network, disk and entropy](https://sandscale.dev/blog/firecracker-rate-limiters-explained).
- **Secrets.** Anything in the guest’s environment can be read by code in the guest. See [secrets in environment variables](https://sandscale.dev/blog/secrets-in-environment-variables-risks).
- **A guest image.** A kernel, a root filesystem and boot arguments: [what a Firecracker guest needs](https://sandscale.dev/blog/firecracker-guest-kernel-and-rootfs).
- **Host hardening and operations.** [The production host checklist](https://sandscale.dev/blog/firecracker-production-host-checklist) covers what the Firecracker docs ask of the host.
- **Snapshots, if you use them.** [What a microVM snapshot contains](https://sandscale.dev/blog/microvm-snapshots-pitfalls) and how restoring one can go wrong.

Whether to build that yourself or use a hosted service is its own question: [self-hosting Firecracker vs a hosted microVM sandbox](https://sandscale.dev/blog/self-hosted-firecracker-vs-hosted-microvm-sandbox).

## Running agent code in a Firecracker sandbox with Sandscale

Each [Sandscale sandbox](https://sandscale.dev/sandboxes) 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):

```js
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 });
}
```

**CLI** (macOS and Linux):

```sh
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
```

`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](https://sandscale.dev/blog/how-to-run-tests-in-a-sandbox-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](https://sandscale.dev/blog/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

- Firecracker: [https://firecracker-microvm.github.io/](https://firecracker-microvm.github.io/), [https://github.com/firecracker-microvm/firecracker/blob/main/docs/design.md](https://github.com/firecracker-microvm/firecracker/blob/main/docs/design.md)
- Sandscale: [Sandboxes concept](https://sandscale.dev/docs/concepts/sandboxes), [Quickstart](https://sandscale.dev/docs/quickstart), [sandscale sandbox reference](https://sandscale.dev/docs/reference/cli/sandbox)

**On this page**

1. What Firecracker is
2. Why agents, specifically
3. What Firecracker does not decide for you
4. Running agent code in a Firecracker sandbox with Sandscale
5. FAQ

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 29, 2026 · **Your first Sandscale sandbox from Claude Code: sign up, connect, run one command** · A first-run walkthrough: create a Sandscale account, install the CLI, connect Claude Code with claude mcp add, and have it start a sandbox, run node --version inside it and stop it.](https://sandscale.dev/blog/claude-code-first-sandbox-tutorial)
- [November 29, 2026 · **Your first Sandscale sandbox from Codex: config.toml, login and a Go command in a microVM** · A first-run walkthrough: create a Sandscale account, add the remote MCP server to Codex's config.toml, run codex mcp login, and have Codex start a Go sandbox, run go version in it and stop it.](https://sandscale.dev/blog/codex-first-sandbox-tutorial)

---
Source: https://sandscale.dev/blog/firecracker-sandbox-for-ai-agents
