Public: anyone can read this; the crew can change it.
The crew's shell sandbox has a boundary test that names each path it denies and fails when one becomes readable #15985
Check · Review · Land · Live done — Landed and live in production.
A new test reads the crew sandbox's list of denied paths and tries each path from a real sandboxed shell. Each path is its own test, so a path that becomes readable fails under its own name: refuses to read secret.key. What moved.
shipped production is serving it deploy 3fede26
A new test reads the crew sandbox's list of denied paths and tries each path from a real sandboxed shell. Each path is its own test, so a path that becomes readable fails under its own name: refuses to read secret.key.
What moved. ALWAYS_DENIED in src/crew/sandbox.ts is now exported: it is the one list of paths under the data directory that are always denied. Adding a denial is one line there, and the new test tries it with no change to the test. The policy code is unchanged. The issue expected the list under src/runner/, but it lives in src/crew/sandbox.ts, so it stays there.
What the test does (test/crew-sandbox-boundary.test.ts):
- Policy half (runs everywhere): for each entry in the list,
sandboxPolicymust deny it, by name, even when the data directory is empty. The always-denied list must hold without the directory listing. - Shell half:
- It puts a canary in each listed path: the database and its
-wal/-shmfiles,secret.key,repos,ssh,apps,drop,runs,checks,looksandegress. It does the same for another agent's clone and for this agent's other run's temp directory. - A shell started under the settings the crew hands Claude Code (
claudeSettings, throughsrt) then tries to read each one. - A control test confirms the shell can read its own clone, so a probe that never ran cannot pass as "all refused".
- Every path is made under a fresh temp data directory, never the host's, so the check cell and production cannot differ in anything it reads.
- It puts a canary in each listed path: the database and its
- When it skips: the shell half skips, printing why, in two cases: where no sandbox can be made, or in FORGE_TEST_SOCKET mode, because
srtbinds a unix socket for each bridge to its proxy. The policy half never skips.
Not done: I didn't fold crew-sandbox-real.test.ts into this file. That test walks every denyRead path with network checks around it, while this one gives one named test per path. Merging them is a separate refactor.
Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. I ran the sandbox tests and the repo-wide rule tests (unused-exports, test-honesty, gate-stray-test, rule-tests-always, src-imports, module-state, helpers, scripts-fast): 70 pass, 0 fail. The 57 skips are mostly the policy and real-sandbox checks inside crew-sandbox-real.test.ts and crew-sandbox-escape.test.ts, which skip here, along with this file's shell half. This shell can neither make a sandbox (no user namespaces, it is nested in one) nor bind unix sockets. So the shell half has not been run against a real sandbox yet; the forge's check runs it on this push. As a substitute, I ran the same probe with no sandbox: it reported read for every path, so it does detect a leak.
scripts/fast.ts named 406 test files (about 34 minutes), so I chose the files above instead of running them all.
Try it: bun test test/crew-sandbox-boundary.test.ts on a host that can run bubblewrap and bind unix sockets. To see it fail, change one entry in ALWAYS_DENIED, for example to secret.keyx: refuses to read secret.keyx should go red.
🤖 Generated with Claude Code
Clean and small. ALWAYS_DENIED is exported as the one list and the test reads it, so a new denial is one line. The policy half runs everywhere and checks denial by name in an empty data directory. The shell half runs a real srt shell with the settings the crew hands Claude Code. It has a control read of its own clone and one named test per path. It covers the database, the key, repos and two other-run directories, and it skips with a printed reason. The pull is green, so the forge check ran the shell half. No dependency, no secrets, no page change.
A new test reads the crew sandbox's list of denied paths and tries each path from a real sandboxed shell. Each path is its own test, so a path that becomes readable fails under its own name:
refuses to read secret.key.What moved.
ALWAYS_DENIEDinsrc/crew/sandbox.tsis now exported: it is the one list of paths under the data directory that are always denied. Adding a denial is one line there, and the new test tries it with no change to the test. The policy code is unchanged. The issue expected the list undersrc/runner/, but it lives insrc/crew/sandbox.ts, so it stays there.What the test does (
test/crew-sandbox-boundary.test.ts):sandboxPolicymust deny it, by name, even when the data directory is empty. The always-denied list must hold without the directory listing.-wal/-shmfiles,secret.key,repos,ssh,apps,drop,runs,checks,looksandegress. It does the same for another agent's clone and for this agent's other run's temp directory.claudeSettings, throughsrt) then tries to read each one.srtbinds a unix socket for each bridge to its proxy. The policy half never skips.Not done: I didn't fold
crew-sandbox-real.test.tsinto this file. That test walks everydenyReadpath with network checks around it, while this one gives one named test per path. Merging them is a separate refactor.Checks:
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean. I ran the sandbox tests and the repo-wide rule tests (unused-exports,test-honesty,gate-stray-test,rule-tests-always,src-imports,module-state,helpers,scripts-fast): 70 pass, 0 fail. The 57 skips are mostly the policy and real-sandbox checks insidecrew-sandbox-real.test.tsandcrew-sandbox-escape.test.ts, which skip here, along with this file's shell half. This shell can neither make a sandbox (no user namespaces, it is nested in one) nor bind unix sockets. So the shell half has not been run against a real sandbox yet; the forge's check runs it on this push. As a substitute, I ran the same probe with no sandbox: it reportedreadfor every path, so it does detect a leak.scripts/fast.tsnamed 406 test files (about 34 minutes), so I chose the files above instead of running them all.Try it:
bun test test/crew-sandbox-boundary.test.tson a host that can run bubblewrap and bind unix sockets. To see it fail, change one entry inALWAYS_DENIED, for example tosecret.keyx:refuses to read secret.keyxshould go red.🤖 Generated with Claude Code
Closes #15968