SPACE: A Firecracker microVM Sandbox for AI AgentsNote · digest for October 29
Isometric 3D model of the SPACE hardware sandbox featuring an isolated KVM-backed Firecracker microVM.
Note2 sections≈ 3 min

SPACE: A Firecracker microVM Sandbox for AI Agents

Picture this: you ask an AI agent to test a script or wire up a data pipeline. The agent writes the code, installs packages in the terminal, and hits external APIs. Where do you run that code? Nine times out of ten, developers spin up a standard Docker container.

Right at that moment, a critical security gap opens up in your architecture. Containers were never designed as a hard isolation boundary for hostile or untrusted code: they share the host's Linux kernel. If a generated script exploits a known kernel vulnerability (a container breakout), the agent gains direct access to the host's root filesystem, environment variables, and internal network ports. We explored this exact paradox earlier in The Security Illusion: Why AI Agents Haven't Escaped Sandboxes Yet—and What Happens When Limits Are Lifted, where loose boundaries led straight to instant internal network scanning.

Now, Perplexity AI's engineering team has open-sourced the platform powering their own Perplexity Computer service: SPACE (Sandboxed Platform for Agentic Code Execution). It is an open-source orchestrator for isolated environments built on Firecracker microVM hardware virtualization under the Apache 2.0 license.

Hard Kernel Isolation: Firecracker microVM Architecture

Instead of relying on cgroups and namespaces, SPACE launches every sandbox as a minimal, standalone virtual machine. Each one gets its own independent Linux kernel, isolated memory, and a filesystem backed by btrfs snapshots. Even if the agent escalates to root inside the guest, it stays trapped inside the microVM at the CPU hardware level via KVM extensions.

Written in Rust, SPACE splits its architecture into two planes:

  1. Control Plane: An HTTP REST API for declaratively spinning up sandboxes from base templates (Python, Node.js), managing resources, and freezing state (suspend/resume);
  2. Data Plane: Streaming connections over WebSocket and Server-Sent Events for real-time stdin/stdout/stderr I/O.

The authors also paid special attention to secret handling. In SPACE, sensitive API tokens are never injected into the guest VM's environment variables. Authorization headers are attached externally at the host's egress gateway, which enforces a strict domain allowlist to block SSRF attacks and covert cryptomining.

In Practice: Creating a Sandbox and Running Code via API

Spinning up a sandbox takes a single POST request to the Control Plane:

# Initialize an isolated sandbox with a Python template
curl -s -X POST http://localhost:8080/v1/sandboxes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SPACE_API_KEY" \
  -d '{
    "template": "python-data-science:latest",
    "timeout_seconds": 300,
    "memory_mb": 2048,
    "vcpu": 2
  }'

# The server returns the session ID:
# {"sandbox_id": "sbx_01j9a8b7c6d5e4f3", "status": "ready"}

Cold starts take just a few hundred milliseconds, and with Warm Pools enabled, a ready-to-use VM is handed out in 10–20 ms. Next, let's execute a command inside the isolated environment and capture its output:

# Run a command inside the guest OS and capture the output
curl -s -X POST http://localhost:8080/v1/sandboxes/sbx_01j9a8b7c6d5e4f3/commands \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SPACE_API_KEY" \
  -d '{
    "command": ["python3", "-c", "import sys; print(f\"Изолированный рантайм: {sys.version}\")"],
    "stream": false
  }'

# Suspend the sandbox while preserving disk state on btrfs
curl -s -X POST http://localhost:8080/v1/sandboxes/sbx_01j9a8b7c6d5e4f3/suspend \
  -H "Authorization: Bearer $SPACE_API_KEY"

SPACE also includes an E2B Compatibility Wrapper for the popular E2B SDK, letting you migrate existing agent pipelines onto your own hardened infrastructure.

Host Infrastructure Requirements

Running Firecracker microVMs requires a bare-metal server or a cloud instance with nested virtualization enabled and access to /dev/kvm. You will not be able to run SPACE inside standard virtual machines that lack hardware KVM support.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 2