{"slug": "run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode", "title": "Run a coding agent in a microVM before enabling YOLO mode", "summary": "BoxLite, an Apache-2.0 open-source embedded microVM runtime, lets developers run coding agents such as Claude Code in hardware-isolated virtual machines instead of enabling `--dangerously-skip-permissions` (YOLO mode) on the host. BoxLite boots each Box through a `boxlite-shim` child process using `libkrun` on macOS `Hypervisor.framework` (Apple Silicon macOS 12 and later) or Linux KVM, backed by a host-side OS jailer, an `allow_net` egress allowlist, and a host-side `Secret` proxy, with no Docker daemon, no root privileges, and about a dozen lines of Python. The project targets indirect prompt injection hidden in `CLAUDE.md`, `AGENTS.md`, READMEs, code comments, error logs, or dependencies, and agent \"Escape to Complete\" behavior, so a destructive command is contained to a microVM disk that can be discarded while host files and keys stay intact.", "body_md": "Running Claude Code without `--dangerously-skip-permissions` interrupts every step with approval prompts. Turning it on hands a coding agent your host shell. Permission hooks and plain Docker leave gaps because indirect prompt injections can hide inside `CLAUDE.md` or error logs, and standard containers share your host kernel. BoxLite embeds a microVM runtime as a library using `libkrun` on macOS `Hypervisor.framework` or Linux KVM, paired with a host-side OS jailer, an `allow_net` egress allowlist, and a host-side `Secret` proxy. No Docker daemon, about a dozen lines of Python. If the agent runs something destructive, you throw away the microVM and keep the rest of your host files and keys intact.\n\nLocal coding agents like Claude Code and OpenClaw force a tradeoff. Leave auto-approval off, and every test run or config edit stops for confirmation. Turn on `--dangerously-skip-permissions` (YOLO mode), and the agent gets a host shell. Work moves faster, and every mistake hits your local machine.\n\nReal incidents go beyond accidental file deletion. As context degrades over a long session, an agent can mishandle path expansion and turn a cleanup command into `rm -rf ~/` or wipe an uncommitted Git stash. Indirect prompt injection is harder to spot. When you clone an external repo and ask an agent to debug it, hostile instructions can sit inside `CLAUDE.md`, `AGENTS.md`, a README, code comments, error logs, or third-party dependencies.\n\nSecurity debates around OpenClaw point to the same root cause. When a long-running agent gateway holds read and write access to the host filesystem, reading `~/.ssh`, `.env`, or cloud credentials takes one ordinary command. When a soft sandbox blocks a diagnostic command, agents also show \"Escape to Complete\" behavior: they look for alternate commands to bypass or disable the restriction so they can finish the task.\n\nMany teams start with tool-call hooks like `PreToolUse` or a `permissions.deny` denylist. Those checks run in the same user environment as the agent. As long as the agent can run Python, Node, or any compiled binary, it can bypass string-based matching, read `.env` from a script, and send the contents over the network.\n\nAnother common setup puts the agent in a standard Docker container. Containers separate the filesystem view, while sharing one Linux kernel with the host. Untrusted generated code still carries a kernel-escape risk. On macOS, Docker also needs the background Docker Desktop VM, which eats memory and adds licensing costs. Passing real API keys as container environment variables exposes them inside the container. If a prompt injection triggers there, one `printenv` command can leak every key.\n\nBoxLite is an Apache-2.0 open-source embedded microVM runtime. You embed it in your application as a library, with no Docker daemon and no root privileges. It runs standard Open Container Initiative (OCI) images and puts four hard boundaries around coding agents.\n\nHardware virtualization handles kernel isolation. BoxLite spawns an isolated `boxlite-shim` child process through `ShimController`, which calls `libkrun` to boot a microVM. It uses `Hypervisor.framework` on Apple Silicon macOS (12 and later) and KVM (`/dev/kvm`) on Linux and WSL2. Each Box runs its own guest kernel. Even if an agent runs `rm -rf /` inside the Box, the damage stops at that microVM's disk and never touches the rest of the host filesystem.\n\nA host-side OS jailer backs up the VM layer. If a bug breaks out of the microVM, the jailer limits what host resources `boxlite-shim` can reach. On Linux, it combines mount, PID, and network namespaces, `chroot` or `pivot_root`, Seccomp BPF syscall filtering, dropping to an unprivileged user, and cgroups v2 limits. On macOS, it loads a Seatbelt SBPL profile through `/usr/bin/sandbox-exec` starting from `(deny default)`, applies `rlimits`, and separates `AF_UNIX` control-plane socket permissions from IP network permissions.\n\nAn egress allowlist locks down outbound traffic. With `NetworkSpec(mode=\"enabled\", allow_net=[...])`, BoxLite resolves only allowlisted hostnames and sinkholes every other DNS lookup to `0.0.0.0`. To stop an agent from connecting to raw IP addresses to bypass DNS checks, BoxLite inspects TLS SNI and HTTP `Host` headers on TCP connections. When `allow_net` contains only hostnames, it also blocks all outbound UDP traffic. For offline tasks, `NetworkSpec(mode=\"disabled\")` removes the virtual network interface completely.\n\nA host-side secret proxy keeps real credentials out of the guest. When you configure `Secret(name, value, hosts)`, the real key stays on the host. Code inside the guest sees only a placeholder, which defaults to `<BOXLITE_SECRET:name>` and is also exposed as `BOXLITE_SECRET_<NAME>`. When the guest sends an HTTPS request to a domain listed in `hosts`, the host proxy swaps the placeholder for the real secret in the HTTP headers. If a malicious `CLAUDE.md` tricks the agent into exfiltrating environment variables to an external server, the attacker gets a useless placeholder and the allowlist blocks the request.\n\n```\nflowchart LR\n  subgraph L[\"Bare host or shared-kernel container\"]\n    direction TB\n    A1[\"Coding Agent (YOLO mode)\"] --> A2[\"Reads real keys from .env and ~/.ssh\"]\n    A1 --> A3[\"Host filesystem or shared Linux kernel\"]\n    A2 --> A4[\"Exfiltrates credentials via curl to any domain\"]\n  end\n\n  subgraph R[\"BoxLite dual-layer isolation and egress filtering\"]\n    direction TB\n    subgraph J[\"OS Jailer (Linux Seccomp/NS or macOS Seatbelt deny default)\"]\n      subgraph VM[\"Hardware MicroVM (libkrun / KVM / Hypervisor.framework)\"]\n        B1[\"Coding Agent + isolated guest kernel\"]\n        B2[\"Sees only mounted repo and Secret placeholders\"]\n      end\n    end\n    B1 --> B3[\"Host egress gateway (allow_net + Secret proxy)\"]\n    B3 -->|\"Matches allow_net and hosts\"| B4[\"Injects real key and forwards to API host\"]\n    B3 -->|\"Not allowlisted\"| B5[\"DNS sinkhole to 0.0.0.0 and block\"]\n  end\n```\n\nInstall the Python SDK with `pip install boxlite` (requires Python 3.10 or later). This example uses `SimpleBox` to mount a local repo read-write so the agent can edit code, restrict outbound traffic to `api.anthropic.com`, and keep the real API key on the host with `Secret`:\n\n``` python\nimport os, boxlite\n\nsecret = boxlite.Secret(\n    name=\"anthropic\", value=os.environ[\"ANTHROPIC_API_KEY\"], hosts=[\"api.anthropic.com\"]\n)\nnet = boxlite.NetworkSpec(mode=\"enabled\", allow_net=[\"api.anthropic.com\"])\nasync with boxlite.SimpleBox(\n    image=\"python:slim\", network=net, secrets=[secret],\n    volumes=[(\"/path/to/repo\", \"/workspace\", False)],\n    env=[(\"ANTHROPIC_API_KEY\", \"<BOXLITE_SECRET:anthropic>\")],\n) as box:\n    res = await box.exec(\"sh\", \"-c\", \"echo $ANTHROPIC_API_KEY\")\n    print(res.stdout)  # Prints only the placeholder <BOXLITE_SECRET:anthropic>\n```\n\nTo invoke the Claude Code CLI inside an isolated microVM, BoxLite provides `SkillBox` (see `examples/python/06_ai_agents/use_skillbox.py` in the repo, and set `CLAUDE_CODE_OAUTH_TOKEN` first):\n\n``` python\nimport asyncio, boxlite\n\nasync def main():\n    async with boxlite.SkillBox(skills=[\"anthropics/skills\"]) as box:\n        reply = await box.call(\"Investigate the failing tests in the current directory and propose a fix\")\n        print(reply)\n\nasyncio.run(main())\n```\n\nFor a persistent agent gateway like OpenClaw, `examples/python/06_ai_agents/run_openclaw.py` shows how to isolate it with `SyncBoxlite`. It runs `ghcr.io/openclaw/openclaw:main`, maps only port `18789` and a dedicated config directory, and leaves the host home directory unmounted.\n\nOnce BoxLite caches the image locally, it boots in seconds, close to `docker run`. Inside a coding-agent loop where every model response takes several seconds, that startup time barely registers, and you don't have to keep Docker Desktop in memory all day.\n\nThe only host requirement is hardware virtualization: Apple Silicon macOS 12 and later, Linux with `/dev/kvm`, or Windows WSL2 with KVM enabled.\n\nBefore turning on auto-approval for a coding agent, isolate the kernel, filesystem, network egress, and credentials in hardware virtualization and a host-side proxy. Don't rely on a prompt reminding the model not to wipe your disk.", "url": "https://wpnews.pro/news/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode", "canonical_source": "https://blog.boxlite.ai/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode", "published_at": "2026-12-03 03:45:46.257981+00:00", "updated_at": "2026-12-03 03:45:49.438553+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["BoxLite", "Claude Code", "OpenClaw", "libkrun", "Hypervisor.framework", "KVM", "Docker", "ShimController"], "also_reported_by": [], "takeaway": "Run coding agents in BoxLite microVMs, which boot each Box via libkrun on Hypervisor.framework or KVM behind a host-side OS jailer, an allow_net egress allowlist and a Secret proxy, so a destructive command only destroys a disposable microVM disk rather than host files and keys.", "recommendation": {"advice": "Run coding agents in a BoxLite microVM with an egress allowlist and host-side Secret proxy instead of YOLO mode, so prompt injection or a runaway rm -rf only destroys a disposable VM disk, not host files or keys.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode", "markdown": "https://wpnews.pro/news/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode.md", "text": "https://wpnews.pro/news/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode.txt", "jsonld": "https://wpnews.pro/news/run-a-coding-agent-in-a-microvm-before-enabling-yolo-mode.jsonld"}}