ventgrisdocs

Workspace tools

Sandboxes

Run untrusted code in an isolated gVisor sandbox with no workspace, no secret and no network unless granted. Images, limits, mounts, networks and vg sandbox.

View .md

A sandbox is an isolated environment where the agent runs code it does not trust: a script found on the web, a cloned repository, a package nobody checked. Code in a sandbox does not see the workspace, the vault or the internal network, and cannot exhaust the machine. Nothing is mounted and no network is open unless the command asks for it. The Sandboxes screen shows what runs now, what ran in the last seven days, and the images sandboxes start from.

Which plans include sandboxes

Plan Sandboxes
Solo not included
Pro included
Team included
Scale included

See Plans and billing. How many sandboxes run at once depends on the size of the machine (below).

How a sandbox is isolated

Each sandbox runs under gVisor (runsc, platform systrap): a kernel in user space between the code and the machine. The code talks to gVisor, not to the kernel of the host. It is stronger than a container and weaker than a virtual machine.

Boundary What the code inside gets
Files An empty /work, a read-only image, a write layer of bounded size. Workspace folders only if mounted
Secrets None. The vault is not reachable
Network Loopback only by default. Otherwise only the egress proxy, with the policy of the sandbox
Resources A memory cap, a CPU cap, a process cap, a disk cap and a time limit
Other sandboxes Not reachable. Two sandboxes cannot talk to each other

A sandbox is created by a small root service of the machine from closed lists (image, limits, mounts, network policy). It refuses any mount outside the workspace or the volumes folder, any mount of the harness configuration folders (.claude, .codex, .ssh, .config), and any path that goes through a symbolic link.

What gVisor does not cover: a flaw in gVisor itself, side-channel attacks between processes on a shared processor, and programs that need a rare system call or a kernel module. System calls cost more: an npm install or a compilation runs about 1.2 to 2 times slower than outside a sandbox. Pure computation is not slowed down.

Read the Sandboxes screen

The header facts

Fact Meaning
Driver gvisor and the tag ready, or none and unavailable
Runtime The gVisor version and its platform, when the driver is ready
KVM present or absent on this machine. Only informative: the driver in use is gVisor
Tier The size class of the machine (see System)
Running at once N of MAX, with N waiting when sandboxes are queued
Memory budget Memory used by running work out of the budget, in MB
Default memory The memory a sandbox gets when it asks for nothing

Click Refresh to read the state again. The screen also updates by itself when a sandbox starts, stops or ends, and every 5 seconds while one runs.

When sandboxes cannot run

If the driver is unavailable, a card says Sandboxes cannot run on this machine right now, followed by the reason and this sentence: "Every request to start one is refused with a clear error. Nothing is run outside a sandbox instead." The message under Reported by the server: gives the detail. The most common reasons:

Reason shown What it means
This machine has less than 3 GB of memory Sandboxes start at the small tier
The sandbox helper (vg-sandboxd) does not answer The root service that creates sandboxes is not running
gVisor is not installed runsc is missing on the machine
The sandbox helper is an older or newer version than this service The two parts must run the same build

On a workspace of the service these are faults of the machine, not settings you change. Contact support if the card stays.

Running now

One row per live sandbox:

Column Content
Sandbox The image, a short id, the command, and N mounted (hover to see each mount and whether it is read-only or writable)
Owner The session (or app) the sandbox belongs to
State queued (with place N in the queue), starting, running, frozen, stopped, ended or failed. N command(s) running when several commands run in it
Started How long ago, and ends in ... for a running sandbox
Memory USED of LIMIT MB while it runs, otherwise limit LIMIT MB
CPU Percent of one core. measuring on the first reading
Network none, allowlist (with its hosts), packages or web

Actions in the row:

  • the eye icon (Output) shows the end of the output of its commands. Only the last part is kept (1 MB); the panel then says "Only the end is kept.";
  • Stop, on a running or frozen sandbox. It asks "Stop this sandbox? Its commands are killed. Its output stays readable for a few minutes." A stopped sandbox keeps its output for 10 minutes;
  • Remove, on a stopped sandbox. It asks "Remove this sandbox and what it wrote?"

