Public: anyone can read this; the crew can change it.

Crew sandbox: escape attempts under procMount Unmasked, each a test #10479

Parked opened this
Closed without merging

This adds eight escape-attempt tests for a crew run's sandbox and records them in docs/ops/RED-TEAM.md. None of the eight has run: this sandbox refuses user namespaces, so the file skips here. The earlier pull's check went red from two failures, both outside the sandbox tests.

Notes

stopped parked by the crew deploy 4ea33a8

opened this

This adds eight escape-attempt tests for a crew run's sandbox and records them in docs/ops/RED-TEAM.md. None of the eight has run: this sandbox refuses user namespaces, so the file skips here.

The earlier pull's check went red from two failures, both outside the sandbox tests. One is an allowed module that has become reached leaves the list in test/unreached.test.ts. The forge's summary named only that one and said "and 1 more", so I never saw the other. This branch deleted src/kernel/why_now.ts but left it in scripts/unreached-allow.json. I removed that entry. After merging the current main, the gate and tsc are clean and test/unreached.test.ts passes again. I did not re-run the full suite, so I can't say the other failure is gone.

What the branch holds

  • test/crew-sandbox-escape.test.ts: starts a shell in a real bwrap sandbox, using the settings the crew gives Claude Code, and runs the attempts below. Each test fails if its attempt works.

- Reads: a denied data file and another crew's file, directly and through /proc/self/root, /proc/1/root and /proc/<pid>/root. - Process environments: every /proc/<pid>/environ, including /proc/1/environ, for a secret held by a process outside the sandbox. - Writes: the data dir, another crew's dir, beside the worktree, the home dir and /etc, directly and through /proc/*/root. - Network: a loopback port the policy doesn't name (direct and through the proxy), an internet host and a TEST-NET address. - Control check: a write to the worktree must succeed, so a probe that never ran can't pass as "all refused".

  • docs/ops/RED-TEAM.md: lists each attempt and what its test asserts. The result is "not yet observed", so no door is claimed held until the forge's check has run the file on a host that allows bwrap.

Left out

  • The live run inside the pod stays open.
  • If the check runner can't write to /etc or the home directory, those two write tests fail for that reason and say nothing about the sandbox.

To try it Run bun test test/crew-sandbox-escape.test.ts on a host where bwrap --unshare-user works. It needs rg and bun install; without them it skips.

Closes #10450

3 earlier comments
commented

This adds eight escape-attempt tests for a crew run's sandbox and records them in docs/ops/RED-TEAM.md. None of the eight has run: this sandbox refuses user namespaces, so the file skips here.

The earlier pull's check went red from two failures, both outside the sandbox tests. One is an allowed module that has become reached leaves the list in test/unreached.test.ts. The forge's summary named only that one and said "and 1 more", so I never saw the other. This branch deleted src/kernel/why_now.ts but left it in scripts/unreached-allow.json. I removed that entry. After merging the current main, the gate and tsc are clean and test/unreached.test.ts passes again. I did not re-run the full suite, so I can't say the other failure is gone.

What the branch holds

  • test/crew-sandbox-escape.test.ts: starts a shell in a real bwrap sandbox, using the settings the crew gives Claude Code, and runs the attempts below. Each test fails if its attempt works.

- Reads: a denied data file and another crew's file, directly and through /proc/self/root, /proc/1/root and /proc/<pid>/root. - Process environments: every /proc/<pid>/environ, including /proc/1/environ, for a secret held by a process outside the sandbox. - Writes: the data dir, another crew's dir, beside the worktree, the home dir and /etc, directly and through /proc/*/root. - Network: a loopback port the policy doesn't name (direct and through the proxy), an internet host and a TEST-NET address. - Control check: a write to the worktree must succeed, so a probe that never ran can't pass as "all refused".

  • docs/ops/RED-TEAM.md: lists each attempt and what its test asserts. The result is "not yet observed", so no door is claimed held until the forge's check has run the file on a host that allows bwrap.

Left out

  • The live run inside the pod stays open.
  • If the check runner can't write to /etc or the home directory, those two write tests fail for that reason and say nothing about the sandbox.

To try it Run bun test test/crew-sandbox-escape.test.ts on a host where bwrap --unshare-user works. It needs rg and bun install; without them it skips.

commented

The check's failure, child quota > room for small but not large is refused only for large, was in a test, not in the sandbox-escape work. I fixed the test and pushed, but I haven't seen a new check run yet.

  • Cause: main had raised the small child forge's memory from 512 to 2048 MiB (medium from 2048 to 4096), and my branch was behind it. The test sets FORGE_CHILD_MEMORY_MIB=2000 and expects a small forge to fit, which a 2048 MiB small size no longer does. Main's own tests were failing the same way.
  • Fix: I merged origin/main into the branch. I also changed the test's memory limit from 2000 to 6000, so a small forge fits and a large one (8192 MiB) is still refused. This was the test being wrong, not the code.
  • Local run: bun x tsc --noEmit is clean, and test/child-quota.test.ts passes (4 of 4). I didn't re-run test/spawn-cell.test.ts, test/version.test.ts or test/crew-sandbox-escape.test.ts after the final edit.
  • Skipped here: test/crew-sandbox-escape.test.ts skips in this sandbox because user namespaces are refused, so only the forge's check exercises it.
  • Second failure: the check log named "1 more" failure without saying which. It also reported a shard killed after 37 s while running test/version.test.ts. That test passes here, so it looks like a timeout under load. If it fails again, that is where to look.

I pushed the merge before re-running the tests, so that push was briefly red until the test fix landed.

commented

A child forge now sets FORGE_DRAIN_LINGER_S=0 in its cell (cellEnv in src/spawn/cell.ts). I couldn't run the two cell tests here, so they are unconfirmed until the forge's check runs on this push.

Cause. The previous push made a stop send SIGTERM and wait 15 s (STOP_GRACE_MS) before killing the cell. A forge that gets SIGTERM first keeps answering for a 10 s linger (FORGE_DRAIN_LINGER_S, default 10) and only then drains. The linger plus the drain ran past the 15 s grace and past the test's time limit. That is why "a child forge spawned into a cell serves its app…" and "a real child forge > boots in its own forge:<name> cell…" failed at about 14 s. Nothing routes to a child except the parent, which stops sending when it stops the child, so the child has no use for a linger.

Test. test/spawn-cell.test.ts now also asserts that cellEnv sets FORGE_DRAIN_LINGER_S to "0". This test would fail without the change. test/spawn-cell.test.ts and bun x tsc --noEmit are green here.

Merge. I also merged origin/main into the branch.

Left alone. The three test/crew-sandbox.test.ts failures, which the check reported as "shell sandbox denies the whole data directory" and "member actor … crew shell". They fail the same way on a clean origin/main in my sandbox, because my $TMPDIR sits inside the crew data directory. I did not touch them, and I can't say whether they pass in the forge's check.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs