Repository navigation
fix(sandbox): mask the vault under a relocated data home - #18412
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that an agent-run shell under a [DESIGN-REVIEWED] 4d7b3a7 Description read[DESCRIPTION-READ] 787abe70720b33b55609a5b21bb71cd01abb6382954ad3333b719a16cb09a95b 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (5 items) — 5 justifiedIntent: keep stored secrets unreadable to sandboxed agent shells when
[FIRST-PRINCIPLES-REVIEWED] 4d7b3a7 Description read[DESCRIPTION-READ] 11cc434e41b6cfca7074a4f916b4abfaa827a36533b91f4186ef14e57afd128c That sha256 names the PR description this verdict read. 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: |
Sensitive change review
|
|
Self-review (crew-pr-reviewer, read-only): HOLD for a maintainer / security owner This closes a real gap at the root cause. When |
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE Updated verdict (replaces my earlier HOLD on this head). A human code-owner review is required anyway. I found no defect: the moved |
buluoray
left a comment
There was a problem hiding this comment.
The fix is correct, but the owning spec needs a matching update before this auto-merges.
Verified
- Real Linux namespace sandbox, data home outside
$HOME, canary in the vault:- On the base tree, the canary is readable from a sandboxed shell. This reproduces #18397.
- On this head, the vault reads as empty in
standardandstrict. - It also stays masked through both spellings when
$HOMEis a symlink and the data home sits at the resolved path.
- Odd vault paths fail closed. With a moved data home, a symlinked
.vaultor a dangling one refuses the spawn, and a missing one is created empty first. All of this comes from the existing precreate pass, which already resolves against the moved root. - Default-home users are unaffected.
_relocated_crew_targetsonly adds a path that differs from the$HOMEspelling. - No in-sandbox reader is cut off. Every vault reader runs in the gateway.
- Scope matches the issue. It asks for this mask in all three tiers, with save and load unchanged.
- The new plan-host guard is pinned. Reverting the
_live_plan_hostchange reddens the nine moved-vault cases and the Seatbelt golden.
Blocking (spec drift, in scope)
docs/system-specs/modules/governance.md around lines 901-904 still says the $HOME-relative relocation gap is "a limitation shared with the vault entries". After this change that is no longer true. Please reword it in this PR to say the vault (_RELOCATED_CREW_HIDDEN_LEAVES) is re-anchored at a moved data home, like policy_cache. A clause in the security.md vault "Sandbox-hidden" bullet would help too. With auto-merge on, an approval would land the stale sentence on main.
Non-blocking follow-up
The matching change in carveout_shadowed_by_foreign_mask has no test: reverting it alone keeps the suite green. No carve-out sits under the vault today, so nothing is exposed. A case that refuses a carve-out beneath the relocated vault would keep the two readers in step.
CI on this head: 90 success, 10 skipped, no failures.
cruisercohen
left a comment
There was a problem hiding this comment.
The sandbox.py change does what #18397 asks: with the change reverted, 9 of the 16 new cases in test/test_sandbox_relocated_vault_mask.py fail, and on this head they pass together with the protected-name, generated-program, plan and governance-mask suites (788 passed).
Two things need a new revision on 38d8184: the branch now conflicts with main in test/test_sandbox_protected_name_holds.py, where main moved EXPECTED to 268/275/276 (#18407), so the +1 per tier should be re-applied on top of those numbers.
docs/system-specs/modules/governance.md line 902 still calls the $HOME-relative gap "a limitation shared with the vault entries", which stops being true here, so it should say the vault is re-anchored through _RELOCATED_CREW_HIDDEN_LEAVES.
Optional: a case that refuses a carve-out beneath the relocated vault would cover the carveout_shadowed_by_foreign_mask change, which no test fails without.
38d8184 to
d143210
Compare
cruisercohen
left a comment
There was a problem hiding this comment.
Thanks for the rebase: the protected-name counts now sit on top of main (269/276/277), and on this head the new vault test plus the protected-name, generated-program and plan suites all pass (788 tests) with the comment-history check clean.
One item from the previous round is still open: docs/system-specs/modules/governance.md line 902 still says the moved-home gap is "a limitation shared with the vault entries", which this change makes untrue, so that sentence needs updating to say the vault is now masked at a relocated data home as well.
Separately, the Sensitive Change Review check is red on this head only because its reasoning template names the earlier head commit; re-posting it with d1432104 clears it.
d143210 to
47caa58
Compare
Sensitive change review
|
|
@buluoray @cruisercohen thanks — the spec drift you both flagged is fixed in 47caa58.
No code changed in this revision. The protected-name counts stay on top of main (269/276/277). Comment-history and docs-lint pass, and the relocated-vault tests pass. The Sensitive Change Review template is re-posted for this head. The optional carve-out-beneath-the-vault case is left out to keep the fix to the reported hole. |
The tier lists name .vault only at its two $HOME-joined spellings, so a KIROCREW_HOME outside $HOME left config_dir()/.vault unmasked. Re-anchor it through _relocated_crew_targets the way kas is, on both the namespace and Seatbelt plans.
47caa58 to
4d7b3a7
Compare
Sensitive change review
|
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE Recommend approve. This fixes #18397 at the root cause: the tier lists spelled |
CrysisDeu
left a comment
There was a problem hiding this comment.
Reviewed the diff: narrowing-only sandbox change, the relocated .vault is re-anchored the same way kas is and kept out of _CREW_HIDDEN_LEAVES for the stated reason, the protected-name counts sit on main's numbers, and the governance.md sentence the earlier reviews asked for is now updated. Sensitive Change Review is green on this head. All checks green.
buluoray
left a comment
There was a problem hiding this comment.
Approving at 4d7b3a7. This supersedes my CHANGES_REQUESTED on 38d8184: the spec now matches the code.
docs/system-specs/modules/governance.md:901-903 no longer says the relocated-home limitation is "shared with the vault entries"; it now says the vault avoids it through _RELOCATED_CREW_HIDDEN_LEAVES (sandbox.py:535, used at :1359 and :7542). The _relocated_policy_cache_dirs() docstring carries the same correction.
Against the previous head, the range-diff shows only that spec/docstring wording plus the protected-name EXPECTED counts moving by +3 per tier, which comes from the rebase onto main (three new sealed names there), not from this change. My earlier verification of the mask itself (real namespace sandbox, relocated data home, vault reads empty in standard and strict, fail-closed on a symlinked or dangling .vault) stands.
CI on this head: 85 success, 13 skipped, 0 failures. I did not re-run tests on this head.
Problem / Motivation
Goal: The secret vault stays hidden from sandboxed agent processes when
KIROCREW_HOMEis outside$HOME.The sandbox tiers name the vault only at
~/.kiro/crew/.vaultand~/.kirocrew/.vault. When the data home moves out from under$HOME, the real vault folder is in no masked tree.kasandpolicy_cacheare already hidden at the moved home. The vault was the gap.Why it matters
The vault folder holds the vault key and every stored secret. A sandboxed shell on a host with a moved data home could read both. The tool gate still fences the vault, but a spawned
python -cor shell never goes through the tool gate.Not a goal
.vaultto_CREW_HIDDEN_LEAVES, which would also put the vault under the alias walk and the planted-link spawn refusal.What changed (motivation → approach → change)
Symptom: with
KIROCREW_HOMEoutside$HOME,config_dir()/.vaultis not in the sandbox plan's masked folders, in any tier.Root cause: the tier lists spell the vault only
$HOME-joined. The re-anchoring for a moved data home (_relocated_crew_targets) only reads_CREW_HIDDEN_LEAVES, and the vault is not in that list.Change in
src/kiro_crew/sandbox.py:_RELOCATED_CREW_HIDDEN_LEAVES = (".vault",)names the leaves masked at a moved data home on top of_CREW_HIDDEN_LEAVES._live_plan_host) and the carve-out shadow check._CREW_HIDDEN_LEAVESstill reaches the plan.Result: the moved vault is masked on the namespace plan, and denied for read and write on the Seatbelt plan. That is the same treatment the moved
kasgets. At the default home, the moved path equals the$HOMEpath, so nothing is added.The precreate pass already makes
.vaultthroughconfig_dir(), so the mask always has a target.Two test files move with it:
test/test_sandbox_protected_name_holds.py: the leaf-only ratchet is +1 per tier, with a note. The conftest pins a moved data home, so the moved vault is one more leaf-only name, held likekas.test/test_sandbox_refactor_generated_programs.py: the Seatbelt golden gains the four<ROOT>/crew/.vaultdeny lines.Backwards compatibility
Compatible: the vault saves and loads exactly as before. Every reader runs in the gateway, outside the sandbox. The default-home masks are unchanged.
Reader: src/kiro_crew/dashboard/handlers/secrets.py:SecretVault -- crew page -- gateway process, unsandboxed; test_vault_save_and_load_round_trip_under_relocated_home
Reader: src/kiro_crew/cron_script.py:_resolve_secret_env -- cron -- runs in the gateway's cron pool thread before the child spawns
Reader: src/kiro_crew/mcp_gateway/secret_uri.py:SecretVault -- chat -- MCP gateway resolves secrets in the gateway process
Reader: src/kiro_crew/dashboard/handlers/connections.py:SecretVault -- crew page -- gateway process, unsandboxed
Reader: sandboxed agent subprocesses -- chat|cron|subagent|app -- already cannot see the default-home vault in any tier; the moved vault now matches
Tests
New
test/test_sandbox_relocated_vault_mask.py(16 cases, tmp home and a fake secret only):standard,ccandstrict;$HOMEspellings;Fails before: with the
sandbox.pychange reverted, the 9 moved-vault cases fail on the vault check. The default-home cases and the round trip pass on both trees.Determinism: 20/20 green at
-n0; 10/10 green at-n 4 --dist loadgroup --max-worker-restart=2besidetest_sandbox_plan.pyandtest_sandbox_governance_mask.py; shuffled order, seed 23695, 16 passed.Sandbox suites (every
test_sandbox*.pyplus every test naming the vault or the hidden leaves): 5978 passed, 0 failed.Manual verification
N/A — unit coverage sufficient: the plan and the Seatbelt profile are pure functions of the host inputs, and the tests drive both on a moved tmp home.
Related Issues
Closes #18397
Pattern harvest
Rule candidate: review-prompt
Pattern: a secret leaf spelled only
$HOME-joined in a tier list, with no re-anchoring for a moved data home.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)