Repository navigation
fix(cli): refuse before open: a sandbox option the adapter can't enforce fails the seat at start (F535) - #4171
lilyshen0722 wants to merge 6 commits into
Conversation
…rce fails the seat at start (F535) Ported from OAR's rule (D318): an option a runtime can't honour is refused before anything opens, never silently dropped. The 11-15 audit on main 10364a0 found shapes that were accepted and then not enforced. - hermes ran sandbox.trust=workspace bare, while the unconfined-seat guard read that trust as confined. It now refuses workspace at spawn, like every adapter but claude. - sandboxOptionRefusal (lib/sandbox-option-refusal.js) runs beside providerRefusal in agent config, attach and run, so a stored or daemon record can't skip it. It refuses network.allow-hosts (read by no adapter), a restricted network under macOS Seatbelt on claude, opencode or qwen (the profile keeps it on), a sandbox.mode with no public or workspace trust (spawns bare except claude bwrap, codex and dsh), and network or filesystem rules on a seat with no sandbox. Two tests that ran a mode with no trust to reach a later check now use a shape that still starts. ADR-008 invariant 2 notes the rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…s pass; codex refuses what its private profile ignores (F535 gate) Gate M1: an open network policy and empty lists asked for nothing but were refused, so the quickstart's macOS shape and examples/demo/demo.yaml would stop starting. They pass now, and allow-hosts beside a restricted network (which reaches no host) is left to the other rules. Gate M2: codex runs every seat with no trust in one private profile (workspace writable, network on), so mode read-only and network or filesystem rules were dropped. Those are refused now; mode workspace stays. The unconfined-seat guard's comment and the demo env's network comment say what the adapters do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate review by an Opus subagent at medium effort, since this is a sandbox boundary. It read 2df3b85, and the fixes are at 03a4745, which it re-checked. No High.
Medium, both fixed at 03a4745
- Options that were honoured got refused. An open network policy and empty lists asked for nothing, but the check counted them. So the quickstart's macOS shape (
mode: nonewithpolicy: unrestricted) andexamples/demo/demo.yaml(claude bwrap, restricted, allow-hosts) would have stopped starting. Both pass now. allow-hosts beside a restricted network reaches no host, so it's left to the other rules, and it's still refused wherever the restriction isn't enforced. Tests cover the quickstart shape, empty lists, demo.yaml and public bwrap opencode. - The codex exemption kept options codex drops. With no trust, codex runs one private profile (workspace writable, network on), so mode
read-onlyand network or filesystem rules did nothing. Those are refused now, and modeworkspacestays. Tests pin read-only, workspace with restricted, and workspace with filesystem.
Lows
- L1. Left as a follow-up: on Windows with
--unsandboxed, a public seat with a restricted network resolves to bwrap here, so it passes, while claude runs it with no jail and the network open. - L2. Left as a follow-up:
agent configchecks against the platform of the machine running it, not the seat's host. - L3. Fixed: the unconfined-seat guard's comment now says what each adapter does with a mode and no trust.
- L4. Left as is: hermes hand-copies the workspace refusal text, because packages/seats can't import cli/.
- L5. Left as is: a dsh seat with no trust and an unsupported mode gets the generic message. dsh refuses that shape at spawn in its own words anyway.
Checked and found correct
- These shapes are untouched: the default
{trust:'public'}, public read-only opencode, legacyinternal, claude workspace trust withallow, the dsh shape, and public codex. - Seatbelt keeps the network open on claude, opencode and qwen. Under bwrap, each adapter handles restricted itself.
- The daemon starts seats through
agent run, so it reaches performRun. Nothing re-adds sandbox options after the check, and the Windows codex opt-in stripssandboxbefore it. No run path skips the three call sites. - The four test suites this change touches pass, along with attach.test.mjs (507 tests). In the full CLI suite, the only failures are 3 in
seat-files.jailandseatbelt.commit-hooks, the same as on main on this host.
Press-held: cli/** joins Tue 11-17's cli batch, after #4125 (both touch hermes.js).
GATE: PASS
Written by Lily Shen, via Claude Code.
…used on every adapter (F535 item 5) Cofounder ruling 11-15: public agents start from nothing, and a read path outside the workspace on a seat strangers can message is what an injected agent would use to reach tokens. bwrap opencode and qwen bound sandbox.filesystem.read-outside into the jail. Now the start-time check refuses it on any public seat, legacy internal trust included, and the opencode and qwen adapters refuse it at spawn as goose and pi already did. Workspace trust and empty lists keep today's behaviour. Attack case: a public bwrap opencode seat whose config asks to read ~/.commonly is refused at start, and at spawn with nothing spawned. No seat record here or install on prod declares read-outside today. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
lilyshen0722
left a comment
There was a problem hiding this comment.
Delta review of bf4efc0 (F535 item 5, Cofounder ruling 11-15: a public seat reads only its workspace). Same Opus reviewer, medium effort, since it's security. No High or Medium.
What changed
sandbox-option-refusal.jsrefusesfilesystem.read-outsideon every public seat at start. It checks the normalized trust, so legacyinternalis included, and it applies whatever the mode, dsh included.- opencode and qwen now refuse it at spawn, like goose and pi. claude's public bwrap branch already did.
Checked and found correct
- The spawn-time throws come before anything reads the path. In qwen, that's before the provider key-file roots and the bwrap wrap. In opencode, it's the top of
spawnTurn, before the binds. The only readers of the path incli/srcarebwrapReadRootsand the ro-binds, and both come after the check. - write-outside is untouched.
- These still run: workspace trust with read-outside, an empty list,
examples/demo/demo.yaml(no trust), and the default public seat. - The attack case is tested at start and at both adapter spawns, with zero spawn calls: a public bwrap opencode seat asking to read
~/.commonly. The opencode test has no provider, so it can only pass through the new check. - No local seat record and no install on prod declares read-outside today, so no live seat changes.
- Tests: the five suites the change touches pass. In the full CLI suite, the only failures are the two known smoke suites, the same as on main on this host.
Low, fixed at 381826b: the new tests sat between an F197 comment and its test. They've been moved.
Press-held: Tue 11-17's cli batch, after #4125.
GATE: PASS
Written by Lily Shen, via Claude Code.
…weep) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor
F535: refuse before open
Ported from OAR's rule (D318, CTO verdict 11-15): an option a runtime can't honour is refused before anything opens, never silently dropped. The 11-15 audit on main 10364a0 found sandbox shapes that
commonly agent runaccepted and then didn't enforce.Change
hermes (
packages/seats/src/adapters/hermes.js) ransandbox.trust=workspacebare, while the unconfined-seat guard read that trust as confined and skipped the private-pod check. It now refuses workspace at spawn, as every adapter but claude does.sandboxOptionRefusal(cli/src/lib/sandbox-option-refusal.js) runs besideproviderRefusalinagent config,attachandrun. The daemon starts seats throughrun, so a stored or daemon record can't skip it. It refuses:network.allow-hosts, which no adapter reads;network.policy=restrictedunder macOS Seatbelt on claude, opencode or qwen, where the profile keeps the network on for the model and MCP (under bwrap, claude and qwen already refuse it and opencode applies it);sandbox.modewith no public or workspace trust, which spawns bare on claude (exceptbwrap), opencode and qwen. codex runs such a seat in one private profile (workspace writable, network on), so it keeps modeworkspaceand refusesread-only;An open network policy and empty lists ask for nothing, so they pass. That covers the quickstart's macOS shape and
examples/demo/demo.yaml, whose comment now says allow-hosts documents intent only.ADR-008 invariant 2 notes the rule.
Audit item (5), by Cofounder ruling 11-15: a public seat reads only its workspace.
filesystem.read-outsideon a public seat is refused at start on every adapter, legacyinternalincluded. opencode and qwen refuse it at spawn too, as goose, pi and claude's bwrap branch already did; before this, bwrap opencode and qwen bound it into the jail. Workspace and private trust keep today's behaviour. No seat record here and no install on prod declares read-outside, so no live seat changes. Attack test: a public bwrap opencode seat asking to read~/.commonlyis refused at start and at spawn, with nothing spawned.Proof
sandbox-option-refusal.test.mjs(29): one case per rule and adapter, plus the shapes that run today and must still start: no sandbox, the default{trust:'public'}, public read-only opencode (hq-support's record), claude workspace trust with an allow list, legacyinternal, claude bwrap, codex with a mode, mode none, and the stub.run-loop.test.mjs: a run refuses at start, with no client made and no spawn.adapters.hermes.test.mjs: workspace trust is refused before the probe or spawn. Both cases fail on main.seat-files.jailandseatbelt.commit-hooks, which fail the same way on main on this host. Seats package: 288 pass.Follow-ups from the gate (Lows, not in this PR): on Windows with
--unsandboxed, a public seat with a restricted network still passes and runs with the network open;agent configchecks against the platform of the machine running it.Press-held: cli/** joins Tue 11-17's cli batch.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N4VWLEgKqoyJ97ffrijbor