Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The sandbox, and going away

Every bash and exec call runs in a sandbox by default — a direct call, one from a script, and one from a child session — in every mode, --approve-all included, unless you approve one of the two ways out (below; under escape = "judge" the judge may allow the second). The one exception is a command you type yourself with ! (below). In auto the judge (modes.md) still judges every command; the sandbox contains what it misses.

The backend is bubblewrap on Linux (Windows through WSL2) and Seatbelt on macOS 15.4 or later (“Requirements”, below). A machine that is itself the sandbox — a dedicated VM, a container, a CI runner — can say so with mode = "external" (“External mode”, below).

What it does

  • Reads everywhere except the hidden list (below). A hidden path reads as empty on Linux. On macOS it fails with Operation not permitted and cannot be run.
  • Writes only to the project, a private temp folder, and [sandbox] writable paths. On Linux the temp folder is /tmp. On macOS it is $TMPDIR, /tmp is not writable, and the user’s temp folder (/var/folders/…/T, used by a bare mktemp) is writable except Apple’s com.apple.* entries.
  • Untracked protected files are read-only, even in the project (below).
  • Network. On Linux, only localhost within the same command: no other session’s or the machine’s services, no internet. On macOS, none, not even 127.0.0.1: any port needs network: true (“The two ways out”, below).
  • No local sockets: no ssh-agent, gpg-agent, D-Bus, Docker or tmux. Python’s default multiprocessing needs a full escape on Linux; on macOS only a Manager fails.
  • No credentials. Every provider’s key variable, and anything named *TOKEN*, *SECRET*, *_KEY, *CREDENTIAL*, *PASSWORD*, *PASSWD*, *_PASS, *_AUTH, *_AUTH_*, *COOKIE*, AWS_*, SSH_AUTH_SOCK or GPG_AGENT_INFO, or whose value is a URL with a password, is stripped from the environment. [sandbox] env_hide adds names.
  • A private process view. Other processes are invisible. A command’s background processes end with it, unless the command itself runs in the background (below). On Linux there is no terminal to read from. On macOS ps cannot run, and only a terminal the command opens itself is usable.

The hidden list is ~/.ssh, ~/.gnupg, ~/.aws, ~/.azure, ~/.config/gcloud, ~/.config/gh, ~/.config/hub, ~/.docker, ~/.kube, ~/.netrc, ~/.git-credentials, ~/.npmrc, ~/.pypirc, ~/.gem/credentials, ~/.terraform.d/credentials.tfrc.json, ~/.vault-token, ~/.password-store, ~/.local/share/keyrings, ~/.secrets, ~/.cargo/credentials*, ~/.bash_history, ~/.zsh_history, ~/.claude/ (except the read-only carve-outs below), ~/.claude.json, ~/.codex/, the harness’s own config root, and its sessions/ and checkpoints/ folders under the data root ($DATA/sessions/, $DATA/checkpoints/). [sandbox] hide adds paths: ~, ~/… or absolute ones, and project paths (below). A symlink is hidden with its target (~/.ssh -> ~/dotfiles/ssh). For the ~ and absolute entries, Linux covers paths that exist at session start; macOS also covers ones created later. A ~/.cargo/credentials* file is hidden only if it exists at session start. Project entries are looked up at every spawn, on both. macOS adds ~/Library/Keychains, ~/Library/Cookies, ~/Library/HTTPStorages, ~/Library/Accounts, ~/Library/Group Containers, ~/Library/Containers, ~/Library/Mail, ~/Library/Messages, ~/Library/Safari, the profile folders of Chrome, Chromium, Firefox, Edge, Brave, Arc, Vivaldi and Opera under ~/Library/Application Support, and ~/.zsh_sessions.

With HARNESS_HOME set, the list (minus the macOS additions) also applies inside it. If it is the project, commands cannot see the project’s own .npmrc, .claude/ or .docker/. An entry that holds the project or its git folder stays visible, and the start-up notice names it. The exception is a Windows Users folder under WSL2: a project inside one makes the sandbox unavailable instead (“Windows (WSL2)”, below). mode = "external" and "off" hide nothing from commands, and neither does a command you type with ! (below).

Project paths in [sandbox] hide. An entry that does not start with ~ or / is relative to the project: .env, secrets/ (a trailing / matches a folder only), config/*.key (* in the last part only; no **). The syntax and its load errors are in config.md. There is no default list: a project file is hidden only if you name it.

  • Looked up at the start of each sandboxed command (bash, exec, foreground or background, a sandboxed hook, a sandboxed MCP server’s start), with no walk of the project: a literal entry is one lookup, and an entry with * lists its parent folder once. A file the command itself creates is hidden from the next command, not from that one.
  • Hidden where it lies: every link on the way is followed, so what is hidden is the path on disk, in the disk’s spelling. A match outside the project is hidden there; a match that is the project, a folder above it or / is skipped. A path with a .git component never matches. A match found through a link stays hidden for the rest of the session after a command removes the link, for as long as the target exists (the harness remembers up to 1,000 such targets; nothing is recorded). On Linux the folders between the project and a hidden match are bound in place for the command, so it cannot rename one of them to move the match out from under its mount (Seatbelt denies the same renames).
  • How it looks. On Linux a hidden file reads as empty and a write to it vanishes; a hidden folder is an empty one. On macOS reads and writes fail with Operation not permitted. A sandboxed command that names a hidden path, or prints it, gets a note so the model does not mistake an empty .env for the real one: `.env` is hidden from commands by the user's [sandbox] hide, so it reads as empty here; ask the user if the task needs it. (macOS: so it cannot be read here; several paths read `.env`, `secrets` are hidden …).
  • The file tools refuse a hidden path too, in every mode and sandbox state (below).
  • Bounds. At most 1,000 matches per command, beside the 1,000 credential files a network: true command hides. Past that the command is not run: [sandbox] hide matches more than 1000 paths in the project, so the command was not run; hide their folder instead. A folder that cannot be read refuses it too ([sandbox] hide: <path> could not be checked (<error>), so the command was not run. Fix that path's permissions.). On Linux, bubblewrap’s 9,000 arguments can refuse a command near both bounds. On macOS each match uses part of Seatbelt’s 1,000-filter budget (below), so a few hundred matches can reach the budget refusal first, and that refusal speaks of credential files: hide a folder, not each file in it.
  • Not covered: a path made during a command (hidden from the next one); a hard link made before; a copy under another name; committed content (git show HEAD:.env); commands under off and external; and a host hook (sandbox = false). A sandboxed hook, a Stop hook included, sees hidden paths hidden, so a test suite that loads a hidden .env fails there: set sandbox = false for that hook (it then runs from /, so cd "$(jq -r .cwd)" first, and it runs code the agent can write on your machine: hooks), or do not hide the file.

Session logs are always hidden, so harness export does not work in a sandboxed command; if the project holds sessions/ or checkpoints/, sandboxed commands are refused. The harness’s other data, state and cache are read-only to commands.

The protected list (modes.md, “Protected files”) applies here too, except **/ patterns such as **/build.rs. An untracked protected file is read-only to commands, however the write is spelled. A protected directory with nothing tracked is read-only whole. One with tracked files is judged file by file, and anything a command adds is moved aside (below); past 1,000 entries it is read-only whole. A file counts as tracked only if it was tracked at session start (or last resume) and still is, so staging it does not unlock it. With no repository, nothing is tracked. .claude/worktrees/ stays writable.

A tracked protected file — CLAUDE.md, a workflow, .cargo/config.toml — is writable, so a sandboxed git checkout completes. Commands can write .git, so to review such changes, note the commit hash and the ignored files before the work, outside the project:

S=$(git rev-parse HEAD); B=$(mktemp)
git ls-files --others --ignored --exclude-standard > "$B"

After it, review from a fresh index built from that commit:

git --no-replace-objects for-each-ref refs/replace    # a line you didn't make: stop here
T=$(mktemp); r() { GIT_INDEX_FILE=$T git --no-replace-objects "$@"; }
r read-tree "$S"
r diff --stat                 # each tracked file changed; drop --stat to read the changes
r ls-files --others --exclude-standard                              # files added
r ls-files --others --ignored --exclude-standard | grep -vxFf "$B"  # added, but ignored

This defeats tricks that make git status look clean, and the last list catches files hidden by a new ignore rule. It is not a proof: a change to an existing ignored file (in .venv/, say) shows nowhere, and submodules have their own index. Checkpoints (checkpoints.md) do not rely on the index.

A protected path a command creates — a new .envrc or .vscode/, a new file in a .claude/ with tracked files, a re-pointed protected link, or a tracked file replaced by another kind of file — is moved aside afterwards, never deleted, even if git now tracks it. It goes to <name>.harness-quarantined-<16 hex digits>, beside it, or at the project root if it was inside a protected directory. Links are moved, never followed. A note says what moved where; to keep it, write it with the file tools, which ask. If the move fails, later sandboxed commands are refused, naming the path, until it moves or you move it on the host.

A new .claude/ that holds only worktrees/ is kept, so git worktree add .claude/worktrees/<name> works. If a .claude/ with nothing tracked has no worktrees/ yet, that command fails: create the directory with the file tools, or run the command with approval.

A protected link to the project or a folder above it (.claude -> ., .vscode -> ..) refuses every sandboxed command, naming the link, until you replace it on the host. So does a protected link whose target needs more mounts than bubblewrap allows: replace it or shorten the target’s path.

A directory a command makes unreadable (chmod 000) becomes read-only; the result says to check it before restoring its permissions. An unsearchable project root (chmod 600) refuses every sandboxed command until you restore it on the host.

Git’s auto-run files are read-only, even when committed: .git/hooks/, .git/config, .git/config.worktree, worktree and submodule copies, your global and system git config, and whatever those name (core.hooksPath, core.fsmonitor, include/includeIf files, a hook’s linked script). If a command re-points or removes a symlink on the way to one, you’re told to restore it before your next git command.

A git checkout of a branch whose hooks differ therefore stops short. The model is told which files git could not update. After a checkout or switch it gets git checkout -- <those files> to finish outside the sandbox, which escape decides: ask asks you, judge has the judge decide it unless a local ask matches, never refuses it. After a merge, pull, reset --hard or stash pop, it is told to check git status. With escape = "never", it tells you which files are left.

A .git/commondir a command creates is moved aside. A hooks folder, include or git config file that did not exist at session start is not locked: creating one gets a note, so husky install keeps working.

Past 512 entries in .git/modules/ or .git/worktrees/, that folder is read-only whole, so a submodule update or git worktree add fails inside the sandbox. A command that would still need more binds than the system allows is refused, naming the folder: remove what you don’t need on the host, then resume.

On macOS these are path rules with the same effect, under a separate limit (“The budget”, below). Also:

  • A command cannot create the first missing folder above a hidden or read-only path, so making a missing .git/hooks fails (mkdir: .git/hooks: Operation not permitted).

  • Folders above protected paths cannot be renamed (“What you carry”, below).

  • A protected file with a second hard link refuses the command:

    denied: `.envrc` has another hard link, so a command could change it through that name. Fix on the host: remove the other link, or copy the file over itself (`cp -p .envrc x && mv x .envrc`).
    
  • An unsearchable folder on the way to a hidden or read-only path refuses the command, naming it and, if needed, the fix (chmod u+rwx on it).

Read-only carve-outs inside ~/.claude

After /migrate claude-code (config), the active skill folders and active plugin install roots it links are visible to a sandboxed command, read-only, and the rest of ~/.claude stays hidden. Agents, CLAUDE.md and rules/ are not exposed: harness reads them through Live::read_file, never a command.

  • Linux: bwrap binds each target with --ro-bind-try, with a nested --tmpfs re-hiding anything private inside it.
  • macOS: Seatbelt allows file-read* process-exec* on each target, plus file-read-metadata on a (literal ...) for ~/.claude and each intermediate directory between it and a carve-out, so the path resolves. Never path-ancestors, and never readdir or file reads in ~/.claude itself.
  • Never visible: settings.json, .credentials.json and history.jsonl (added to the private list).
  • Hard links: a regular file with nlink > 1 inside a carve-out refuses the whole carve-out folder: it is dropped, with every skill or plugin under it, and a startup notice or a /migrate skip says so. A link made to a private file would otherwise read through the carve-out.
  • Walk budget: the carve-outs share one walk of 10,000 entries (MAX_CARVE_OUT_ENTRIES); a carve-out that exceeds it is dropped with a notice.
  • Identity: each carve-out directory’s device and inode are checked before every spawn (carve_out_ids); one that changed is dropped from the view.
  • Not covered: a hard link made on the host after a command has started, and a rename inside the sub-millisecond window between that check and the spawn. A command you run outside the sandbox sees everything.

What it does not stop

  • Damage inside the project (git reset --hard, rm -rf src): that is the judge’s job. rm -rf (or --recursive --force) on a path with a .git component is refused in every mode.
  • Reading an in-project secret like .env with the file tools or a command (cat .env): the file tools ask first (except under --approve-all and in run --mock), and nothing in the sandbox stops a command from reading it; a command is left to the judge’s credentials reason (ADR-0118). Hide it in [sandbox] hide and the file tools refuse it in every mode, with no ask, and a sandboxed command sees it hidden.
  • Anything an approved full escape does.
  • What a network-only command reaches: project files and localhost services.
  • The removal ask (modes.md, “Local asks”) sees only named files in known forms. Globs, find -delete, xargs rm, sed -i, one-liners and scripts go to the judge.
  • Overwriting is not asked (cp other f, cat > f << EOF): that is an edit.
  • A touched-but-unchanged file reads as changed (touch, chmod, renamed back): an extra ask.
  • With no repository, every named delete or empty asks.
  • The decode-and-run ask is a text match. What it misses goes to the judge, still sandboxed.
  • Tracked protected files and build files are writable. Changes to CLAUDE.md, a workflow, build.rs, package.json scripts, conftest.py or a Makefile show only in the review above, and run the next time you build or test on the host. Review first.
  • A hard link made outside the sandbox to an untracked protected file lets a command change it through the other name. On macOS such a file refuses the command instead.
  • A protected directory on another filesystem keeps what a command creates in it, moved aside in place.
  • On Linux, a protected link into the private /tmp is not read-only.
  • A path the harness couldn’t move aside blocks commands only until the session ends. Move it on the host before resuming.
  • Concurrent children: a protected path one child creates can be moved aside by a sibling’s check.

Which tools it covers

Only the two that run programs.

ToolIn the sandbox?What limits it instead
bash, execyesthe sandbox
read_file, write_file, edit_file, glob, searchnothe project root; no links out; credential reads and protected writes ask; paths in [sandbox] hide are refused; the file tools open regular files only, and read none over 16 MiB (below)
scriptnoit acts only through the tools above
agentno, but the child’s own bash/exec arethe same rules, one level down
skillnoit only reads skill text; some loads ask

The file tools refuse a symlink out of the project, naming its target; a project CLAUDE.md or .agents/ file that links outside does not load. Reading a credential file asks first in every mode, with Asked because it reads a credential file, except under --approve-all and in run --mock. Credential files are .env/.env.* (not .env.example, .env.sample or .env.template), *.pem, *.key, *.p12, *.pfx, and anything in a .secrets folder in the project. The “this turn” choice reads except this kind: the next one asks again. search skips credential files and says how many (credential_files_skipped).

Hidden project paths. read_file, edit_file and write_file refuse a path that matches a project entry in [sandbox] hide, as written or, for a read or an edit, as the file actually opened (a link inside the project), and anything beneath a hidden folder: refused: .env is hidden by the user's [sandbox] hide; the file tools do not read or write it. The refusal comes before the credential ask for the path as written, and is never an ask. A link into a hidden path is refused when it is opened; the hide check there comes before the credential check too, so only a mode’s own ask can come first. The refusal holds in every mode, under --approve-all and in run --mock, and with the sandbox on, off, external or unavailable. search skips a hidden file and does not enter a hidden folder; each skipped file is counted in credential_files_skipped with the credential files (search leaves dot-files out unless asked, so a hidden .env is counted only when the search reaches it). A search based inside a hidden folder returns nothing; one whose path is a hidden file skips and counts it. glob lists names as before. A checkpoint never copies a hidden file and /undo never writes one; /undo’s preview lists a hidden file as a credential file.

The file tools read only regular files, up to 16 MiB. After the checks above, read_file, edit_file and write_file refuse:

  • a FIFO, a socket, a device or a folder (a read of a FIFO or a device can wait forever): refused: <path> is not a regular file; the file tools work only on regular files;
  • on Linux, a file in /proc or /sys, which matters when the project is at /, where read_file proc/self/environ would return the harness’s own environment: refused: <path> is in /proc or /sys; the file tools do not read there.

read_file and edit_file also refuse a file over 16 MiB, before reading any of it: refused: <path> is larger than 16 MiB; the file tools read files up to 16 MiB. write_file replaces a file of any size, since it keeps none of it. search skips a file over 16 MiB and says how many it skipped (large_files_skipped, shown only when above zero). bash and exec keep the first 1 MiB of each stream as before, and no longer hold the rest in memory while a command runs. A file that is a link out of the project, or a credential file, keeps its own refusal. A session recorded before 0.26.0 replays as it was recorded.

The two ways out

bash and exec take two more arguments, each with a reason shown to you and never sent to the judge.

  • network: true keeps the rest of the sandbox and adds network access. By default (when [sandbox.network] is absent), it adds the machine’s whole network — on macOS that includes any port on 127.0.0.1. When [sandbox.network] is configured (below), network: true commands route exclusively through the harness’s in-process host-allowlist proxy instead. It hides the project’s credential files and every .secrets folder, found fresh each time (unless [sandbox.network] credential_walk = false is set while proxied). On Linux a hidden .secrets reads empty and writes into it are discarded; macOS refuses them. A .pem up to 2 MiB holding only public certificates stays visible. .venv, node_modules, site-packages and __pycache__ are skipped. Past 1,000 files to hide or 100,000 entries to search, or at a directory or credential-named link it can’t read, the command is refused, naming the path: fix its permissions, drop network, configure [sandbox.network] with credential_walk = false, or use outside_sandbox. It does not stop git show HEAD:.env, credentials inside skipped folders (.git, target, .venv, node_modules, site-packages, __pycache__), or a renamed copy. It is judged in auto and asked in manual, and a grant for plain commands never covers it.
  • outside_sandbox: true runs the command as you, unconfined. By default, in auto with you present, the judge decides it as described below, and asks you the rest; in manual it asks. With escape = "ask" it always asks, in every mode. No “for this turn”/“for this session” option covers it. Unconfined (this way, or with the sandbox off or unavailable), if a process still holds the output two seconds after the command exits, the call returns. Processes in its group are ended; ones that left it (setsid, job control) keep running. The model sees [output cut: the command exited, but a process it started still holds its output].

[sandbox] escape = "never" removes both: nothing the model runs leaves the sandbox or reaches the internet. A ! command you type is not the model’s (below).

escape = "judge" sends a full escape to the judge (modes.md) instead of to you. The judge sees it only when all of these hold: the mode judges commands, you are not away, the breaker has not tripped for this task (below), no local ask matches, the command passes the planted-input and worktree-escape gates (u7), and either runs no file by path or runs 1–4 eligible in-project text scripts (≤64 KiB total, judged in two monotone stages under u7: Stage 1 on the command alone, then Stage 2 on the script contents only if Stage 1 allows). Allow runs it, with no approval prompt. A Stage 2 flag, unreadable/oversized script, or a judge that cannot be reached asks you directly with allow once or deny only. Everything else still asks you unjudged, as under ask: a mode that judges nothing (manual), an unmentioned worktree or dirty/modified build trigger, a script outside $PROJECT or over 64 KiB, a command whose text cannot be told apart (cat x.sh | bash), and a local ask. Wrappers it does not read through (xargs, timeout, nice, find -exec, watch, eval) are judged on their text (modes.md). While you are away it is refused. network: true is offered and judged as before. No grant covers a full escape, so allow for this turn never reaches one. The reason the agent gives is shown to you and never sent to the judge.

A wrong “yes” outside the sandbox has nothing behind it. Inside the sandbox the judge’s miss is contained; here it is not. The limits are the conditions above, a lower cutoff for escapes ([judge] escape_cutoff, modes.md), and this setting, which is on by default and which escape = "ask" turns off. Name the action and the place in an allow rule, and the host in a rule about a remote (modes.md).

Under --approve-all, network: true is approved automatically and outside_sandbox: true is refused, whether escape is ask or judge; the model is told to carry on and name the step in its final message. Child sessions inherit this. A conversation (--input-format stream-json) refuses outside_sandbox: true the same way unless --allow-escapes says a person answers the program’s requests (docs/headless.md, “Approvals”); with it, escape = "judge" holds as well.

Commands you type with !

A line you type that starts with ! (!git status) runs outside the sandbox, in every mode, under escape = "never", and with --approve-all and --away. The sandbox, escape and --approve-all limit what the model may run. You are not the model, and you could run the same line in another terminal. It is the only command that runs outside the sandbox with no approval.

  • Environment. The harness’s own, with every provider’s key removed. Credentials (GH_TOKEN, AWS_*, SSH_AUTH_SOCK) stay, and nothing [sandbox] hide lists is hidden: neither a path under your home folder nor a project path such as .env. !cat .env prints the file, and the next bullet sends it to the model.
  • No approval, judge, hard-deny rule or hook. The model’s bash stays sandboxed in the same session.
  • Output goes to the model. The command and its output are recorded and sent with your next message, so a secret you print with ! reaches the model’s provider.
  • [sandbox] hide does not apply. A ! command, like a command approved to leave the sandbox, reads hidden project paths. !cat .env prints the file, and the output reaches the model with your next message.
  • A git redirect file it creates is left alone. No watch runs after a ! command. The next model command’s watch moves the file aside, with a note.
  • It can be refused while an earlier sandboxed command’s sweep is unclean (below). It is recorded with the error, and the model is told.

Away

/away (panel or plain REPL) says you’re not watching: until the current task ends if typed mid-task, or from the next task if typed while idle. The plain REPL reads it only between tasks. Type /away again to come back. harness run --away --prompt "…" does the same for a scripted run; it needs --prompt and starts in auto unless --mode says otherwise. Both are refused under --approve-all and in a mode where every command asks.

While you’re away, anything that would ask you is refused (an unreachable judge and a child’s ask included), and the model is told to keep going. Under escape = "judge" a command outside the sandbox is never judged while you are away: it is refused, as under ask. If you type /away while the judge is still weighing one, and the judge allows it, the command is refused too. A network-only command is judged at the away cutoff ([judge] away_cutoff, default 0.2 like the ordinary cutoff; lower asks more while you’re away, config.md). Grants from before you left (AllowForTurn/AllowForSession) do not apply.

The timeout

[away] timeout (default 15m) is how long a question waits before it is refused as if you’d typed /away; the rest of the task then runs away. It applies only where /away can start: a mode where commands don’t ask, with the sandbox on or external. Otherwise questions wait with no limit. A child’s question follows your session’s mode. Values: off, or Ns/Nm/Nh up to 24h. On the panel any key restarts the clock.

After the breaker has tripped in the current task (below), a timeout ends the turn instead, and the session waits for your next message.

The breaker

While you’re away, 3 refusals in a row, or 20 across the away stretch (unreachable-judge refusals included), trip the breaker. Away ends, and the next thing that needs you waits as an ordinary ask. Until the task ends, a timeout ends the turn instead of restarting away, and the away cutoff stays in force even if you return. A child spawned after a trip starts tripped.

A tripped root task keeps doing what needs no approval. A tripped child stops, and its parent gets that as the result. Under run --away, the next question is denied at once if nothing can read it, or after the timeout if something can. Either way an unfinished turn exits 1.

/iterations for long tasks

An away task can still hit the per-task cap on model calls (32 by default); each refusal costs one. /iterations <n> raises it for the rest of the session, the running task included, before its next model call; alone, it prints the cap. --away warns at launch if the cap is the default. A resume keeps a cap you chose (--max-iterations or /iterations); one from the default or config.toml follows config.toml as it reads at the resume. A crash resume keeps the cap the log last recorded.

Requirements

On Linux the backend is bubblewrap (bwrap) with a seccomp filter. It needs unprivileged user namespaces, which Ubuntu 24.04 usually blocks through AppArmor; the harness names the fix. Under Windows it runs in WSL2 (“Windows (WSL2)”, below).

On macOS the backend is Seatbelt, through /usr/bin/sandbox-exec. It needs:

  • macOS 15.4 or later, on Apple Silicon or Intel (README.md, “macOS”); 27.0 or later is better, on Apple Silicon (“Update macOS”, below).
  • /usr/bin/sandbox-exec, which ships with macOS.
  • The harness outside any other sandbox, since Seatbelt refuses a second one.

Otherwise each start says why the sandbox is unavailable:

the sandbox is unavailable: the harness is itself running inside a sandbox. Auto is off, and --approve-all and --away will not start. Fix: start the harness outside it, or set [sandbox] mode = "external" when that sandbox is the boundary, in <your config file>.
the sandbox is unavailable: `/usr/bin/sandbox-exec` is missing. Auto is off, and --approve-all and --away will not start. Fix: set [sandbox] mode = "external" when this machine is its own boundary, or mode = "off" to run commands unconfined, in <your config file>.

Each session start also runs a probe (about 0.2 s) and names any check that fails:

the sandbox is unavailable: the sandbox did not hold (listing_order). Auto is off, and --approve-all and --away will not start. Fix: no setting fixes a failed check; report the check's name. To run without the sandbox on purpose, set [sandbox] mode = "off" in <your config file>.

A failed check usually follows a macOS update, and no setting fixes it. Until the harness is updated, mode = "off" restores auto and --approve-all, and mode = "external" also restores --away when the machine is its own boundary. Report the check’s name.

Default Docker and Docker Desktop cannot nest the namespace bubblewrap needs. If the container is your boundary:

[sandbox]
enabled = false

That runs commands unconfined but still refuses run --away; for unattended runs use mode = "external" (“External mode”, below). On Linux, when markers such as /.dockerenv suggest a container, the unavailable message says so and suggests mode = "external" first:

the sandbox is unavailable: user namespaces are blocked; the harness seems to be inside a Docker container (/.dockerenv). Auto is off, and --approve-all and --away will not start. Fix: set [sandbox] mode = "external" when that container is the boundary, in <your config file>; otherwise sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0.

When the sandbox is unavailable, the harness fails closed. auto is not offered: choosing it, resuming into it, or a judging default mode in config.toml prints the cause and fix and falls back to a plain manual that judges nothing. --approve-all, run --mode auto, run --away and harness eval exit 2 at launch, as does resuming a session that crashed with its sandbox on. In manual, approved commands run unconfined.

How mode changes that:

sandboxauto--approve-all, run --mode auto, evalrun --away, /away
unavailablenot offeredexit 2exit 2
mode = "off"yes, unconfinedyes, unconfinedrefused
mode = "external"yesyesyes

On macOS the model is told it has BSD tools (sed -i '', stat -f).

Background commands

With [commands.background] on (config.md), bash and exec take run_in_background. The call returns at once with a task id (cmd-412); output goes to $STATE/tasks/<session>/cmd-412.log, which the model reads with read_file or search, and the command’s end arrives later as a message to the model. At most 8 run per session. A command runs until its limit (timeout under [commands.background], or the model’s timeout_ms up to max_timeout), then is stopped. task_stop stops one sooner, as does x in the monitor (↓ or /tasks, then x).

  • The spool. The file stops growing at 16 MiB with a cut marker; the process keeps running, and its last 50 lines (at most 8 KiB) arrive with its end. The harness unlinks the files when the session ends. A crashed session’s are left. With a host-bound secret on, the command’s output is redacted as it is read, so the file on disk, the end’s lines and what read_file and search read back show a secret’s value only as [secret:<name>]. The last few bytes of a value’s possible start are held until the command’s next output or its end; a command stopped mid-value loses that value’s first bytes.
  • A command’s end lands in the turn that is running. With the panel idle it opens a turn, unless the command was stopped (task_stop) or interrupted (Esc, quit): that end is recorded and opens none.
  • Esc while idle, and quit, stop every background command; each ends interrupted. Esc during a turn interrupts the turn, and its background commands keep running. A resume closes the ones a kill left open.
  • Waiting. -p and every sub-agent wait for their commands: the turn does not end while one runs (headless.md). The panel does not wait.
  • A timeout moves a command, with the sandbox off or external. A foreground command that reaches its timeout keeps running as a background command. With the sandbox on it is stopped, since a running box cannot be tightened: run it again with run_in_background.

With the sandbox on, a background command runs inside it. network: true is allowed; outside_sandbox: true is refused. It cannot write a protected path, tracked or not, or any git directory, so git commit, git fetch and husky install belong in the foreground. On Linux an empty read-only placeholder stands at each missing protected path while it runs and is removed after it, so meanwhile no other command or git checkout can create that path, and the file tools refuse a write there: <path> is held by a running background command; stop it with task_stop or wait for it to end. The placeholders show on the host while the command runs. A placeholder is not a change: it is in no checkpoint and no turn-end list, and /undo of a file one stands in for is skipped until the command has ended. On macOS no placeholder is made.

Placeholders are shared. Every sandboxed command that runs meanwhile, in this session or in another harness session in the same project, holds the ones its box binds under a file lock of its own, and whichever holder ends last removes each one that is still empty. One that something wrote into is left in place; when a background command is its last holder, that command’s result says so.

A sandboxed command, foreground or background, is refused when opening or locking a placeholder at a protected path fails with an error, since it cannot tell then whether another command holds it. (One that is merely being removed by another session at that moment is not an error: a foreground command goes on without it.) On a filesystem that takes no flock, that means an empty read-only file or folder left at a protected path has to be removed by hand; the refusal names it.

A start is refused, with a sentence ending Run this in the foreground., when the box could not hold its baseline:

  • the project has no .git;
  • a protected path is reached through a link git does not track, or a link that leads nowhere;
  • an existing file or link is in the way of a missing protected path;
  • a git hooks or include path the config names (core.hooksPath, include.path) inside a writable root was missing when the session started, whether or not it exists by the background start (git runs it outside the box, and the session could not hold it), or a link that git’s config leads through is untracked;
  • on macOS, any protected path is missing;
  • with a sentence of its own, ending Run the command again., when the project changed between the start’s look at it and its baseline (a protected path went missing or appeared), or another harness process was removing a placeholder at that moment. Running the command again is the remedy: refused: <path> changed while the start was being prepared, so a background command could not be kept from it. Run the command again.

The network. Each sandboxed command keeps its own network namespace on Linux, so a later command cannot reach a background server’s port; run both in one command, or both with network: true.

macOS. A harness killed outright leaves its background boxes running until the next resume sweeps them.

A killed command’s leftovers

harness resume brings back a session whose harness was killed mid-command (terminal closed, SSH dropped, a reboot), without re-running the command (checkpoints.md, “Resuming a killed session”). It also handles what the command left behind.

The record. Before each command the harness writes leftovers/<session>/<effect number> under its state folder (~/.local/state/harness by default, config.md), and removes it once the command is done.

What resume does, before anything else runs, for the session and its children:

  • Linux: the sandbox died with the harness. One still running holds sandboxed commands (below).

  • macOS: sandboxed leftovers are stopped: Leftover processes: 2 stopped (they ran in the sandbox).

  • A command outside the sandbox that was still running is named, never stopped:

      Still running outside the sandbox: 275710 (sleep). They were left running.
    

    If the command’s first process is gone:

    May still be running outside the sandbox: …. The command's first process is gone, so these may belong to another program; check with `ps -p <numbers>` before stopping one.
    

    After a reboot, nothing is looked up.

  • A record with no process (killed before the command started) quotes its first two words:

    A command may still be running; it could not be identified. Look for it with `pgrep -fl 'cargo test'`; stop any it lists that you did not start, with `kill` and its number.
    
  • Then protected files the command created are moved aside:

      The command created .envrc, which runs code or steers the agent later, so the harness moved it to .envrc.harness-quarantined-1231b2265de8612a. To keep it, write it with the file tools; the user is asked.
    

An interrupted resume reports again.

Holds. If a leftover can’t be confirmed gone, sandboxed commands are held, and so is a command approved to run outside the sandbox. Each one re-checks, so the hold lifts once the cause is gone:

  • An old sandbox still running, or one that could not be checked:

    Sandboxed commands are held: a sandbox from before the harness was killed is still running (pid 4321). It ends by itself, or stop it with `kill -9 4321`; then run the command again.
    

    On macOS, for a command that never entered its sandbox:

    a command from before the harness was killed has not entered its sandbox (pid 4321). Stop it with `kill -9 4321`; then run the command again.
    
  • Files that could not be moved aside: Sandboxed commands are held until .envrc is moved aside: move it away or remove it on the host.

  • A record that is empty, damaged, from another version, or incomplete:

    Sandboxed commands are held: ~/.local/state/harness/leftovers/<session>/3 could not be read (it is empty or damaged), so the files that command may have planted were not checked.
    Protected files in the project now: .envrc, CLAUDE.md. Remove any you did not make.
    Then run: rm ~/.local/state/harness/leftovers/<session>/3
    

Another folder. Resume from the folder the command ran in:

session failed: a command this session ran in /path/to/project was killed; files it may have planted there can only be checked from that folder. Resume it there: cd /path/to/project && harness resume <session>

A records folder that can’t be listed stops the resume the same way.

When the record cannot be written (permissions, a full disk), sandboxed commands are refused:

Sandboxed commands are refused: the harness cannot write in ~/.local/state/harness/leftovers/<session>/ (Permission denied). Make that folder writable by you, or free disk space, then run the command again.

Commands outside the sandbox, or with it off, run with the note leftover record not written: <why>; if the harness is killed while this command runs, its processes are not reported at resume.

Known gap: a session held at resume and then closed while idle is neither held nor swept at its next resume.

Background commands leave the same record, and a resume’s closure pass checks the whole session tree, so a background command’s files are moved aside like a foreground one’s. The placeholders of a Linux box that died with the harness are empty files at missing protected paths; the next write there by the file tools replaces a leftover one.

On macOS

Seatbelt enforces the same policy. Where macOS differs (below), the model is told too. The session record names the backend (seatbelt macOS 27.0 (26A428)).

Side by side

PolicyLinux (bubblewrap)macOS (Seatbelt)
Readsall but the hidden list; hidden reads emptythe same; hidden fails Operation not permitted
Hidden listcovered at session startplus the macOS additions; later paths covered too
Writesthe project, private /tmp, a linked worktree’s git directory, [sandbox] writablethe same, private folder at $TMPDIR, plus the user’s temp folder minus com.apple.*
The machine’s /tmpout of reachout of reach; a project inside it works
Git’s auto-run files, protected files, the harness’s own foldersread-only; created ones moved asidethe same; folders above them cannot be renamed
Network, plain commandloopback within the commandnone
Network-only commandthe machine’s networkthe same
Unix-domain socketsrefusedrefused; socketpair works
DNSfails at oncefails at once
Processesall end with the commandinvisible; swept when the command ends
Shared objectsa private IPC namespaceothers’ shared memory refused; named semaphores shared
Devicesa minimal /deva short list; none of your disks, console or terminals
Terminala fresh devptsone the command opens
Credentials in the environmentremovedremoved
Ways out—refused: open, Apple Events, launchd, the keychain, the pasteboard, most system services, terminal input injection, setuid programs, a nested sandbox-exec

A refused command shows the system’s own error, then the blocked-command note:

touch: /tmp/x: Operation not permitted

What you carry

  • Loopback tests need network: true. A test against a fake server on 127.0.0.1 (a cargo test, say) fails in a plain command — Rust: Operation not permitted (os error 1), Python: PermissionError: [Errno 1] Operation not permitted. With network: true it has the whole network, is judged, cannot run under escape = "never", and cannot read the project’s credential files, so a TLS test with a *.key or .pem fixture needs a full escape.
  • The user’s temp folder is shared with your other programs. A bare mktemp and Foundation use it rather than $TMPDIR, so files left there outlast the session. Use mktemp -d "$TMPDIR/x.XXXX". The user’s cache folder (/var/folders/…/C) is read-only.
  • A network-only command listens on every address, reachable from the local network.
  • Keychain credentials do not work inside: security finds nothing, and git’s osxkeychain helper and the gh login should fail too (unverified). Run the step that needs the credential outside the sandbox.
  • Named shared memory is refused except libomp’s, so Python’s multiprocessing.shared_memory and PyTorch worker tensors fail with PermissionError. Named semaphores are shared with your programs. System V objects outlive the command.
  • A command cannot rename or remove a folder holding a hidden or read-only path (or, for a network-only command, a credential file), nor the project, the private temp folder or another writable root: mv .vscode .vscode-old fails with Operation not permitted. A whole-folder clone is refused; cp -c -R copies file by file.

These fail with their own error and get no blocked-command note: open (No application knows how to open URL …), osascript to another app (Connection Invalid error for service com.apple.hiservices-xpcservice), security (The specified item could not be found in the keychain.), and pbcopy and launchctl (exit 1, no output).

Tools that sandbox themselves

Seatbelt refuses a second sandbox, so a program that sandboxes itself fails inside; an App Sandbox program is killed at once. SwiftPM is the common case: swift build fails with

sandbox-exec: sandbox_apply: Operation not permitted

swift build --disable-sandbox fixes it. Similar: xcodebuild (run it with outside_sandbox), Bazel (--spawn_strategy=local, unverified), Chrome and Electron (--no-sandbox, unverified). When such a failure is a command’s whole result (exit 65 or 71), it reads as the sandbox failing to start, with no note:

io: sandbox-exec failed to start the sandbox: sandbox_apply: Operation not permitted

A held session

When a command ends, even on a timeout or Ctrl-C, the harness ends every process it started. If it cannot confirm they all ended, the result is withheld and the session is held: every later command and file tool, children’s included, is refused until the process is gone. The command’s error (the process ID is an example):

the harness could not confirm that every process this command started has ended (process 4321 is still running), so its result is withheld and nothing else runs in this session until it can: end it on this machine (`kill -9 4321`), then run any command to check again. Files a leftover process creates are checked once it is confirmed.

Each later call:

an earlier command left a process the harness could not confirm has ended (processes 4321 and 4322 are still running), so this was not run: end them on this machine (`kill -9 4321 4322`), then run any command to check again.

At most eight IDs are listed, then and N more. If only unsettled entries remain, the text says how many (3 entries of the process list could not be settled) and the fix is wait a moment. Run the kill -9 in your own terminal, then any command. A killed harness’s leftovers stay sandboxed until resume sweeps them (“A killed command’s leftovers”).

The budget

A sandboxed command starts about 30 ms later, and a session start about 0.2 s later. Every path a command’s profile names adds start time, so a profile is capped at 1,000 path filters; a typical project uses about 100. Past the cap the command is refused, naming the largest list and the fix:

denied: the sandbox for this command needs 1155 path filters, more than Seatbelt compiles in a usable time (1,000): most are hidden paths. Fix on the host: shorten the [sandbox] hide list, then resume the session.

It can also name the protected paths (drop unneeded protected-list entries and git files) or the credential files (move unneeded ones out of the project).

The whole command line, environment included, must fit the system’s 1 MiB argument limit. Past it the refusal names the largest part:

denied: the sandbox for this command needs 1111404 bytes of arguments and environment, more than the system's argument limit (1048576 bytes): the largest part is the command's own arguments (1100066 bytes). Fix: shorten them, or pass the data to the command through a file in the project or $TMPDIR.

An environment near 1 MiB makes the sandbox unavailable at start.

A project path over about 1,000 bytes cannot run sandboxed commands. The message blames permissions, but the cause is the length:

denied: the project root cannot be read (File name too long (os error 63)), so the command was not run: restore its permissions on the host.

Move the project to a shorter path.

Update macOS

macOS 27.0 fixed a Seatbelt flaw Apple describes only as “an app may be able to bypass network restrictions” (CVE-2026-84551, 27.0’s notes). Apple’s record (NVD) marks every macOS below 27 as affected, so below 27, doubt the network rules. An Apple Silicon Mac fixes it by updating to 27; update when you can. An Intel Mac cannot (27 does not run on Intel), so on Intel the network rules carry that doubt for good. The backend in a session’s record shows which macOS enforced it.

Windows (WSL2)

Windows is supported through WSL2, as a Linux install inside a distribution. It has been checked on one Windows machine (WSL2 with Ubuntu 26.04); the rest of what follows is from Microsoft’s documentation and the code.

  • Check the version. In PowerShell, wsl -l -v lists each distribution with a VERSION column, which must say 2. wsl --set-version <name> 2 converts one; wsl --install sets up WSL2 with Ubuntu. WSL1 is not supported, and neither is Windows on ARM.
  • Set up inside the distribution. Install bubblewrap with its package manager (sudo apt install bubblewrap on Ubuntu), then run the installer from Getting started there. The Linux requirements above apply unchanged.
  • Keep projects in the Linux file system (~/code), not under /mnt/c. Names on a Windows drive compare without case, so write_file claude.md could replace CLAUDE.md with no prompt. The harness folds case there, as it does on a Mac’s default disk, so that write is refused; but the Linux file system is the safe place.
  • What the sandbox hides. WSL2 mounts each Windows drive at /mnt/c, /mnt/d, and so on, and the sandbox reads the whole file system, so a command would otherwise read C:\Users: every account’s .ssh, AppData (browser profiles, app tokens) and Documents. Each drive’s Users folder is hidden under every spelling that names an existing folder (Users, users, USERS, …), because the drive folds case. The rest of the drive stays readable, and read-only. The mount table decides what a drive is, so a moved automount root (/etc/wsl.conf) is followed.
  • A project (or its git folder) inside a Users folder (/mnt/c/Users/you/code) makes the sandbox unavailable, since hiding the folder would hide the project. Auto, --approve-all and --away fail closed, as for any unavailable sandbox (/mnt/c/code keeps the sandbox):
the sandbox is unavailable: the project is inside a Windows Users folder (/mnt/c/Users), which the sandbox hides. Auto is off, and --approve-all and --away will not start. Fix: move the project into the Linux file system (such as ~/code) or elsewhere on the drive, or set [sandbox] mode = "off" to run commands unconfined, in <your config file>.
  • Windows programs do not start from a sandboxed command. cmd.exe and /mnt/c/…/*.exe reach Windows over a Unix socket, which the sandbox refuses. Run them outside the harness.
  • Not covered: a Users folder moved to another drive or folder, a drive mounted after the session starts, and Users on a Windows partition mounted outside WSL (dual boot).

[sandbox] and [away]

Both tables are read only from your own config.toml: a project cannot widen or disable the sandbox or lengthen the timeout. A [sandbox] table in a config reached through HARNESS_HOME or XDG_CONFIG_HOME is refused if it lies inside the project (config.md).

[sandbox]
enabled = true               # false runs every command unconfined (mode = "off")
mode = "on"                  # "on", "off" or "external"; must agree with enabled
writable = ["~/.cache/pip"]  # extra ~/… paths commands may write
hide = ["~/.ssh", ".env"]    # extra paths to hide: ~, ~/…, absolute, or relative to the project
env_hide = ["MY_APP_TOKEN"]  # extra variable names (or * patterns) to strip
env_pass = ["GITHUB_TOKEN"]  # exact names kept in the environment; external only
escape = "judge"             # "judge" (default), "ask" or "never" (no ways out)

[away]
timeout = "15m"               # "off", or Ns / Nm / Nh, up to 24h

writable takes ~/… paths below your home directory: not ~ itself, and not absolute paths. hide takes ~, ~/…, absolute paths or paths relative to the project (.env, secrets/, config/*.key; see “What it does” and config.md). [judge] away_cutoff (default 0.2) is in config.md. escape is "judge" by default: the judge decides the full escapes it can and asks you the rest (above). "ask" has every full escape ask you; "never" offers none.

Host allowlist proxy ([sandbox.network])

When [sandbox.network] is present in your config.toml (under the same [sandbox] authority check — never from a project-relocated config), network: true commands route exclusively through an in-process HTTP/1.1 allowlist proxy instead of receiving the host’s whole network. Plain commands (without network: true) stay completely offline. Absent [sandbox.network], network: true keeps whole-host networking unchanged.

[sandbox.network]
allow = ["api.example.com", "*.docs.example.com", "custom.example.com:8443"]
deny = ["blocked.docs.example.com"]  # deny always beats allow (including package_managers); "*" kills all
package_managers = true              # opt-in preset for crates.io, npmjs, PyPI, Go, RubyGems, GitHub (default false)
allow_http = false                   # plain HTTP off by default; set true to allow HTTP (default port 80)
credential_walk = true               # set false to skip the per-command repo credential walk while proxied
  • Matching and ports. Entries are ASCII domains, *.<domain> subdomain wildcards (at least two labels after *., never matching the apex domain; bare * is rejected in allow and permitted in deny), or public IP literals (IPv6 bracketed, e.g. [2606:4700:4700::1111]). Without a :port suffix, an allow rule permits CONNECT tunneling on port 443 only (and plain HTTP on port 80 when allow_http = true); a portless deny rule blocks that host on every port. A rule with :port narrows that entry to that exact port. deny always beats allow and beats package_managers = true. An empty [sandbox.network] table is valid and denies all hosts.
  • Host-side DNS and SSRF defense. Every allowed hostname is resolved once on the host. Loopback, unspecified, RFC 1918 private, CGNAT, link-local, cloud metadata (169.254.169.254, 168.63.129.16, 100.100.100.200, 192.0.0.192, fd00:ec2::/32, fd20:ce::254, etc.), IPv6 ULA, multicast, broadcast, reserved/documentation ranges, and IPv4-mapped/tunneled IPv6 equivalents are unconditionally refused, and the proxy dials the vetted SocketAddr directly. Refusal responses (403 Forbidden, header X-Harness-Proxy-Error: <reason>) name only the address class — never the resolved IP. Non-public IP literals in allow are rejected at config load time.
  • OS-native enforcement and proxy environment.
    • Linux: commands stay inside bwrap --unshare-net with our unchanged seccomp filter (AF_UNIX still refused with EPERM). The harness’s single-threaded __net-bridge bootstrap binds 127.0.0.1:0 inside the private namespace, hands the listening FD to the host over SCM_RIGHTS, closes both FDs, sets HTTP_PROXY/HTTPS_PROXY/ALL_PROXY/GRPC_PROXY (upper and lower case) to http://127.0.0.1:<port> and NO_PROXY/no_proxy to localhost,127.0.0.1,::1, and execvps the command.
    • macOS: the host binds a per-command 127.0.0.1:0 listener, Seatbelt permits outbound TCP only to localhost:<port> plus macOS TLS trust evaluation daemons (com.apple.trustd.agent, com.apple.TrustEvaluationAgent, with no mDNSResponder), and injects the same proxy environment variables.
  • Audit log, crash-resume, and replay. The active policy is recorded on session.started.v1 / session.resumed.v1 and shown in /status (harness session). Each proxied command records sorted unique allowed_hosts and blocked_hosts on its outcome (command.finished.v1 for background commands) and appends a sandbox_note naming blocked hosts so both the model and the transcript see why a request failed. Replay serves recorded outcomes and starts no proxy. A crash-recovered resume refuses to continue if [sandbox.network] changed since the session started.
  • Credential walk opt-out. Setting credential_walk = false under [sandbox.network] skips the per-command 100,000-entry repo walk while proxied (home hidden paths, ENV_PATTERNS, and explicit project-relative [sandbox] hide entries still apply). Whole-host network: true always runs the walk.
  • Limitations.
    • Only programs that honor standard HTTP proxy environment variables can use proxied egress. Raw UDP, non-HTTP TCP (such as direct ssh without ProxyCommand), and tools that ignore proxy env vars fail closed inside the sandbox.
    • Tier 1 does not terminate TLS, inspect TLS SNI, or inject credentials, except on the hosts a secret is bound to.
    • On macOS, a per-command loopback proxy port is reachable by other unsandboxed local processes while the command runs, though it only forwards to already-allowlisted public hosts.

Host-bound secrets ([sandbox.secrets])

A network: true command can use a token without ever holding it. The box gets a placeholder; the proxy swaps it for the real value on that secret’s own hosts, and nowhere else. This is how an unattended run pushes: git push and an authenticated curl work while the token stays outside the sandbox. Secrets need [sandbox.network] and the sandbox on; under off and external nothing is exported or swapped, and a source is hidden only as those modes hide any [sandbox] hide or env_hide entry.

[sandbox.network]
allow = ["crates.io"]

[sandbox.secrets.github-dsaccon]
file            = "~/.secrets/github-dsaccon"      # exactly one of env / file / command
hosts           = ["github.com", "api.github.com"]
placeholder_env = ["GH_TOKEN", "GITHUB_TOKEN"]
git             = ["https://github.com/dsaccon/"]  # optional: git helper for these URL prefixes
# key = "GITHUB_TOKEN"     # with `file`: read that key from a dotenv file
# headers = ["x-api-key"]  # extra headers to swap in, beside Authorization
# git_username = "oauth2"  # default "x-access-token"
  • Sources, read once per process (start and resume), held only in memory:

    • env = "NAME": a variable of the harness’s own environment.
    • file = "~/…": the whole file (at most 64 KiB), trailing whitespace trimmed.
    • file with key: one key of a dotenv file (KEY=VALUE or export KEY=VALUE, quotes stripped, no expansion; the last line wins).
    • command = ["op", "read", "op://…"]: an argv run on the host without a shell, from /, with no input and a 30-second limit; stdout is the value. It runs in its own process group, so a command that prompts on the terminal is stopped and ends as timeout; a prompt of its own (Touch ID, a pass agent) is answered at start, while you are there.

    A value is 1 to 8,192 printable ASCII bytes, no spaces. A source that fails turns its secret off with a start notice naming the reason (missing, unreadable, no_key, invalid_value, command_failed, timeout, no_ca_bundle); the session still starts, and the secret’s hosts are reached without it. Only your own config may declare secrets.

  • What the box sees. Only network: true commands get the secrets’ variables; a plain command gets none of them. Each placeholder_env name holds harness_ph_<name with - as _>_<32 hex> (so github-dsaccon gives harness_ph_github_dsaccon_…), new every process, so the model is told to use the variable and never a copied value. With git, a credential helper answers for those URL prefixes (the longest wins) and replaces any helper you configured for that host. SSL_CERT_FILE, GIT_SSL_CAINFO, CURL_CA_BUNDLE and the other CA variables name a read-only bundle in <cache>/sandbox-trust/: the session’s CA, then your system’s roots and any SSL_CERT_FILE roots. NODE_EXTRA_CA_CERTS, which Node adds to its own roots, names the session’s CA alone. Each process has its own CA; its key never touches the disk.

  • What the proxy does. Only a secret’s hosts are intercepted (TLS ended with the session CA, then verified onward with the harness’s own trust); every other allowed host stays a raw tunnel. Hosts are exact names (no wildcard, no IP), CONNECT only, and allowed by being named. The swap is in headers only: Authorization (Bearer, token, and Basic, decoded and re-encoded) and the headers you list; never bodies, query strings or paths. Intercepted hosts speak HTTP/1.1 only, so gRPC and WebSocket to them fail closed.

  • The source is hidden from every sandboxed command, network or not, on or off: an env variable is removed, a file is hidden (one under the project also from the file tools). A project .env used as a source is therefore hidden from your test runner too.

  • A value that comes back in a command’s output (foreground or background, and output read back later) is replaced by [secret:<name>] before the harness records it or the model sees it.

  • Recorded as names. The session record lists each secret’s name, source kind, a digest of its source, hosts, variables and state; each command records which secret it used on which host. /status shows secrets: 2 on, 1 off (npm: missing). Replay reads no source and starts no proxy. A resume after a crash keeps the recorded states (one recorded off stays off, and its source is not read: no command runs) and refuses if a declaration changed or a secret recorded on fails now; /quit and resume to pick up the change.

  • On macOS git, curl and Node trust the session CA through the variables; Go tools and Apple-native ones (gh, and Apple’s /usr/bin/python3, whose LibreSSL ignores SSL_CERT_FILE) do not, and fail on intercepted hosts with a note saying so. A Python built on OpenSSL (Homebrew’s, python.org’s) reads the variable, and code that names the bundle itself works under any Python: requests through REQUESTS_CA_BUNDLE, pip through PIP_CERT, or ssl.create_default_context(cafile=os.environ["SSL_CERT_FILE"]). Other hosts are tunnelled, so they are unaffected.

  • What it does not stop. A process in the box can use the token on its hosts, within the token’s scope: bind narrowly scoped tokens. An unattended push still needs a [judge] allow rule (modes.md). Nothing limits what the token may do (branch, method, path). Redaction is of the exact value: an encoded echo (base64) is not caught, and a server that echoes the header returns the value into the box. A command’s output is redacted as it is read, before it reaches the result, the tail or a background command’s spool file, so the spool on disk holds markers, never a value; a background command’s last few bytes (fewer than the longest value) show only once its next output or its end decides they are not a value’s start, and a value’s first bytes are dropped when the command is stopped or times out mid-value. Tools that pin certificates refuse interception. A token that expires mid-session needs a restart.

External mode: the machine is the sandbox

[sandbox] mode = "external", or --sandbox external for one session, says this machine is itself the boundary: a dedicated VM, a container, a CI runner. The harness builds no sandbox of its own. It works on Linux and macOS, and only your config or the flag can set it (config.md, “[sandbox] — mode, env_pass and --sandbox”). At start it says:

this machine is the sandbox ([sandbox] mode = "external", set by <your config file>): commands run without a sandbox from the harness.

(set by --sandbox when the flag chose it.)

What it allows. auto, --approve-all, run --away, /away and harness eval. --approve-all refuses only the hard-deny list (modes.md, “The hard-deny list”) and installs (modes.md, “Local asks”); run --away with --approve-all is still refused.

What goes. Hidden folders, read-only protected files, the private /tmp, the network rule, the probe, and the two ways out. What stays. The judge, the local asks, the file tools’ limits and asks, and the hard-deny list.

The environment. For every command, children’s included:

  • A provider’s key variable is always removed.
  • Otherwise a name in [sandbox] env_pass stays (exact, case-sensitive, no patterns).
  • Otherwise the credential names under “What it does”, URL values with a password, and env_hide names are removed.

This is not a credential boundary: commands run as the harness’s user and can read that user’s other processes’ environments. Keep credentials off the machine.

The session record lists the names removed and those kept by env_pass (never values), and the model is told what is missing:

Commands run without a sandbox from the harness: this machine is the boundary. These variables are not available to commands: MY_APP_TOKEN, OPENAI_API_KEY.

The second sentence is dropped when nothing was removed.

Resuming. To switch a session to or from external, /quit and harness resume <session> with the new setting. A resume after a crash keeps the recorded sandbox: external continues only if it is still set and the recorded environment names, platform and case still match. Otherwise it exits 2 with the start-up notice, the first difference (the variables removed from commands changed since the crash: recorded …; now ….), and:

a session resumed after a crash keeps the sandbox it recorded; to change it, /quit and resume, or start a new session

A resume after a crash also exits 2 when the project’s [sandbox] hide entries differ from the ones the session recorded, with: the [sandbox] hide entries changed since this session started, and a session resumed after a crash keeps the list it recorded; resume with the recorded list and /quit, then resume again to take the new one, or start a new session.

A session recorded on resumes in the sandbox or exits 2. One recorded off, unavailable, or before the sandbox existed counts as unavailable unless the setting is now off.

A 0.5.x binary cannot read a log that records external.

What the environment must do instead. A command can damage anything outside the project that the machine’s user can touch. So:

  • keep key folders, other checkouts and long-lived tokens off the machine; pass a scoped, short-lived token through env_pass;
  • limit its network: the harness enforces none (the record says "network":"host");
  • snapshot or discard it after each run.

Protected files are writable to commands under external, and under off. The file tools still ask, but a command can write .envrc, .claude/, .vscode/ or a workflow, and the judge treats that as an in-project edit. Planted code runs when the project is next opened, so review the work (“What it does”). The judge is untested on macOS commands (brew, launchctl, osascript, security, defaults).

What stays fine inside

On both systems:

  • DNS fails fast: Network is unreachable or Could not resolve host, not a hang. On macOS curl prints curl: (6) Could not resolve host: example.com.
  • The private temp folder (<cache>/sandbox-tmp/<session>) is shared with child sessions.

On Linux:

  • cargo test against a loopback fake server.
  • A fresh devpts: a command that opens a pseudo-terminal gets a private one.
  • The private /tmp, in place of the machine’s (your tmux sockets, other sessions’ files).

On macOS:

  • Ordinary builds and tools: git, cargo build with a C build script, swiftc with its module cache, a zsh here-document, a Foundation atomic save, and Python’s multiprocessing Pool, Process and Queue. A package manager that fetches needs network: true.
  • $TMPDIR, the private folder; mktemp -d "$TMPDIR/x.XXXX" works.
  • A terminal the command opens, socketpair, pipes and /dev/null.

A blocked command says so

When a sandboxed command fails, or exits 0 while its output shows a sandbox refusal on a protected git path, the result carries a note: what the sandbox blocks, and how to ask for more — network: true for the internet, outside_sandbox: true for anything else. On macOS it also says network: true is the way to a local port. A failing open, osascript, launchctl, pbcopy or security gets no note (“What you carry”, above).

An overnight task

Set the model, thinking effort and mode, raise the per-task cap, then go away — the rest is one ordinary message:

harness run
/model claude-opus-5
/model thinking high
/mode auto
/iterations 500
/away
<the actual task>