When nothing runs, the card says No sandbox is running: "The agent starts one with vg sandbox run, and it disappears when the command ends."

Last 7 days

Every sandbox of the last seven days: When, Image, Owner, Command (or kept open for several commands), Exit code (green for 0, red otherwise), Duration, Waited (time in the queue) and Ended by.

Ended by Meaning
the command ended A one-shot run finished
removed Removed by its owner or from the screen
stopped by hand Stopped from the screen
time limit Reached its time limit
idle No command used it for 15 minutes
command timeout The command passed its own --timeout
image not built The image asked for is not built
mount refused A mount was not allowed
mount source missing The folder to mount does not exist
daemon restart, lost by the helper, no slot after a restart The machine restarted while it ran

Images

A sandbox starts from an image: a read-only root file system pinned by its digest. The table lists Name, Source (the base image and a digest, or from NAME), State (built, not built or building) and Built (date).

Image Content Use
base Debian, bash, curl, git, jq, ca-certificates shell scripts. The default
python Python, uv, requests, pandas, pillow, and the tools of base scripts, data analysis
node Node.js, Bun, and the tools of base scripts, JavaScript projects
browser Chromium used by the shared browser, not for your commands

Build (or Rebuild) builds an image from its pinned definition. It asks "Build the image “NAME” now? It downloads and unpacks its base, which can take several minutes." A toast says when it is built or when it failed; a failure stays under the image as The last build failed: ....

Run a command in a sandbox

The agent starts sandboxes from its session with vg sandbox. The output and exit status of the command are those of the command itself.

# A throwaway sandbox: created, runs one command, removed
vg sandbox run --image python --mount projects/data -- python /work/data/analyse.py

# With access to package repositories
vg sandbox run --image python --network packages -- sh -c "pip install polars && python x.py"

run waits for a free slot if the machine is busy. Add --no-wait to fail at once instead (error sandbox.busy).

Keep a sandbox for several commands

SB=$(vg sandbox create --image node --network packages --ttl 2h)
vg sandbox exec $SB -- npm install
vg sandbox exec $SB -- npm test
vg sandbox cp $SB:/work/report.html ./report.html
vg sandbox rm $SB

create prints the id (sbx_...). A kept sandbox stops after 15 minutes without a command, or at its --ttl.

vg sandbox commands

Command What it does
vg sandbox run [flags] -- COMMAND... Run one command in a throwaway sandbox. Extra flags: --cwd DIR, --timeout D
vg sandbox create [flags] Start a sandbox that stays; prints its id
vg sandbox exec ID [--tty] [--cwd DIR] [--env K=V] [--timeout D] -- COMMAND... Run a command in an existing sandbox
vg sandbox shell [ID | flags] An interactive shell, in an existing sandbox or a throwaway one
vg sandbox cp ID:/path FILE or vg sandbox cp FILE ID:/path Copy a file out of or into a sandbox. --tar copies a folder as a tar archive
vg sandbox rm ID... Stop and destroy sandboxes
vg sandbox list [--all] (or ls) The sandboxes that exist; --all adds the last 7 days
vg sandbox logs ID [--tail BYTES] The end of the output of its commands
vg sandbox image list The images: defined, built

Flags that describe a sandbox

Used by run, create and shell:

Flag Default Meaning
--image NAME base base, python or node
--network POLICY none none, packages, allowlist or web
--host HOST A host of the allowlist. Repeat it or give a comma list. Implies --network allowlist
--mount DIR[:DST][:rw] A workspace folder. Read-only unless :rw. Without DST it appears at /work/<folder name>
--volume NAME[:DST] A persistent writable volume, at /data unless DST says otherwise
--env K=V An environment variable. Repeatable
--user root|agent root, or agent with a writable mount The user inside the sandbox. With a writable mount, only agent is allowed
--read-only off Make the root file system read-only
--memory SIZE tier default 384, 384m or 2g
--cpus N 1 CPU cores
--pids N 256 Processes
--disk SIZE 2 GB Size of the write layer
--ttl D 30 min Longest life of the sandbox
--no-wait off Fail at once if no slot is free

