Repository navigation
fix(sandbox): pin the parents of every hidden crew-home leaf - #36327
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 Nothing blocks. The fix goes at the cause by putting hidden leaves into the existing What this change shipsInventory (8 items) — 8 justifiedIntent: stop a sandboxed agent from moving a masked crew-home credential out from under its mask by renaming a folder above it. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 0ed9eba Description read[DESCRIPTION-READ] 93485d0809e035b393396ed1163e948d92d5148050e81205f456d233855fe349 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change reuses the existing seal-parent rename guards for hidden leaves on both backends, and a leaf's own backend keeps its lifted parents unpinned. Notes
[DESIGN-REVIEWED] 0ed9eba Description read[DESCRIPTION-READ] e1c635be949fe5b18b1606b99b712517b791be4212d46960d056b39c9c696d9a 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: |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR adds the parent folders of every hidden crew-home file (core and app-declared An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
e015b46 to
46b3276
Compare
Sensitive change review
|
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: |
46b3276 to
46c09d8
Compare
|
Rebased: main moved in .github/workflows/ci.yml (#36198, the New-test stability job timeout, a different hunk from this PR's namespace-sandbox test list) since this head went green (27e9359 -> d4b588b); CI re-running. Related tests (146) and the lint/type/comment/brand/line-cap gates pass on 46c09d8 locally; writer sweep re-run on d4b588b finds no new renamer of |
46c09d8 to
5b6ebe5
Compare
|
self-added: yes
|
Sensitive change review
|
|
Main red, not this PR: |
Carries #36327 and #36346, which this branch stacks on, as one commit; review them there. leaf so the next spawn read the leaf at a name no mask covers. Every parent of every hidden spelling now joins the rename guards the read-only seals use (pin_seal_parents on Linux, literal write denies on Seatbelt); a retired leaf guards its parents only while they exist. entry of one name ending in "/" now names a directory under the app's data dir, masked whole, created before each Linux spawn inside an existing data/, and handed back to the app's own backend while it is absent or a real directory. App Kit level 7.
958f39c to
7761365
Compare
Sensitive change review
|
|
Rebased onto origin/main @ 205d08d, which carries #37063 (the fix for main's |
Carries #36327 and #36346, which this branch stacks on, as one commit; review them there. leaf so the next spawn read the leaf at a name no mask covers. Every parent of every hidden spelling now joins the rename guards the read-only seals use (pin_seal_parents on Linux, literal write denies on Seatbelt); a retired leaf guards its parents only while they exist. entry of one name ending in "/" now names a directory under the app's data dir, masked whole, created before each Linux spawn inside an existing data/, and handed back to the app's own backend while it is absent or a real directory. App Kit level 7.
|
Backend Tests (3.12, 2) on 7761365 is main's red, not this diff: |
A sandboxed child could rename a parent of a masked crew-home leaf (apps/meetings/data, apps/aws-control, or an app's credentialMasks data dir). On Linux the mask is a mount that moves with the parent inside that spawn, but on disk the leaf then sits at a name no mask covers, so the next spawn read it there. On Seatbelt the parents of core hidden leaves were not guarded either. Every parent of every hidden spelling, core or app-declared, now joins the rename guards the read-only seals already use: pin_seal_parents binds on Linux, literal write denies on Seatbelt. A leaf the spawn lifts keeps its parents unguarded there. A retired leaf, which nothing writes any more, guards its parents only while they exist, so md-notebook's sandboxed backend can still create its own home.
7761365 to
0ed9eba
Compare
Sensitive change review
|
|
Green-age note for 0ed9eba: Proof on fresh main: this commit cherry-picks cleanly onto 2304233, and on that tree every |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 0ed9eba. This change stops a sandboxed agent from renaming a folder above a hidden crew-home file, which would leave that file readable to the next session. Since the last review the product code is unchanged; the branch was rebased onto main, which carries the type-check fix, and one test was added. The new test renders the Notes backend's own macOS profile and proves each folder on the way to its home stays creatable while absent and is guarded once it exists; it fails if either half of the rule is removed. One older test no longer proves the Linux guard on its own, because main now seals a Meetings folder under the same parents; other tests still fail without the guard, so this is a small follow-up, not a blocker. Decisive lines: src/kiro_crew/sandbox_argv.py:516-526 (hidden_leaf_parents joined into readonly_ancestor_guards on both backends; unchanged since 5b6ebe5), src/kiro_crew/sandbox_argv.py:521 (retired leaf guarded only while its folder exists), test/test_sandbox_hidden_leaf_parent_pins.py:183 (new test for the Notes backend's own spawn), .github/workflows/ci.yml:2342 (one added line: test/test_sandbox_hidden_leaf_parent_pins.py in the backend-test-sandbox pytest file list; no permission, secret, trigger or action change)
A sandboxed child could rename a parent of a masked crew-home leaf (apps/meetings/data, apps/aws-control, or an app's credentialMasks data dir). On Linux the mask is a mount that moves with the parent inside that spawn, but on disk the leaf then sits at a name no mask covers, so the next spawn read it there. On Seatbelt the parents of core hidden leaves were not guarded either. Every parent of every hidden spelling, core or app-declared, now joins the rename guards the read-only seals already use: pin_seal_parents binds on Linux, literal write denies on Seatbelt. A leaf the spawn lifts keeps its parents unguarded there. A retired leaf, which nothing writes any more, guards its parents only while they exist, so md-notebook's sandboxed backend can still create its own home. (cherry picked from commit f43dd14)
Problem / Motivation
Goal: A sandboxed agent can no longer move a masked crew-home file out from under its mask by renaming a folder above it, on Linux or macOS.
A sandboxed child could rename a parent of a hidden crew-home leaf:
apps/meetings/data(above the maskededits/),apps/aws-control(above the maskeddata/), or the data folder of an app that declarescredentialMasks. On Linux the mask is a mount, and a mount moves with its renamed parent, so the child still sees an empty stand-in; but on disk the leaf now sits at a name no mask covers, and the next spawn reads it there. Reproduced throughsandbox.namespace_argvonmain:os.rename(".../apps/meetings/data", ".../apps/meetings/data-moved")succeeded, anddata-moved/edits/was plain on disk. On Seatbelt the mask is a path rule, so the same rename exposes the leaf in the same session; only the parents of app-declared leaves were guarded there.Why it matters
The hidden leaves hold credentials and private state (
apps/aws-control/data, Meetings' edits, any app'scredentialMasksfiles). A prompt-injected agent could read them with two shell commands across two turns. It also blocks campaign #26967: the owner ruling in #26967 (comment) (item 5) asks for md-notebook to run in the standard sandbox, which means moving its GitHub token into its own data folder undercredentialMasks, and that is only safe once that folder cannot be renamed away.Not a goal
security.md); that is a different mechanism.What changed (motivation → approach → change)
Symptom → cause → change:
sandbox_argv._live_plan_hostalready guards the parents of every read-only seal against rename (readonly_ancestor_guards: Linux binds each renameable parent over itself, sorename(2)returnsEBUSY; Seatbelt write-denies each as aliteral). Hidden leaves were left out, except app-declared ones on Seatbelt, on the stated reasoning that "a namespace mask is a mount, which moves with a renamed parent". The mount does move, but only inside that one spawn._CREW_HIDDEN_LEAVESand app-declaredcredentialMasksleaves, in both$HOMEspellings and the relocated-home spelling, now join the same guards on both backends. A leaf the spawn lifts (its own app's backend) still leaves its parents unguarded, as before. A retired leaf (theworkspace/md-notebooknames, which nothing writes any more) guards its parents only while they exist: an absent folder holds nothing to move, and md-notebook's sandboxed backend must be able to create its own home there on macOS. A top-level leaf's parent is the data home, which the seals already pinned, so in practice the new pins areapps,apps/aws-control,apps/meetings,apps/meetings/data, each declaring app's data folders, andworkspace/workspace/md-notebookwhen they exist.scratch(the parent of the maskedscratch/.trees.json) joins the list too; it is itself masked and already write-denied as a whole, so nothing changes for it..github/workflows/ci.ymlruns the new namespace test file in the namespace-sandbox job, the one runner with user namespaces (test_coverage_omit_contract.pyrequires it).security.mdgains the invariant beside the read-only seals' one and its app-declared paragraph says both backends;app-kit-platform.md§37 drops the "namespace plan gains no guard" sentence.Backwards compatibility
Breaking: inside a sandbox, renaming or removing one of the newly pinned folders themselves fails with
EBUSY, and arename(2)orlink(2)that crosses one fails withEXDEV(mvandshutil.movefall back to copying), the cost the seal pins already document. Writer sweep on origin/main @ 6a61c84: the folders underapps/are renamed only by the app lifecycle (apps/manager_install.py,manager_adopt.py,builtin_adoption_apply.py,manager_uninstall.py), which runs in the gateway outside every sandbox, andkirocrew appapplies through the running gateway;apps/manager_builtins.pymoves a retired app's metadata files aside inside its folder, never the folder, also in the gateway; nothing renamesworkspaceorworkspace/md-notebookthemselves;agent_scratch.pymoves trees insidescratch, neverscratchitself, from the gateway; agent temp files live in their own scratch window (agent_scratch.py), already a separate mount fromworkspace/.Reader: src/kiro_crew/sandbox_plan.py:namespace_payload -- chat|cron|subagent|app --
parent_pinscarries the added parents topin_seal_parents(test_a_core_hidden_leafs_parents_stay_in_place)Reader: src/kiro_crew/sandbox_seatbelt.py:render -- chat|cron|subagent|app --
runtime_ancestor_guardsbecome literal write denies (test_every_parent_of_a_nested_core_leaf_is_a_literal_write_deny)Reader: src/kiro_crew/apps/backend.py:_spawn_backend -- app -- an app's own backend lifts its declared leaves and keeps their parents unguarded (test_the_leafs_own_backend_may_rename_its_folder)
Tests
test/test_sandbox_hidden_leaf_parent_pins.py(new): a child under the real namespace sandbox getsEBUSYrenamingapps/meetings/data,apps/meetingsandapps(a core leaf's parents) and an app'sdatafolder (a declared leaf's), while a file inside stays renameable and the leaf is untouched on disk; the app's own backend can still rename the folder its lifted leaf lives in; Seatbelt write-denies each parent of a nested core leaf and the namespace plan pins the same ones.test/test_app_credential_masks.py:test_namespace_plans_no_parent_guard_for_a_declared_leafpinned the old behaviour; it becomestest_namespace_pins_every_parent_of_a_declared_leaf, including the move-aside spelling and the lifted leaf.test/test_sandbox_hidden_leaf_parent_pins.pyalso pins the retired-leaf rule: an absentworkspace/md-notebookgets no Seatbelt deny, and a present one (holding an older build'spat) is guarded on both backends.test_the_notes_backends_own_spawn_can_create_its_home_on_seatbeltrenders the Notes backend's OWN spawn profile (itsapp_backend_visible_targetslift) with nothing, thenworkspace, thenworkspace/md-notebookon disk, in every data-home spelling: each absent folder down to the clone rootworkspace/md-notebook/vaultshas no literal deny, and onceworkspace/md-notebookexists it andworkspaceare write-denied, so no spawn can rename them. It is red with theos.path.lexistscheck removed.test/test_sandbox_refactor_generated_programs.py: both goldens gain the new parents of the stand-in table's nested leaves.Determinism: the 8 tests in
test/test_sandbox_hidden_leaf_parent_pins.pypass 5/5 repeats and 3/3 shuffled orders (seeds 11, 22, 33),-n0, on a host with user namespaces;test_namespace_pins_every_parent_of_a_declared_leafpasses with them in the scoped run below. Each builds its own data home undertmp_path; none sleeps or reads a clock.Proof: PROVEN test/test_app_credential_masks.py::TestThePlanHidesTheDeclaredLeaves::test_namespace_pins_every_parent_of_a_declared_leaf, test/test_sandbox_hidden_leaf_parent_pins.py::TestTheNamespaceChildCannotRenameAParent::test_a_declared_leafs_parents_stay_in_place, test/test_sandbox_hidden_leaf_parent_pins.py::TestSeatbeltGuardsTheParentsOfACoreHiddenLeaf::test_every_parent_of_a_nested_core_leaf_is_a_literal_write_deny, test/test_sandbox_hidden_leaf_parent_pins.py::TestSeatbeltGuardsTheParentsOfACoreHiddenLeaf::test_the_namespace_plan_pins_the_same_parents, test/test_sandbox_hidden_leaf_parent_pins.py::TestARetiredLeafGuardsOnlyTheFoldersThatExist::test_the_notes_backends_own_spawn_can_create_its_home_on_seatbelt (head 0ed9eba)
All 78
test/test_sandbox*.pyfiles plustest_md_notebook_real_sandbox.py,test_app_credential_masks.py,test_app_backend_spawn_env.pyandtest_live_target_pointer_visibility.pypass locally (3,838 tests,-n 8 --dist loadgroup), on a host with user namespaces. Rebased onto origin/main @ 6a61c84: everytest/test_sandbox*.pyfile plustest_app_credential_masks.py,test_md_notebook_real_sandbox.py,test_coverage_omit_contract.py,test_app_backend_spawn_env.py,test_live_target_pointer_visibility.py,test_search_docs.py,test/test_agent_scratch*.pyandtest/tracing/test_tracing_otlp.pypass (4,080 passed, 21 skipped,-n 12 --dist loadgroup), andmypy src/kiro_crewis clean.Manual verification
Reproduced the rename on
mainand its refusal on this branch with a script drivingsandbox.namespace_argvagainst a scratch data home (the same steps the new namespace tests run). The Seatbelt half is checked on the rendered profile only; no macOS host was used.Related Issues
Part of #26967
Merge order (md-notebook stack): #36327 (this PR, part 1) -> #36346 -> #36365 -> #36368. Each later PR builds on this one and merges after it.
Sibling sweep
Swept: git grep -n "readonly_ancestor_guards|_renameable_ancestor_guards|_literal_ancestor_guards" -- src/
Sibling: src/kiro_crew/sandbox_argv.py:480 -- changed here
Sibling: src/kiro_crew/sandbox_workspace.py:225 -- not affected -- the voice runtime parents already have their own guards on both backends
Sibling: src/kiro_crew/sandbox_staging.py:54 -- not affected -- materialised hidden dirs are direct children of the data home, whose parent the seals pin
Pattern harvest
Rule candidate: review-prompt
Pattern: a mask or seal placed on a path is only as fixed as every directory above it; a new hidden or read-only row must say who keeps its parents from being renamed
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)