How It Works
Microsandbox is a self-hosted, local-first microVM runtime designed to execute untrusted code in isolated environments. It operates by creating lightweight virtual machines (VMs) that provide hardware-level isolation for workloads such as AI-generated code, plugins, CI jobs, and automation scripts. Each sandbox runs as a separate VM with its own Linux kernel, filesystem, and network boundary, ensuring that untrusted processes cannot access the host system or other sandboxes. This approach contrasts with traditional containerization, which relies on shared host kernel namespaces and may expose vulnerabilities if exploited.
The runtime supports an OCI-compatible workflow, allowing users to pull and manage standard container images from registries like Docker Hub, GitHub Container Registry (GHCR), and other OCI-compliant sources. This compatibility extends to familiar Docker-like commands, such as msb run, msb exec, and msb pull, making adoption straightforward for teams accustomed to containerized environments. Under the hood, Microsandbox leverages Rust for performance and safety, ensuring fast boot times—typically under 100 milliseconds—while maintaining strong isolation guarantees.
A key innovation is the ability to embed sandboxes directly within applications via SDKs for TypeScript, Rust, Python, Go, and Ruby. This eliminates the need for a long-running daemon or external server, as the SDK spawns VMs as child processes. Secrets are handled securely by design: sensitive credentials never enter the VM, reducing the risk of exposure even if the sandbox is compromised. Additionally, sandboxes can be forked, snapshotted, and restored, enabling workflows like branching experiments or reverting to a known state after testing.
Microsandbox also supports cross-platform deployment on Linux, macOS (Apple Silicon), and Windows (with WHP enabled), though Linux requires KVM for full functionality. The architecture is modular, allowing sandboxes to run locally or on hosted infrastructure by toggling an API key. This flexibility caters to teams with strict data residency requirements or those preferring to avoid cloud dependencies.
Use Cases
Microsandbox addresses a broad range of security and operational challenges in AI and software development. One primary use case is AI agent security, where coding agents or tool-using assistants execute commands, install packages, or manipulate files within isolated VMs. This prevents malicious or flawed AI-generated code from compromising the host system. For example, an agent could run a Python script to analyze a dataset without risking access to host secrets or system files.
In CI/CD pipelines, Microsandbox enables disposable, isolated environments for test jobs, compilers, and package managers. Each build step can run in a fresh VM, eliminating concerns about contaminated build caches or shared dependencies. This is particularly valuable for teams adopting multi-stage builds or third-party plugins, where untrusted code might otherwise interact with the host.
For development environments, Microsandbox provides disposable Linux machines without requiring Docker or modifying the host system. Developers can spin up ephemeral workspaces for testing, debugging, or experimenting with new tools—such as running a headless browser via Playwright or converting documents to PDF—without persistent changes to their local machine.
Automation and scraping workflows benefit from Microsandbox’s network controls, which restrict sandboxes to predefined domains while blocking private networks or metadata services.
Beyond individual use cases, Microsandbox is integrated into broader agent frameworks and tools. These integrations highlight Microsandbox’s role as a foundational component for secure, scalable AI systems.
Hardware Isolation and Performance
Microsandbox achieves isolation at the hardware level by running each workload in a separate VM with its own kernel and memory space. This differs from containerization, which shares the host OS kernel and can be vulnerable to kernel exploits or privilege escalations. The lightweight design ensures fast boot times—averaging under 100 milliseconds—while maintaining compatibility with OCI images. Users can pull images like python:3.12 or ubuntu and execute them with commands such as msb run python -- python3 -c "print('Hello from a microVM!')".
Branch and Snapshot Functionality
Snapshots can be saved to files (e.g., msb snap create --sandbox app --full -o saved.msb) and restored later (msb snap restore saved.msb --name restored), enabling workflows like migration rehearsals or long-running sessions.
Cross-Platform and Embeddable Design
Microsandbox supports Linux (with KVM), macOS (Apple Silicon), and Windows (WHP-enabled), though some features may require specific hardware or configurations. The SDKs for TypeScript, Rust, Python, Go, and Ruby allow developers to embed sandboxes directly in applications.
Secrets Management and Network Controls
Secrets are handled securely by design: sensitive environment variables or API keys are injected into the VM at runtime and never persisted or exposed to the host.
Docker-Like Workflows and CLI
The msb CLI mirrors Docker’s familiarity, offering commands for running, managing, and inspecting sandboxes. Users can pull images (msb pull python), list cached images (msb image ls), or execute commands in named sandboxes (msb exec app -- python -c "import this"). Named sandboxes persist across sessions and can be stopped, started, or removed as needed.
Agent and Tool Integration
Microsandbox is actively integrated into agent frameworks and tools to enhance security and functionality. These integrations demonstrate Microsandbox’s role as a versatile component for secure, scalable AI systems, particularly in environments where untrusted code execution is a concern.
Recent Developments and Fixes
These updates reflect ongoing efforts to stabilize the runtime while expanding its capabilities.
