Repository navigation
fix: stop the sandbox hiding the directory a child execs out of - #11941
Conversation
|
Intent: Make a Not a goal: Changing what the read-gate floor protects, relaxing any write seal, reworking the gate-extension routing, or touching any other harness's mask. |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/agent_sdk/tool_gate.py:269 -- False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the roster-wide rider: unmasking Not justified as shipped
What this change shipsInventory (9 items) — 6 justifiedIntent: unbreak the pi backend, which every sandboxed host refused at session start because Crew's own enforced-harness mask hid the directory holding its gate launcher — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 4d3419a |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The contract doc and Watch
[DESIGN-REVIEWED] 4d3419a |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
3e95864 to
71cfda5
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: The read+write path fence ( ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix and windows, plus no UNADJUDICATED: Most of this change's tightening lives in guards the shell-command classifier never reaches, so no verdict exists for them and
[SCOPE-REVIEWED] 4d3419a |
71cfda5 to
e9588b4
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
a7d4d60 to
69fd34d
Compare
69fd34d to
93eacfe
Compare
93eacfe to
9cc26ff
Compare
9cc26ff to
8687e58
Compare
|
self-added: no
|
bolichen97
left a comment
There was a problem hiding this comment.
Approved: fix-class, readiness:passed, no conflict.
UX Review (Fable 5) — ⏭️ skippedRevision |
buluoray
left a comment
There was a problem hiding this comment.
Approving at bb579044. No blocking findings — nothing unsafe ships. But there is one ask below that I would want closed before this becomes the reference for the next harness author, and it is on this PR's own seam.
All six bots cite this head: GPT, First Principles, Opus and UX PASS; Design and Security-Scope CONCERNS (advisory). Design independently found the same contradiction I did.
The load-bearing thing I checked first, because AGENTS.md makes it the pin that keeps the ceiling un-disableable. test_sandbox_governance_mask.py is 48 insertions, 0 deletions. The existing reconciliation and disjointness pins were not edited to accommodate this change — two methods were added beside them. A sandbox PR that had to loosen that test to pass would be a different conversation entirely, so it is worth stating plainly that this one did not.
How much the visible surface actually grew: one leaf. Of the newly readable entries, playwright-cli is the only one that was genuinely on the mask floor (security/paths.py:179 _CREW_SECRET_LEAVES feeding _SENSITIVE_HOME_DIRS at :759). The rest — apps/.dev-grants.json, settings_seeds.json, agent_model_state.json, subagents, decisions — were never in _SENSITIVE_HOME_DIRS at all (subagents and decisions are write-protected, read-allowed), so reclassifying them changes nothing a child could already open. That is a much smaller delta than the diff size suggests.
This is an OS-level rule change, not a matcher. Bind-mask plus a read-only seal plus a completeness pin, which is the direction AGENTS.md asks for when it calls a regex spelling-chase a review smell. Symlinks are resolved before the decision, not after: acp/client.py::_pi_gate_artifact_dir refuses on is_link_or_junction, then requires realpath == canonical and mode 0o700. pi-gate is a sibling leaf of the still-masked run, precreated so it is a read-only mountpoint before any sandbox starts — so this is not a parent unmask that transitively exposes siblings, which was my main worry going in.
Every credential and authorization leaf stays withheld: run (the gateway port secret), trust, sel_hmac.key, .local_secret, crons.json, member-memory-bindings, the security event log, the admission stores, memory_stores, and pi-gate itself for every backend other than pi.
The one ask
tool_gate.py:269-271 and the crew_host_runtime_leaves docstring state the opposite of what ships. Both say Crew's own ceilings and consent records are excluded from the mask — that is, child-readable — "because an in-sandbox Crew reader needs them and they hold no credential". I read both tuples in full to be sure, because the grep I tried first was inconclusive:
_CREW_CHILD_WITHHELD_LEAVEScontainssecurity_policy.json,profiles,admission_policy.json,computer_use.json,denied_commands.json, and all four consent records (decisions_consent.json,file_delivery_consent.json,ssh_auth_sock_consent.json,aws_service_consent.json)._CREW_CHILD_READABLE_LEAVEScontains none of them.
So the code withholds what the documentation says it exposes. The code is the tighter of the two, which is why this is not blocking and why no exposure ships.
It still matters more than an ordinary doc nit, for a specific reason: harness-onboarding.md directs the next harness author to reason from exactly these two places. Someone reading them will conclude the ceilings are meant to be child-readable and may "correct" the code toward the doc — and AGENTS.md is explicit that this area is where masking and exposing have counterintuitive consequences, since hiding a policy file can make it resolve to the permissive standalone default rather than protecting it. A doc that describes a wider exposure than the code is the one artifact that could license widening it later, on this PR's own seam.
I am not claiming which side is correct. Whether an in-sandbox Crew reader in the child needs those leaves is your call, and it decides whether the fix is to the prose or to the tuples. What should not persist is the two disagreeing.
Smaller: _pi_gate_artifact_dir's refusal string says "not a real owner-only leaf" — "leaf" is internal vocabulary in an operator-facing message. And three residuals are stated rather than hidden: a symlink-relocated pi-gate refuses every pi session, a squat at pi-gate refuses any backend's spawn, and a symlinked run/pi-gate is silently skipped by cleanup_stale_sandbox_profiles.
I did not execute the pin test, and I take on trust that no credential-bearing file exists under run beyond the relocated artifacts, which the OS mask enforces per spec.
Not merging; that is Ray's call.
|
Re-synced onto current main.
|
An enforced ACP harness is handed the agent file-tool floor as an extra OS mask, and pi seals its gate extension and writes its gate launcher into a directory on that floor. The launcher bind-mounts an empty directory over it moments before it execvp's the child, so the child could not start, the command registry could not be read back, and every pi session was refused before the first prompt. The artifacts move to <data home>/pi-gate, a leaf that holds nothing but what Crew's gate sealer writes, and the pi backend excludes it from its own mask through the floor's existing exclude_leaves vocabulary -- the same mechanism that lets an adapter read its own OAuth token. The exclusion names one backend, so every other child's mask still covers the leaf, and the floor still fences the agent's own file tools, so the two controls cover different readers. <data home>/run keeps its mask, because run_marker.secret_path stores the per-listener bearer credential for the gateway's internal API under it. Materializing the leaf and checking it is not a link belongs to the one backend that has it, not to the shared sealable-ceiling walk that every Linux spawn performs whatever the backend is: an entry there lets this adapter's directory refuse an unrelated session's construction. _pi_gate_artifact_dir creates the leaf 0700 and refuses a dangling symlink, a symlink, a junction, a non-directory and a wrong mode, and it runs before the sandbox is built on every pi spawn, so the read-only seal still finds a directory to bind. A spawn on any other backend finds the name absent and the seal skips it. The leaf stays read-only inside every sandbox, because the launcher cache accepts an existing path after isfile without re-reading its bytes, and stays on the file-tool floor. The stale-artifact sweep pins its directory with O_DIRECTORY | O_NOFOLLOW and unlinks relative to that descriptor, so a link planted at either artifact directory cannot redirect a delete outside the data home; Windows has no such primitive through os, so that arm checks for a link and declines to sweep, which is stated as the accepted residual.
…right-cli (#11977) A pi session died because the sandbox hid the directory the child had to exec out of. That was not a pi bug. The credential mask an ENFORCED harness is confined by projects the whole read-gate floor, and the floor covers a Crew runtime file to keep the AGENT'S FILE TOOLS out of it, not to keep the CHILD out. Used as a sandbox deny list, the same entry hides the file from the child too. This is the audit of that class across every backend. All eight were swept. The four unenforced ones get no mask and were never affected. The four enforced ones (codex, opencode, goose, pi) each hid files sandbox.py itself declares the child must reach. No fail-open anywhere: every arm refuses the session rather than running unconfined. What ships is the classification, not a wider mask. Every crew leaf a sandboxed process may read is now declared either child-readable or withheld, in two paired lists rather than one derived as the complement of the other, because a complement makes classification optional: a credential leaf added later would default to readable and reach a foreign child with nothing reading as wrong. Written out, a new leaf lands in neither list and a pin fails until someone decides. That pin caught four upstream leaves across three rebases. Only playwright-cli leaves the mask. It is the one readable leaf the read gate also fences, so the one whose exclusion changes what an enforced child can open; the browser launcher is what an agent browser command execs. Every governance, policy and consent document stays masked, and so does every credential leaf, because each is an input to an authorization decision and a foreign child reads it through a channel that reaches no gate. So the governed-host boot break is NOT fixed here. An in-sandbox boot_platform() under those four harnesses still gets an empty ceiling document and raises, which is fail-closed and therefore safe. Closing it needs a gateway-brokered read rather than a mask exclusion, and that is tracked in #11988 along with every other feature these leaves cost. Three ratchets, all over the production roster: no child-required path may be masked, a withheld leaf leaves the mask only by a narrower per-backend grant (asserted in both directions), and every non-hidden crew leaf must be classified, pinned complete and disjoint. The owning specs and the AGENTS.md residual note are updated to describe the mask's two exemptions rather than one. Co-authored-by: zejiangg <zejiangg@amazon.com>
|
Re-synced again, now that #12193 is on main.
|
|
Found this while reviewing the merged change. The code is correct — three prose passages describe the opposite of what it does. Fix is up as #12251 (wording only, no list or predicate touched). @buluoray had already flagged the same contradiction in a review comment on What disagrees with what
Read from the loaded module on All five ceilings and all four consent records are in The part that matters more than the inventoryThe docstring does not just mis-list the set — it builds an argument on the mis-listing, and reaches the opposite conclusion from the withhold list about the same consequence:
One file, one consequence, two opposite verdicts. The second is the shipped behaviour. This is load-bearing because Not drift — wrong on arrivalNeither Deliberately not changed
What I did not decideWhether an in-sandbox Crew reader in an enforced-harness child should be able to resolve a ceiling is your call, not mine — #12251 only makes the prose match what the code does today. If the answer is that it should, the fix is a list change with its own review, not a docstring edit. Verified with the 831 tests in |
Problem / Motivation
Every
pisession was refused before the first prompt. The operator saw:The install was fine. Crew hid the gate from itself.
Why it matters
The
pibackend is unusable on any host that has a sandbox backend, which is everysupported host. The message also blamed the user's install, so the real cause was
unreachable by following it.
Crew does fail closed here, so nothing ran un-gated. That is the one thing that was
already right.
What changed (motivation → approach → change)
<data home>/run<data home>/pi-gate<data home>/runin an enforced harness's mask<data home>/pi-gatein the pi child's mask<data home>/pi-gatein any other child's mask<data home>/pi-gatewrite access<data home>/pi-gateleaf name<data home>/pi-gate<data home>/pi-gatefor the agent's own file toolsis_sensitive_pathfloorsrc/kiro_crew/acp/client.pysrc/kiro_crew/agent_sdk/tool_gate.pyexclude_leavessrc/kiro_crew/sandbox.pysrc/kiro_crew/security/paths.pydocs/system-specs/modules/pihas no permission gate of its own, so Crew loads its own gate extension into theharness. It seals that extension and writes a small launcher, then asks the harness's own
command registry whether the gate loaded.
An enforced harness is handed the whole agent file-tool floor as an extra OS mask. The
mask builders append that floor after the tier has deliberately kept
<data home>/runvisible, so the launcher bind-mounted an empty directory over it moments before
execvp. The gate artifacts lived there, so the child had nothing to exec.<data home>/runcannot simply be unmasked:run_marker.secret_pathkeeps theper-listener bearer credential for the gateway's internal API at
run/gateway-<port>.secret, andread_local_secretprefers it over the shared.local_secret. So the artifacts move to their own leaf instead, which holds nothing butwhat Crew's gate sealer writes.
The exclusion goes through the floor's own vocabulary.
sandbox_credential_targetstakesexclude_leavesfor exactly this shape — the leaf an adapter must still read while theread gate keeps fencing the agent's file tools — and
adapter_hidden_credential_dirsalready passes that argument for a harness's own credential store. A per-backend table
adds the gate-artifact leaf beside it, so only the
pichild's mask uncovers it and thedata-home spellings are derived from
crew_home_prefixes()rather than written out.The new leaf is read-only inside every sandbox, because the launcher cache accepts an
existing path on an
isfilecheck without re-reading its bytes — a writable window wouldlet one session's child plant the launcher a later session execs. The leaf is
materialized and no-follow pinned on the shared sealable-ceiling walk like
playwright-cli, becausemount(2)cannot seal an absent path: off that walk the namestays WRITABLE in-sandbox until pi first runs.
The walk carries no per-adapter branch: an unsafe state here refuses the spawn as it does
at any other ceiling.
_pi_gate_artifact_dirre-checks the same states before the sandboxis built, so a pi session refuses naming the directory it resolves. Stated residual: a
squat at the leaf refuses any backend's spawn, not only pi's. Conditioning the walk on the
spawning backend was tried and reverted — the adjudicator judged weakening a shared seam
worse than this residual. The resolver
refuses a symlink or a Windows junction at the leaf through
platform_compat.is_link_or_junction, becausestat.S_ISLNKanswers False for a junctionand a reparse point there would redirect the seal into a directory an agent chose.
Two readers act on that path, so both refuse a link at it. The stale-artifact sweep pins
the directory with
O_DIRECTORY | O_NOFOLLOWand unlinks relative to that descriptor, so alink planted at either artifact directory cannot redirect a delete outside the data home.
Windows has no such primitive through
os, so that arm checks for a link and declines tosweep, and the remaining window is stated rather than hidden. It is pre-created, so the Linux seal has something to mount on before the
first
pisession rather than skipping an absent target. The stale-artifact sweep coversthe new directory.
Backwards compatibility
Compatible: the pi gate artifacts move to a path only Crew writes and only Crew reads,
resolved fresh on every spawn. No caller names the old location, and nothing that works
today stops working.
<data home>/runkeeps exactly the mask it has onmain.Tests
test/test_acp_pi_backend.pypins both halves, so re-broadening the exclusion andremoving it fail in different places:
<data home>/runstays bind-masked atstandard,ccandstrict, and the Seatbeltprofile still denies reads on it.
through
run_marker.secret_pathrather than a hardcoded name.<data home>/pi-gateis absent from thepichild's mask while still on the floor, andstill present in another enforced backend's mask, so the exclusion is per backend.
_CREW_READONLY_LEAVES,_CREW_PRECREATE_READONLY_DIR_LEAVESand_CREW_NOFOLLOW_READONLY_DIR_LEAVES, so it is created and sealed before any sandboxstarts.
SandboxCeilingUnsealableout of_materialize_sealable_ceilings, parametrized overpi-gateandplaywright-cliso alater per-leaf exemption for either has to change the test rather than pass quietly.
Adding a
pi-gateskip to the loop fails it.real directory, and a regular file. A loose pre-existing directory is tightened to 0700
rather than refused.
skipped off POSIX because those builders need
os.getuid.neither writer touches it. Both run on Windows too, through
conftest.make_dir_link,which plants a junction where a symlink would need a privilege.
pointed-at file on disk. Dropping
O_NOFOLLOWfails both, because the sweep then deletesthrough the link.
<config dir>/pi-gateat mode 0700.run/voice-runtimekeeps its own mask, and stale artifacts are swept from the newdirectory.
that exits 126, one that answers a shape this gateway cannot read, and one that answers
with the probe from Crew's file.
Mutation-verified twice: emptying the per-backend exclusion table fails 3 tests including
the mask-and-floor assertion, and removing
pi-gatefrom the no-follow set fails the sealassertion.
Manual verification
The read-back was run by hand against a real
pi(mise-installed,24.20.0) outside thesandbox: exit 0, and the registry lists
kiro-crew-gatesourced from the sealed copy.That rules out the install and the rpc protocol as causes. The masked-directory half is
proved by reading the generated launcher's own
SENSITIVE_DIRSandREADONLY_DIRSandthe generated Seatbelt rules, because this host cannot create a user namespace. The
exclusion was also checked against a relocated
KIROCREW_HOME:pi-gateexcluded theretoo,
runstill masked.Related Issues
no linked issue: reported directly as an operator-facing refusal message, not through the
tracker.
Pattern harvest
Rule candidate: review-prompt
Pattern: a caller-supplied deny list appended after a deliberate allow decision cancels
it, and the invariant lives only in a comment on the allow list.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)