Skip to content

docs: add boxd sandbox guide - #1277

Merged
theoephraim merged 2 commits into
dmno-dev:mainfrom
MichielMAnalytics:boxd-sandbox-guide
Nov 17, 2026
Merged

theoephraim merged 2 commits into
dmno-dev:mainfrom
MichielMAnalytics:boxd-sandbox-guide

Conversation

@MichielMAnalytics

@MichielMAnalytics MichielMAnalytics commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

boxd × Varlock

Summary

I work on boxd. boxd runs full Linux microVMs (KVM) with a persistent disk that start in about a second, and can be hibernated, snapshotted and forked. This adds a boxd guide to the cloud sandbox recipes, next to Boat, E2B, Fly.io and Modal, and lists it in the sandboxes overview and the sidebar. Docs only, no code changes.

The guide follows the Boat guide's shape:

  • Passing resolved values: values go in through the machine spec's env (plus the __VARLOCK_ENV blob variant from the E2B/Modal guides).
  • Broker machine: one isolated machine runs varlock proxy start --expose, its HTTPS domain carries the tunnel, and agent machines run varlock proxy run --url. The agent's egress allowlist is then pinned to the broker host, which boxd enforces outside the VM.
  • Egress and trust model, cleanup, other topologies, and a short note comparing the proxy with boxd's own host-bound secrets.

How it maps onto the sandbox recipe

Recipe step boxd
Create a sandbox with env boxd.machines.create({ spec: Machine.spec().isolated().env({...}), deleteAfter })
Run a command boxd.machines.exec(id, { command })
Upload the schema boxd.machines.fs.write(id, path, contents)
Public URL for the tunnel the machine's HTTPS domain, proxies.setPort(id, 8080)
Lock agent egress boxd.machines.setEgressAllow(agentId, [brokerHost])
TTL if the orchestrator dies deleteAfter (seconds)
Cleanup boxd.machines.delete(id)

Where boxd does not map cleanly

  1. Env goes through the spec. The guide sets env with Machine.spec().env(...). The values are kept in the machine's spec and can be read back through the API by whoever can read the machine; the guide says so.
  2. Bot protection has to be off on the broker. The default browser check answers the tunnel's WebSocket upgrade, so proxy run --url fails with "tunnel handshake failed". The guide calls setBotProtection(brokerId, 'off'); the data-plane token is what gates the tunnel.
  3. Agents must be isolated. A non-isolated boxd machine has an in-VM boxd CLI acting as the owner, so an agent could exec into the broker and read its env. The guide uses isolated() for both machines and explains why.
  4. Clamp after install. Like Modal, the allowlist is set after varlock is installed. The guide also shows the snapshot route (Machine.spec().from(snapshot(...)).egress(brokerHost)) for an allowlist from the first command.
  5. Exec has no detached mode. The broker is started with setsid nohup ... & inside a normal exec.
  6. Account env vars and secrets still reach isolated machines. The org's env vars and secrets whose scope covers a machine reach its exec and SSH sessions, isolated or not, and the spec's env only adds to them. The guide says to create agents where no such value holds anything an agent should not have, and to keep credentials as unattached secrets.
  7. Host-bound secrets widen the allowlist. boxd always admits a host-bound secret's hosts on top of the egress allowlist, so the guide says to keep host-bound secrets off agent machines that should only reach the broker.

Test plan

Points 6 and 7 came from the automated review and are now in the guide's trust model section (the website builds with them). Checked again on 2026-11-08, with the branch still on the current main (79fafc7): varlock 1.24.0 and @boxd-sh/sdk 0.3.0 are still the latest releases, and the broker example, run as written on Bun, printed Placeholder received in 6 s and deleted both machines.

The first full pass:

Everything below ran against real boxd (region fra) with varlock 1.24.0 (standalone binary in the machines, npm package in the orchestrator) and @boxd-sh/sdk 0.3.0, on Bun 1.4 and Node 24. For the live runs I extracted the code blocks from the .mdx and changed only two things: a machine name and an extra label, so our test machines are easy to find and clean up.

  • Broker example, as written: prints Placeholder received and deletes both machines. 3 runs (Bun, Bun, Node), all pass, about 6 s each.
  • Passing resolved values example: pass on Bun and Node. Negative check: the same code testing an unset var fails with Machine command failed.
  • Blob example: pass. In the machine, varlock run (CLI) and a Node app with varlock/auto-load both read API_KEY from __VARLOCK_ENV in an empty directory.
  • Extra checks on the broker setup (12/12 pass): isolated broker has no boxd CLI; the agent's direct HTTPS to example.com fails within 66 ms of setEgressAllow and DNS for it is refused; placeholder delivered through the clamp; a curl request to an echo API through the broker gets the key injected (audit shows injected=API_KEY) and the response the agent sees is scrubbed; Node fetch goes through the broker; a host without a rule is blocked by strict egress (blocked-egress in the audit); a wrong token is refused; after the broker is hibernated, the agent's next proxy run --url wakes it and works (265 ms).
  • Bot protection: with the default setting, proxy run --url fails with "tunnel handshake failed"; with it off it works.
  • Snapshot route (5/5 pass): agent created from a snapshot of an isolated machine with varlock installed has the allowlist from its first command, stays isolated, and gets the placeholder from the broker.
  • A real agent: Claude Code (claude -p) in an agent machine pinned to the broker, with ANTHROPIC_API_KEY held only by the broker (@proxy(domain="api.anthropic.com")), answered correctly.
  • Errors: missing BOXD_API_KEY throws Set BOXD_API_KEY and API_KEY; a bad key throws AuthenticationError: API key not recognized.
  • Repo checks: bunx turbo run build --filter=@varlock/website builds (138 pages, the new page and overview card render, I checked a screenshot), all internal anchors on the page resolve, eslint . is clean, and the pre-push hooks (branch name, frozen lockfile, typecheck:all, bumpy) pass. No bump file, since only docs changed.

All test machines were deleted after each run.

Links

Add boxd to the cloud sandbox guides, overview, and sidebar. Cover passing resolved values through the machine spec and running a broker machine over its HTTPS domain, with agent machines pinned to the broker by boxd's egress allowlist.
@MichielMAnalytics
MichielMAnalytics marked this pull request as ready for review November 8, 2026 21:16

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

The recipe can expose inherited credentials to agents, and host-bound secrets can bypass its broker-only network policy. These security preconditions need to be documented before merging.

Reviewed changes: Reviewed the boxd sandbox guide and its navigation entries, including executable examples and provider security contracts.

  • Environment handoff: Adds resolved-value and filtered blob examples using machine specs.
  • Credential broker: Documents isolated broker/agent provisioning, authenticated tunneling, egress restrictions, lifecycle management, and host-bound secrets.
  • Navigation: Adds the guide to the sandboxes overview and sidebar.

Website build and all 20 internal links/anchors passed; live cloud examples were not rerun.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

Isolated boxd machines still get the org's env vars and secrets whose scope covers them in exec and SSH sessions, and the hosts of a host-bound secret are admitted on top of the egress allowlist. Say so in the trust model, and qualify the broker-only claims.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes: Reviewed the security guidance added since the previous review, verified the provider contracts, and resolved both addressed threads. The website build and new internal anchor passed.

  • Documented environment inheritance: Explained that isolated agents still receive scoped values and must have no inherited sensitive credentials.
  • Excluded host-bound secrets on agents: Explained their allowlist bypass and qualified broker-only confinement claims.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@theoephraim

Copy link
Copy Markdown
Member

thanks so much!

@theoephraim
theoephraim merged commit 658da7e into dmno-dev:main Nov 17, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants