Overview
Every secure-exec sandbox has three layers: a runtime (public API), a bridge (isolation boundary), and a system driver (host capabilities). User code runs inside the sandbox and can only reach host capabilities through the bridge. The bridge enforces payload size limits on every transfer. The system driver wraps each capability in a permission check before executing it on the host.Components
Runtime
The public API.NodeRuntime is a thin facade that accepts a system driver, then delegates all execution to the isolate.
System Driver
A config object that bundles host capabilities. Deny-by-default.| Capability | What it provides |
|---|---|
filesystem | Read/write/stat/mkdir operations |
network | fetch, DNS, HTTP |
commandExecutor | Child process spawning |
permissions | Per-capability allow/deny checks |
Bridge
The narrow interface between the sandbox and the host. All privileged operations pass through the bridge. It serializes requests, enforces payload size limits, and routes calls to the appropriate system driver capability.Node Runtime
On Node, the sandbox is a V8 isolate managed byisolated-vm.
Inside the isolate:
- User code runs as CJS or ESM (auto-detected from
package.jsontypefield) - Bridge globals are injected as
ivm.Referencecallbacks for fs, network, child_process, crypto, and timers - Compiled modules are cached per isolate
Date.now()andperformance.now()return frozen values by default (timing mitigation)SharedArrayBufferis unavailable in freeze mode
- The V8 isolate execution environment creates contexts, compiles modules, and manages the isolate lifecycle
ModuleAccessFileSystemoverlays hostnode_modulesat/app/node_modules(read-only, blocks.nodenative addons, prevents symlink escapes)- System driver applies permission checks before every host operation
- Bridge enforces payload size limits on all transfers (
ERR_SANDBOX_PAYLOAD_TOO_LARGE)
memoryLimit: V8 isolate memory cap (default 128 MB)cpuTimeLimitMs: CPU time budget (exit code 124 on exceeded)timingMitigation:"freeze"(default) or"off"
Browser Runtime
In the browser, the sandbox is a Web Worker. Inside the worker:- User code runs as transformed CJS/ESM
- Bridge globals are initialized from the worker init payload
- Filesystem and network use permission-aware adapters
- DNS operations return deterministic
ENOSYSerrors
- The browser isolate spawns workers, dispatches requests by ID, and correlates responses
createBrowserDriver()configures OPFS or in-memory filesystem and fetch-based networking- Node-only runtime options (like
memoryLimit) are validated and rejected at creation time