01 / DECISION
When this primitive earns a place
Use Sandboxes when untrusted or generated code needs an isolated Linux execution environment and a Worker must control the boundary; Dynamic Workers are the lighter option when the code only needs JavaScript, Python, or WebAssembly.
02 / ARCHITECTURE
Build the smallest defensible path
Allocate one sandbox per trust boundary, use explicit sessions, allowlist commands and egress, set resource and time limits, proxy secrets outside, and destroy on completion.
- 01Name the contract
Use Sandboxes when untrusted or generated code needs an isolated Linux execution environment and a Worker must control the boundary; Dynamic Workers are the lighter option when the code only needs JavaScript, Python, or WebAssembly.
- 02Add one primitive
Allocate one sandbox per trust boundary, use explicit sessions, allowlist commands and egress, set resource and time limits, proxy secrets outside, and destroy on completion.
- 03Capture failure evidence
Reject a forbidden command and destination, enforce timeout and cleanup, verify session separation, and confirm no secret enters the sandbox.
03 / REPRODUCE
Evidence before confidence
Reject a forbidden command and destination, enforce timeout and cleanup, verify session separation, and confirm no secret enters the sandbox.
npm create cloudflare@latest -- sandbox-linux --category=hello-world --type=hello-world --lang=ts --no-deploy --no-git --no-agents 04 / BOUNDARY
The production boundary
Isolation is not permission to run arbitrary user intent. Sandbox SDK 1.0 moves control into a Durable Object class you write, and the move to the Durable Object scheduling policy cannot be undone by a rollback, so rehearse it on a staging Worker. Keep browser automation in Browser Run.
05 / FIRST-PARTY SOURCES
Keep first-party sources authoritative
Product behavior, limits, pricing, and availability can change. Re-check these sources before acting.