Limits

Resource Default Maximum
Memory tier default (384 MB on small, 512 MB on medium and large, 1 GB on xlarge) 4 GB, and never more than the memory budget
CPU 1 core 4 cores, and never more than the machine has
Processes 256 1 024
Write disk 2 GB 20 GB
Duration 30 min 6 h
Idle stop of a kept sandbox 15 min
One copy with vg sandbox cp 256 MB
Output kept per sandbox 1 MB (the end)

Over its memory limit, a sandbox is killed. Asking for more than a maximum fails with sandbox.limit.

Sandboxes at once

Tier Sandboxes at once
tiny (under 3 GB of memory) none
small 1
medium 3
large 6
xlarge 12

Before a sandbox starts, the resource governor checks that its memory fits in the budget beside the session turns, terminals and other sandboxes. If it does not fit, the sandbox waits in the queue (state queued) instead of risking an out-of-memory kill. Under memory pressure, the governor can freeze a running sandbox (state frozen); it keeps its state and resumes when pressure drops.

On a small machine one sandbox runs at a time, and a running shared browser takes that slot: a sandbox asked for by a session waits until the browser stops (it stops after 10 minutes idle).

When the disk is 90 % full, new sandboxes are refused (sandbox.disk_full). At 80 %, the write layers of stopped sandboxes are cleaned up.

Mounts

Nothing is mounted by default. A sandbox starts with an empty /work.

  • --mount projects/data gives /work/data, read-only.
  • --mount projects/data:/work/in puts it at /work/in.
  • --mount projects/out:rw makes it writable. The commands then run as the user agent, so what they write belongs to the workspace user.

A mount must be a folder inside the workspace. A target goes under /work, /mnt or /data. A refused mount ends the sandbox with mount refused; a folder that does not exist ends it with mount source missing.

Mount only what the code needs. A writable mount lets untrusted code change or delete those files.

Network

Policy Effect
none No interface besides loopback. The default
packages Package repositories only: deb.debian.org, security.debian.org, archive.ubuntu.com, security.ubuntu.com, ports.ubuntu.com, pypi.org, files.pythonhosted.org, registry.npmjs.org, proxy.golang.org, sum.golang.org, github.com, codeload.github.com, objects.githubusercontent.com, raw.githubusercontent.com
allowlist Only the hosts given with --host. *.example.com matches any subdomain, not example.com itself
web Any public host

Every policy other than none goes through the egress proxy of the machine, on ports 80 and 443. The proxy resolves names itself and refuses private, loopback, link-local, tailnet and cloud metadata addresses after resolution, so a name that points to an internal address is refused too. The workspace API is not reachable from a sandbox. The proxy logs the sandbox, the host and the byte counts, never a path, a header or a body.

Run any code that does not come from the workspace (a downloaded script, a cloned repository, a package you have not checked) with vg sandbox run, never directly in your session. Use --network none unless the code needs the network; prefer packages to web, and allowlist with the exact hosts when you know them. Mount only the folders the code needs, read-only unless it must write; bring results back with vg sandbox cp or a :rw output folder. Remove kept sandboxes with vg sandbox rm when you are done. If a sandbox is refused (sandbox.unavailable, sandbox.no_driver), do not run the code outside a sandbox: report it.

Errors

Code Meaning
sandbox.no_driver No sandbox runtime on this machine
sandbox.unavailable The tier of the machine has no sandbox
sandbox.image_missing The image is not built
sandbox.busy --no-wait and no slot free
sandbox.limit Over a maximum
sandbox.disk_full The disk is 90 % full
sandbox.forbidden A mount or a sandbox the caller may not use
sandbox.timeout The command was killed at its time limit
sandbox.killed The sandbox died: over its memory limit, or its runtime ended
sandbox.too_large A copy over 256 MB

Who can do what

Action Roles
See the Sandboxes screen every role
Stop, remove a sandbox, build an image admin, editor

A session only sees and acts on its own sandboxes. Starting a sandbox needs no human approval: it runs within the tier count and the memory budget.