Repository navigation
fix(sandbox): seal gateway_id read-only inside the sandbox - #18407
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that #14210 really carries the 2026-09-28 maintainer decision the description cites. Under AGENTS.md's sandbox-scope rule, that decision is the only thing that authorizes adding this seal. What this change shipsInventory (6 items) — 6 justifiedIntent: stop a process inside the sandbox from rewriting this gateway's identity file, which the Remote Crew loop guard trusts. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 7d3711d Description read[DESCRIPTION-READ] 32e7a6f65769b11db2e5f58885588d24fedcd5e22be0104029d2b61430371d65 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a corrupt
[DESIGN-REVIEWED] 7d3711d Description read[DESCRIPTION-READ] 31b4cb22adb693d59c835bd762cb9935db251c929c1e3302a8ad9c0909f9a555 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 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: |
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 ADJUDICATED: 15 candidates, 0 confirmed newly-refused. The diff changes none of the three shell tiers ( PLATFORM COVERAGE: Rows were written for three spellings:
One assumed platform has no shell spelling. The Linux bind-mount seal and the macOS seatbelt UNADJUDICATED:
None of these pass through the shell composite, so the empty adjudicated set says nothing about them. [SCOPE-REVIEWED] 7d3711d |
Sensitive change review
|
f56a46d to
5496880
Compare
Sensitive change review
|
|
5496880 to
3cddd88
Compare
|
Sensitive change review
|
3cddd88 to
7d3711d
Compare
Sensitive change review
|
buluoray
left a comment
There was a problem hiding this comment.
Approving. This implements the #14210 decision as specified: an in-sandbox write to gateway_id is refused, and the read path is unchanged.
Verified
- The gateway is the only writer. The only writer of the file is
gateway_identity._install_fresh_id. It is reached from the health handler and the tunnel manager, both in the gateway process, and from the new pre-seal mint in the spawning process. No sandboxed reader needs write access, so READONLY is the right disposition. - Real Linux namespace sandbox, fresh data home:
- On this head, the spawn mints the id first. Inside the sandbox the file reads normally, and writing, renaming or deleting it are all refused. The gateway's value is unchanged afterwards.
- On the base tree, the same rename and delete succeed.
- Every guard is pinned. Reverting any one of these turns a named test in
test_gateway_id_sandbox_seal.pyor the governance-mask classification red:- the READONLY entry
- the pre-seal mint call
- the file-tool write floor
- the child-readable classification
- Spec updated. The instances.md cycle-guard paragraph is updated in the same change.
Non-blocking follow-ups
- If the pre-seal mint ever fails,
gateway_id()falls back quietly and the Linux seal has no name to bind for that spawn. It is not reachable in practice: the mint runs before any sandbox exists, and once the file is valid and sealed it is never re-minted. A warning, rather than a debug line, when the leaf is still absent after the mint would make the case visible. - The temp-file residual named in the description is a reasonable separate item if the owner wants it closed.
CI on this head: 96 success, 10 skipped, no failures. Auto-merge is off, so this approval does not merge the PR.
Problem / Motivation
Goal: A process inside the sandbox can no longer replace
gateway_id, the id this gateway compares to refuse a Remote Crew chain that loops back to itself.<data-home>/gateway_idhad no sandbox disposition: no rule insandbox.pynamed it, and the data-home root is writable in-sandbox. So an agent's shell could rewrite the file and choose this gateway's identity. The read path was already hardened in #13936; the write was not. The maintainer decision on #14210 (2026-09-28) was to add the disposition as defence in depth.Why it matters
The cycle guard trusts this id. A process that can choose it can choose whether a chaining loop is detected. Today the only reader is careful; a later reader would inherit nothing. Sealing the file makes the guarantee structural.
Not a goal
gateway_identity._read_id) or to how the id is minted.gateway_id.locksidecar: only the unsandboxed gateway takes it._install_fresh_idcreates its temp file beside the id in the data home, which stays writable, so a sandboxed process that links or holds that temp inode during a mint is not stopped by this seal. Closing that needs a mint from a directory the sandbox cannot write, a change togateway_identity.py.What changed (motivation → approach → change)
Symptom: a sandboxed shell could write the gateway's identity file. Cause: the file was on none of the three sandbox dispositions or the agent file-tool floors. Change: give it the READONLY disposition, the same treatment as the other sealed ceilings.
sandbox._CREW_READONLY_LEAVESgainsgateway_id. READONLY, not HIDDEN: the id is random and already served on/api/health, so reads stay open.sandbox._CREW_CHILD_READABLE_LEAVESgains it, so a foreign harness's child may read it (nothing secret in it)._materialize_sealable_ceilings) now mints the real id before sealing (_mint_gateway_id_before_seal), skipping an absent data home. The id is minted lazily on first read and the seal cannot bind an absent name. A pre-created{}stub would not do: the gateway's later mint would rename over the bound name, which detaches the bind in a running sandbox._WRITE_PROTECTED_HOME_PATHSinsrc/kiro_crew/security/paths.pygains it, so agent file tools refuse a write and still allow a read. It joins the existing gateway-written MCP block, whose comment is rewritten to cover it, so the security package stays inside its line budget.test/test_sandbox_protected_name_holds.py's leaf-only ratchet records the new root-level leaf (+3 per tier, one per data-home spelling), with its reason, the way earlier root leaves were added.docs/system-specs/modules/instances.mdcycle-guard paragraph names the seal.Design calls I made: the write-only tool tier rather than the read+write
sensitive_home_dirsfloor, because a read reveals nothing the health endpoint does not already serve; and minting before the seal, because without it a fresh Linux install stays writable until the first health read.Backwards compatibility
Compatible: every writer of
gateway_idis the unsandboxed gateway (gateway_identity._install_fresh_id, reached from the/api/healthhandler and the tunnel manager's cycle guard), and reads are unchanged.Reader: src/kiro_crew/dashboard/handlers/core.py:_liveness_payload -- gateway process, not sandboxed -- reads the live file, which the spawn may now have minted first (
test_the_spawn_mints_the_real_id_before_sealing)Reader: src/kiro_crew/instances/ssh_tunnel_manager.py:SshTunnelManager._chain_cycle_reason -- gateway process, not sandboxed -- same read and mint, unchanged
Tests
New
test/test_gateway_id_sandbox_seal.py(23 cases):MS_RDONLY;Red-first: on origin/main the new cases fail;
prove.py --base origin/mainreports PROVEN with the production hunks reverted. Determinism: 5 repeated runs and a shuffled order (seed 14210), all passed. Existing suites pinning the same lists or the spawn path (governance mask, gateway identity, health API, Remote Crew chaining, security, and every test naming these constants ornamespace_argv: 49 files) 5961 passed.Manual verification
Not run on a real OS sandbox: this host's shell is itself inside a Kiro Crew sandbox, where a nested sandbox is refused by design, and no macOS host was available. The Linux seal stage is covered through the launcher program with a recording libc, and the Seatbelt rule through the rendered profile. CI
Backend Tests (namespace sandbox)runs the spawn path in a real namespace.Related Issues
Closes #14210
Tracking: Taskei CREW-20099
Pattern harvest
Not generalizable: the class (a crew-home trust root with no disposition) is already caught for read+write-floor leaves by
test_sandbox_governance_mask; this leaf was on no floor at all, so only a per-leaf decision could place it.Checklist