Repository navigation
fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend - #34339
Conversation
Sensitive change reviewHead: aecbe07
|
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 change puts the same pins in a different order, and the defect is pinned by a real-namespace test that plays the gateway's update mid-session. Not checked: whether the real-namespace test actually fails on base. The author says only CI can run it. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: keep an app-declared credential masked in a running Linux sandbox session after the gateway updates that app. FIX.
[FIRST-PRINCIPLES-REVIEWED] b81cc76 Description read[DESCRIPTION-READ] a639bd7453837deb2a75fa28a8c26ff0ddc32a7023a36dccb22c4b1f1ec24817 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. Binding the declaring app's folder after the masks fixes the cause: the masks no longer depend on a mount that an update retires. Seatbelt and spawns without a declaring app plan exactly as on main. Notes
[DESIGN-REVIEWED] b81cc76 Description read[DESCRIPTION-READ] 64a977164df3c4ea6047c9ae63d32856c0f04f36bc821e69892e7837ca3ce8b0 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: |
aecbe07 to
93bf904
Compare
Sensitive change reviewHead: 93bf904
|
|
AI review disposition for aecbe07, addressed in 93bf904:
|
93bf904 to
251f350
Compare
Sensitive change reviewHead: 251f350
|
|
AI review notes on 93bf904, addressed in 251f350:
|
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider flagged 1 possible problem (p_defect 0.62); a person should check it. The PR pins the folders above a declared credential mask on the Linux namespace sandbox, which closes the next-session rename gap for fresh sessions. But the shallowest-first pin order nests the data/ pin inside the apps/ pin, and an app update deletes that folder, removing both pins. A running session can then rename data/, and the next session reads the credential at its new name. The PR documents this as a limit, but it is a reachable gap in the PR's own goal on a security boundary, and deepest-first ordering would likely close it. The real-sandbox test never tries a rename after the move. Things to check (the decider's concerns; it is right less than half the time):
If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
6cf90fe to
3ff76d7
Compare
Sensitive change reviewHead: 3ff76d7
This PR stays flagged for human review. |
|
Follow-up for the residual this PR states (a running session can rename the replacement |
3ff76d7 to
c861977
Compare
|
AI review findings on 3ff76d7, addressed in c861977 (fix round 1):
|
Sensitive change reviewHead: c861977
This PR stays flagged for human review. |
c861977 to
fc16270
Compare
|
GPT 6.1 findings on c861977, addressed in fc16270 (fix round 2 of 2):
This was the second and last fix round against GPT for this PR. If GPT blocks again on a real finding, the PR goes back to a human decision rather than another patch. |
Sensitive change reviewHead: fc16270
This PR stays flagged for human review. |
…n the namespace backend Main pins every renameable parent of an app-declared credentialMasks file on the namespace backend, before the masks. An app update replaces apps/<app> from the gateway's namespace and renames data/ into the new folder; a mask or a data/ pin placed through a pin of the old folder stays with the retired folder, so a running session reads the restored credential plain. The folder of each declaring app, apps/<app>, now leaves parent_pins and is bound over itself after every mask (mask_parent_pins, pin_mask_parents). The set of pinned folders is unchanged; one pin per app spelling, none nested, so the mount count does not compound. The replacement apps/<app> an update creates is still renameable by a session already running until its next spawn; that is stated in the spec and the manifest reference.
fc16270 to
b81cc76
Compare
|
Test-only follow-up on fc16270, now b81cc76: |
Sensitive change reviewHead: b81cc76
This PR stays flagged for human review. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Verified on head b81cc76: the diff moves a credential-masking app's apps/<app> pin from before the masks to a new last stage (pin_mask_parents). The set of pinned folders stays the same as main's. I traced update_app's data move-aside flow. On main, the masks rode the old apps/<app> pin and a swapped folder read the token plain. Here they sit on the outer mount and stay with data/. The specs in security.md and app-kit-platform.md match the code. CI's Backend Tests (namespace sandbox) job ran test_seal_parent_pin_real_sandbox.py on this head with user namespaces available, and it passed.
Security: the flagged risk is mask placement in the namespace sandbox, and the change tightens it. No pin, seal or mask is added beyond spellings that resolve to the same folder. The masks now survive an app update, including the .<name>-data-tmp window that main leaves exposed. rename(apps/<app>) still returns EBUSY. Seatbelt is unchanged, because the new list defaults to empty. The remaining case, a running session renaming the replacement folder, is stated in the code and the specs and is tracked in #39037.
Done well: the real-namespace test acts as the gateway while a session runs. It moves data/ into a new app folder and checks that the token is still masked. That is the check main fails.
Optional:
- The branch in
sandbox_argv.py(around line 612) that moves an operator read-only parent pin on a declaring app's folder has no test. A plan test withconfigured_readonly_layerreturningapps/demo/trustcould assert thatapps/demois inmask_parent_pinsexactly once and not inruntime_ancestor_guards. _gateway_moves_the_app_datarenamesapps/demobefore it movesdata/.update_appmovesdata/to.demo-data-tmpfirst. Following that order, and reading the file once during the tmp window, would cover that window too.- The READY wait in
test_seal_parent_pin_real_sandbox.py(line 224) has no deadline while stderr is piped and not drained. A bounded read would make a stall fail by name instead of at the pytest timeout.
Problem / Motivation
Goal: On the Linux namespace sandbox, a file an app declares in
credentialMasksstays masked in a session that is already running when the gateway updates that app.Note for the reviewer: this PR was re-scoped. largjaco first chose to narrow it to a one-level pin ("option C"). That choice was made before anyone noticed that #36327 (merged 11-14) already pins every renameable parent of every app-declared credential file on the namespace backend. Option C on top of current main would have pinned nothing new. The worker analysed the rebased branch, and the conductor took option (2) from that analysis. This PR now closes only the gap #36327 leaves: what happens to those pins during an app update. A human decides whether #34339 should instead be closed as superseded. This PR closes nothing.
On main,
sandbox_argv._live_plan_hostputsapps/<app>(along with every other parent of a declared file) intoparent_pins, whichpin_seal_parentsbinds before the masks. An app update replacesapps/<app>from the gateway's namespace, then renamesdata/into the new folder (manager_install.update_app, throughshutil.move). A mount stays on the mount it was placed through. Thedata/pin and the masks were placed through the pin of the OLDapps/<app>, so they stay with the retired folder. In the running session,apps/<app>/data/<entry>now resolves through the new folder, where nothing is mounted, and the credential reads plain until that session spawns again. This comes from reading the code; the real-namespace test below checks it in CI.Why it matters
credentialMasksis how an app keeps a credential on disk away from the agent. #32681 moves Ops Mission Control's PagerDuty / Datadog token store onto it (#34296). Updating an app while a session is running is an ordinary operation.Not a goal
apps/(apps/meetings/data,apps/aws-control). Only app-declared masks are in scope.What changed (motivation → approach → change)
Symptom → cause → change: a running session reads a declared credential after an app update →
apps/<app>was pinned before the masks, so the masks hang off the retired folder's pin → on the namespace backend, theapps/<app>folder of each app that declares a mask is taken out ofparent_pinsand put in a new plan list,mask_parent_pins. A new last mask stage,pin_mask_parents, binds each of those folders over itself after every mask.apps/<app>is unpinned, so thedata/pin and the masks sit on the mount that the update's rename ofdata/keeps.rename(apps/<app>)fail with EBUSY, as on main.os.path.realpath), not by its spelling, so a linked data-home spelling, or one reached by walking anagentReadOnlyDirsseal through its link, moves too. One spelling per folder is bound. A link entry is pinned as itself and stays with the pins placed first. The folder is read from the fixedapps/<app>/data/components, so an app nameddatais found too. An operator read-only parent pin on that folder moves the same way.Stated limit (GPT 6.1 F2's residual, not hidden): the replacement
apps/<app>that an update creates did not exist at spawn. A session that is already running can rename it until its next spawn, and the next spawn then finds no manifest at the declared name. Inside a running mount namespace this cannot be closed with another pin. The fix is the layout change in the follow-up issue. The limit is written inapp-kit-platform.mdsection 37,security.md, themanifest-reference.mdbullet, and ashortcut:comment insandbox_argv.py.Docs:
app-kit-platform.mdsection 37,security.md(app-declared credential masks),manifest-reference.md(credential masks).Backwards compatibility
Compatible. The same folders are pinned, so a sandboxed process can still create and edit files inside a declaring app's folders and cannot rename them, exactly as on main. Only the order changes: one folder per app is pinned last instead of first. A spawn with no declaring app plans exactly as on main, because
mask_parent_pinsis empty.Reader: src/kiro_crew/sandbox_launcher_parts/mask_stages.py:pin_mask_parents -- chat|cron|subagent -- binds each declaring app's folder over itself after every mask (test_a_credential_masking_app_folder_is_bound_over_itself_recursively, test_an_app_folder_that_changes_while_it_is_pinned_refuses_the_spawn, test_a_child_run_takes_every_stage_once_in_order)
Reader: src/kiro_crew/sandbox_launcher_program.py:Launch -- chat|cron|subagent -- reads the new mask_parent_pins key, which the planner in the same package always emits (test_namespace_launcher_payload_carries_the_app_folder_pin)
Tests
test_namespace_pins_the_app_folder_after_the_masks(3 modes):apps/demois inmask_parent_pinsand not in the pins placed before the masks;apps,data/anddata/tokensstay with the pins placed first. No after-mask pin sits above another, and the leaf itself is not pinned.test_namespace_pins_every_parent_of_a_declared_leaf(from fix(sandbox): pin the parents of every hidden crew-home leaf #36327, now reading both lists): every parent is still pinned.test_a_linked_spelling_of_the_app_folder_is_pinned_after_the_masks_too: with~/.kirocrewlinked to the data home, no spelling ofapps/demois pinned before the masks, and exactly one is pinned after them (fails on the previous head).test_an_app_named_data_has_its_folder_pinned_after_the_masksandtest_a_link_into_the_app_folder_stays_pinned_before_the_masks(both fail on the previous head).test_namespace_pins_no_app_folder_after_the_masks_without_a_declaration,test_seatbelt_plan_has_no_after_mask_pins,test_namespace_launcher_payload_carries_the_app_folder_pin.test_a_credential_masking_app_folder_is_bound_over_itself_recursively,test_an_app_folder_that_changes_while_it_is_pinned_refuses_the_spawn, and the stage-order lists (pin_mask_parentsruns last of the mask stages). The launcher golden gains the empty key.test_seal_parent_pin_real_sandbox.py::test_a_declared_credential_stays_masked_and_its_folders_stay_put(standard and strict; CI's namespace-sandbox job runs it). Inside the real sandbox it checks that renamingapps/demo/dataorapps/demofails with EBUSY and that a sibling write works. The test then plays the gateway and movesdata/into a newapps/demomid-session. After that move, the token must still be unreadable anddata/must still refuse a rename.Proof: PROVEN test_app_credential_masks.py::TestThePlanHidesTheDeclaredLeaves::test_namespace_pins_the_app_folder_after_the_masks[standard|cc|strict], test_namespace_launcher_payload_carries_the_app_folder_pin, test_sandbox_launcher_program.py::test_a_credential_masking_app_folder_is_bound_over_itself_recursively (head b81cc76)
Each of these fails with main's four source files swapped in and passes on this head. The kernel-level proof is the real-namespace test, which only CI can run, because this worker's host cannot create a user namespace (unshare EPERM).
Local: every
test/test_sandbox*,test/test_seal*andtest/test_app_credential*file at-n 2: 3,938 passed, 40 skipped (withtest_app_agent_readonly_dirs.py). The one failure,test_the_seatbelt_profile_is_the_golden, is a host tmp-path regex-escaping difference in a Seatbelt rule this PR does not touch, and it fails the same way on main on this host. Line-cap, comment-history (against origin/main) and docs lint pass.Manual verification
Not run by hand. The behaviour is in the kernel's mount semantics, which the real-namespace test above checks in CI. There is no user-visible UI change, so there are no screenshots.
Related Issues
Part of #32681. Builds on #36327. Needed by #34296.
Sibling sweep
Swept: git grep -n "parent_pins|readonly_ancestor_guards" -- src/kiro_crew
Sibling: src/kiro_crew/sandbox_plan.py -- operator parent pins skip an after-mask folder (changed here)
Siblings: none -- the seal pins of
agentReadOnlyDirsfolders are placed before the seals by design; a declaring app's folder among them moves with this changePattern harvest
Not generalizable:
apps/<app>is the only pinned folder the gateway replaces, rather than renames, while sessions run.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.