OPEN SOURCE DEEP DIVE
CubeSandbox: High-Concurrency MicroVM Sandboxes for Coding Agents
A KVM-based, E2B-compatible sandbox platform with fast restore, snapshots, controlled egress and dense coding-agent execution.
CubeSandbox is an open-source sandbox platform from Tencent Cloud for coding agents. The problem it addresses is not code generation itself, but the execution layer around generated code: how to run untrusted commands with strong isolation, create environments quickly, restore state for retries, enforce network policy, and retain an audit trail. Its isolation primitive is a KVM microVM. On top of that foundation, it exposes an E2B-compatible interface and separates API handling, scheduling, routing, execution, snapshots, networking, and lifecycle management into distinct components.
This review covers TencentCloud/CubeSandbox at commit 6843e3f97e670e8e5f1e8b720f8538938dcaf700, dated 2026-11-21. The repository describes the project as Apache 2.0 and also notes that some modified upstream components retain their own terms, which is why GitHub reports a custom license. A deployment should review the licenses of the components it actually distributes rather than relying on a single repository-level label.
A coding agent needs an execution environment it can discard
Coding agents run tests, install dependencies, start services, modify repositories, and execute commands that were not necessarily reviewed by a person. Running those actions on a developer workstation or inside a long-lived application container leaves privileges, state, and dependency conflicts behind. Containers are convenient and cheap, but tasks share the host kernel. A microVM gives each sandbox a dedicated guest kernel, strengthening the isolation boundary at the cost of more virtualization machinery. CubeSandbox tries to recover that cost through snapshots, copy-on-write storage, and a purpose-built creation path.
E2B compatibility is the second load-bearing design choice. Code already written against E2B sandbox creation, command execution, file operations, and snapshots can point at a replacement endpoint instead of rebuilding its integration. More importantly, the interface turns the sandbox into a replaceable infrastructure dependency. The coding agent, evaluation harness, and delivery pipeline can evolve without being tied to one virtualization implementation.
How a request reaches a sandbox
CubeSandbox does not collapse every responsibility into one process. CubeAPI is a Rust and Axum interface layer. CubeMaster is the Go scheduling and cluster-control component. CubeProxy uses OpenResty for request routing. Cubelet manages the sandbox lifecycle on each node, and CubeShim connects that lifecycle path to RustVMM and KVM. The data plane adds CubeVS for eBPF networking, CubeCoW for XFS copy-on-write snapshots, and CubeEgress for controlled outbound access. The split gives operators independent failure domains and lets each layer evolve without forcing the others to change.
| Component | Responsibility | What it changes for an operator |
|---|---|---|
CubeAPI | Rust and Axum interface layer for sandbox and execution requests. | An existing E2B client can target the platform as a replacement backend. |
CubeMaster | Go scheduling and cluster control. | Chooses nodes for new sandboxes and coordinates multi-node resources. |
CubeProxy | OpenResty request proxy and routing layer. | Routes control traffic without forcing clients to understand node topology. |
Cubelet and CubeShim | Node-side lifecycle management and runtime-to-hypervisor integration. | Creates, pauses, restores, snapshots, and destroys sandboxes. |
RustVMM and KVM | MicroVM execution with a dedicated guest kernel. | Separates generated code from the host kernel and other sandboxes. |
CubeVS | eBPF network data plane. | Provides sandbox networking and supports isolation policy. |
CubeCoW | XFS copy-on-write filesystem support. | Shares unchanged data while creating writable snapshot and clone layers. |
CubeEgress | Layer-seven outbound proxy. | Constrains access by domain, path, method, and related policy. |
This separation is more than a diagram. A sandbox platform has to reconcile hostile workloads, fast allocation, node failure, network policy, and persistent state. A monolithic service makes those concerns look simpler until one of them fails. CubeSandbox gives isolation to the hypervisor, copy efficiency to the filesystem, policy to the proxy, and placement to the scheduler. That division is the basis for scaling beyond a single development machine.
The lifecycle of a coding task
A typical call starts from a template or base environment. The control plane accepts a create request, CubeMaster chooses a node, and the node prepares a microVM with a copy-on-write root filesystem. Once ready, the coding agent can execute commands, transfer files, start services, and inspect output through the compatible API. At the end of the task, the caller can destroy the sandbox or capture a snapshot for retries, checkpoints, and branching.
The guest kernel matters for coding workloads. An agent can install packages, alter kernel settings, or run tests that expect privileged behavior without changing the host kernel directly. The host still needs KVM access, resource limits, and careful virtualization configuration. CubeSandbox does not remove infrastructure work; it places each task's kernel state inside a disposable boundary.
The E2B-compatible lifecycle also fits evaluation loops. A benchmark can create a fresh environment for every patch, run the test suite, and preserve a failing workspace. Another loop can clone one prepared snapshot several times and validate competing fixes in parallel. CubeSandbox exposes those operations as platform behavior instead of requiring every caller to implement virtual-machine management.
Snapshots trade state for speed
The project distinguishes full snapshots from filesystem-only snapshots. A full snapshot preserves the guest runtime state as well as storage, which allows in-place rollback and can seed clones or forks. A filesystem-only snapshot preserves files but requires a cold boot when restored, and therefore cannot roll back live memory state. The distinction is operational, not cosmetic. Tests that depend on a running service or in-memory process need the full path; tasks that only need a prepared repository and dependencies can use the filesystem path with a colder restore sequence.
XFS copy-on-write makes clones share unchanged base data and allocate separate blocks only when a write occurs. This is essential for concurrency. Copying a complete multi-gigabyte environment for every task would turn storage bandwidth into the bottleneck, even if the microVM itself starts quickly. CubeCoW defers the expensive copy until the workload actually changes those blocks.
| Snapshot type | State retained | Restore behavior | Operational boundary |
|---|---|---|---|
| Full snapshot | Guest runtime and filesystem state. | Rollback in place or clone into a running sandbox. | Preserves more state and carries more state-management overhead. |
| Filesystem-only snapshot | Disk and file contents. | Restore storage, then cold boot the guest. | Cannot restore live memory state or replace a full snapshot. |
The distinction also prevents a common migration mistake. A team might design a benchmark around snapshot branching, then switch to filesystem-only snapshots to save storage and discover that a running server or process state disappeared. The platform documents the semantic difference, but the caller still has to choose the correct primitive for the task.
Network and credentials sit outside the workload
Generated code may need package registries, internal APIs, or model services, but it may also try to exfiltrate data. CubeSandbox starts from a default-deny egress posture and opens access through explicit policy. CubeEgress can filter by domain, path, and HTTP method, which makes it possible to allow one endpoint rather than granting unrestricted internet access. That is useful when a dependency needs a package feed or when an agent should call a narrow model API but must not browse arbitrary destinations.
Credential injection is handled outside the sandbox filesystem and process environment. A proxy injects the secret into an approved request path instead of exposing a long-lived token to code that can read files or enumerate environment variables. CubeEgress records requests as JSONL audit events, creating a record of what a sandbox attempted to reach and when.
Those controls do not make arbitrary code trustworthy. The microVM isolates kernels, egress policy narrows the network, and external injection limits secret exposure, but the management plane, host hardening, image supply chain, authentication, log retention, and quotas still require independent design. The security claim belongs to the combined system, not to the word "sandbox" by itself.
Reading the published performance numbers
The repository reports cold starts under 60 milliseconds. In a test of 50 concurrent creates, it reports an average of 66.7 milliseconds, P95 of 89.1 milliseconds, and P99 of 136.8 milliseconds. It also reports VMM memory overhead below 5 MB. These numbers show where the project focused its optimization: the control path and virtualization machinery for large numbers of short-lived sandboxes.
The figures are vendor benchmarks, not an independent comparison across platforms. They do not prove that every host, image, start script, or network will produce the same latency. The sub-5-MB figure is especially easy to misread: it describes VMM overhead, not total sandbox memory. Guest kernels, user processes, caches, and task data still need their own memory budget. A serious evaluation should repeat the test with the intended image size, concurrency pattern, host shape, and cold-cache conditions.
The deployment requirements are heavier than a container stack
The quick-start path requires x86_64 and KVM. ARM64 systems need native KVM or bare-metal support, and a container host without virtualization access is not enough. The project also provides a PVM path for ordinary cloud virtual machines, but that path has its own support and performance boundary. Operators should not treat PVM, local KVM, and ARM-native deployments as interchangeable when planning capacity.
The storage path is equally specific. Cubelet requires XFS for /data/cubelet, with at least 50 GB and 200 GB recommended. Larger image and snapshot catalogs need more capacity. The production guidance starts around 32 cores and 64 GB of RAM, which is a deployment starting point rather than a guarantee for every workload. Before the first launch, verify the KVM device, kernel modules, nested-virtualization availability, and filesystem type.
CubeSandbox supplies execution infrastructure, not an editor, model, or agent loop. Integrations include Claude Code, the OpenAI Agents SDK, LangChain and LangGraph, Pi Agent, OpenClaw, and SWE-bench or mini-swe-agent workflows. The upper layer still chooses models and strategies; CubeSandbox supplies the disposable environment and its lifecycle. That boundary is why E2B compatibility matters: teams can preserve their agent code while moving the sandbox backend under their own control.
Where it fits
CubeSandbox is a strong fit for isolated kernel boundaries, rapid creation, stateful retries, and dense parallel coding tasks. Examples include repository repair, automated test execution, agent evaluation, competing patch validation, and per-session dependency isolation. It is also relevant to teams that want an E2B-compatible API but need to own scheduling, network policy, and data placement rather than delegating the environment to a managed service.
It is less compelling for a handful of trusted commands on one developer laptop. The host requirements, image lifecycle, XFS storage, and network policy become overhead when the threat model is mild. Teams without KVM, XFS, or a plan for managing virtualization nodes should use a conventional container or managed sandbox instead. If the requirement is hostile multi-tenant isolation, CubeSandbox still needs management-plane authentication, host hardening, image signing, monitoring, and audit retention around it. It is an execution substrate with explicit boundaries, not a complete tenant-security product.
The project's real contribution is therefore the lifecycle, not a single startup number. It combines dedicated guest kernels, copy-on-write snapshots, controlled egress, credential mediation, E2B compatibility, and node-level orchestration into one coding-agent substrate. That combination raises the deployment bar, but it also moves parallel code execution from "run a container with a timeout" into an infrastructure component that can be operated, audited, cloned, and recovered.