Skip to content

fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend - #34339

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/32681-mask-rename-guard
Nov 18, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/32681-mask-rename-guard

Conversation

@JLargent42

@JLargent42 JLargent42 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the Linux namespace sandbox, a file an app declares in credentialMasks stays 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_host puts apps/<app> (along with every other parent of a declared file) into parent_pins, which pin_seal_parents binds before the masks. An app update replaces apps/<app> from the gateway's namespace, then renames data/ into the new folder (manager_install.update_app, through shutil.move). A mount stays on the mount it was placed through. The data/ pin and the masks were placed through the pin of the OLD apps/<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

credentialMasks is 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

  • Re-pinning anything fix(sandbox): pin the parents of every hidden crew-home leaf #36327 already pins. The set of pinned folders does not change.
  • Seatbelt. It is unchanged; its guards are path rules, which an update does not move.
  • The core hidden leaves under apps/ (apps/meetings/data, apps/aws-control). Only app-declared masks are in scope.
  • Closing the residual below. That needs a layout change, tracked as a follow-up issue (linked in a comment).

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, the apps/<app> folder of each app that declares a mask is taken out of parent_pins and 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.

  • While the other pins and the masks are placed, apps/<app> is unpinned, so the data/ pin and the masks sit on the mount that the update's rename of data/ keeps.
  • The app folder's recursive pin, bound last, adds one copy of what is below it. It still makes rename(apps/<app>) fail with EBUSY, as on main.
  • One level: one pin per app per spelling. These folders never nest, so no after-mask pin copies another, and the mount count does not compound. That was the GPT 6.1 mount-limit finding on the old recursive design, which is gone. The pins bound before the masks are main's, minus those folders.
  • A pin is matched to an app folder by the folder it resolves to (os.path.realpath), not by its spelling, so a linked data-home spelling, or one reached by walking an agentReadOnlyDirs seal 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 fixed apps/<app>/data/ components, so an app named data is 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 in app-kit-platform.md section 37, security.md, the manifest-reference.md bullet, and a shortcut: comment in sandbox_argv.py.

Docs: app-kit-platform.md section 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_pins is 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/demo is in mask_parent_pins and not in the pins placed before the masks; apps, data/ and data/tokens stay 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 ~/.kirocrew linked to the data home, no spelling of apps/demo is 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_masks and test_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_parents runs 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 renaming apps/demo/data or apps/demo fails with EBUSY and that a sibling write works. The test then plays the gateway and moves data/ into a new apps/demo mid-session. After that move, the token must still be unreadable and data/ 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* and test/test_app_credential* file at -n 2: 3,938 passed, 40 skipped (with test_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 agentReadOnlyDirs folders are placed before the seals by design; a declaring app's folder among them moves with this change

Pattern harvest

Not generalizable: apps/<app> is the only pinned folder the gateway replaces, rather than renames, while sessions run.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners November 10, 2026 05:18
@JLargent42
JLargent42 requested a review from buluoray November 10, 2026 05:18
@JLargent42 JLargent42 self-assigned this Nov 10, 2026
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: aecbe07

  • What rule changed: on the Linux namespace backend, every parent of an app-declared credentialMasks leaf now joins the launcher's parent pins (readonly_ancestor_guards → parent_pins), as on Seatbelt it already joined the literal rename guards. Before, app_mask_parents was () when the backend was the namespace launcher.
  • Before -> after: before, a sandboxed process could rename apps/<app>/data and the next spawn masked a path where nothing was left, leaving the credential plain at its new name. After, each parent the spawn could rename is bound over itself before any mask, so rename(2) refuses with EBUSY and the declared path keeps naming the file.
  • Worst case if wrong: a pin on a folder an app's own backend needs to create or remove would break that backend. That spawn's lifted spelling keeps its parents unpinned (test_namespace_leaves_the_parents_unpinned_for_the_leafs_own_backend); for every other spawn the folders stay writable inside, only their entries are fixed.
  • No regression:
    • Evidence checked: the new tests fail on main and pass here; the plan's pins and the launcher payload both carry every parent of both spellings at both crew prefixes; the leaf itself is not pinned.
    • Tools still work: no shipped app declares a mask on main, so every current spawn plans exactly as before; the pin stage is the existing one used for seal parents and skips absent names.
    • Backward compatible: files inside a declaring app's data folders stay creatable and editable by sandboxed processes; only renaming or removing the folders above a declared file is refused.
  • Existing tests: 10,223 sandbox, security, app-credential-mask and app-backend tests pass locally at -n 2; the Seatbelt profile golden fails identically on main on this host.
  • How to undo: revert the commit; the guard tuple goes back to empty on the namespace backend.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/sandbox_argv.py

  • src/kiro_crew/sandbox_launcher_parts/mask_stages.py

  • src/kiro_crew/sandbox_launcher_program.py

  • src/kiro_crew/sandbox_plan.py

  • @JLargent42 posted a complete reasoning template for b81cc76.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 5 — symptom-level: the cause is credentials living under a folder an update replaces. The description admits this ("the fix is the layout change in the follow-up issue"), and the shortcut: comment records the residual. This is accepted and deferred, so it needs no action here.

What this change ships

Inventory (6 items) — 5 justified

Intent: keep an app-declared credential masked in a running Linux sandbox session after the gateway updates that app. FIX.

  1. On Linux, a declared credential stays unreadable in a running session after an app update — justified
  2. The declaring app's folder is now pinned after every mask instead of before; the set of pinned folders is unchanged — justified
  3. A new mask_parent_pins plan/payload key and a pin_mask_parents launcher stage, which shares _pin_over_themselves with pin_seal_parents (1 producer, 1 consumer each) — justified
  4. An operator read-only parent pin on that app folder also moves after the masks — justified
  5. A running session can still rename the replacement apps/<app> until it next spawns; this is documented in three docs — symptom-level, cause deferred to a layout change
  6. The spawn refusal text names which kind of folder moved ("the folder of a credential-masking app") — justified

[FIRST-PRINCIPLES-REVIEWED] b81cc76

Description read

[DESCRIPTION-READ] a639bd7453837deb2a75fa28a8c26ff0ddc32a7023a36dccb22c4b1f1ec24817

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • _gateway_moves_the_app_data renames apps/demo first. update_app moves data/ out to apps/.<name>-data-tmp before it replaces the folder (manager_install.py:857-875). Both orders should leave the mounts in the same place, but copying the real order into the CI namespace test would prove the path users actually hit.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b81cc76

False positive or not applicable? A repository writer can comment:
/ai-review override gpt b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b81cc76

Verdict parsed from the review's SHA-scoped output markers for commit b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128.

False positive or not applicable? A repository writer can comment:
/ai-review override fable b81cc76d5f5a9872abfec3b5fc4ab63a58ed2128 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 10, 2026
@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from aecbe07 to 93bf904 Compare November 10, 2026 06:13
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 93bf904

  • What rule changed: on the Linux namespace backend, every parent of an app-declared credentialMasks leaf this uid could rename now goes to a new launcher list, mask_parent_pins, bound over itself by a new last mask stage (pin_mask_parents), as on Seatbelt it already joined the literal rename guards. The seal-parent pins are unchanged. Before, app_mask_parents was () when the backend was the namespace launcher.
  • Before -> after: before, a sandboxed process could rename apps/<app>/data and the next spawn masked a path where nothing was left, leaving the credential plain at its new name. After, each such parent is bound over itself after every mask, so rename(2) refuses with EBUSY and the declared path keeps naming the file; because the pins land after the masks, a host-side app update that moves data/ into a new apps/<app> still finds the mask on the outer mount in a running session.
  • Worst case if wrong: a pin on a folder an app's own backend needs to create or remove would break that backend. That spawn's lifted spelling keeps its parents unpinned (test_namespace_leaves_the_parents_unpinned_for_the_leafs_own_backend); for every other spawn the folders stay writable inside, only their entries are fixed.
  • No regression:
    • Evidence checked: the new tests fail on main and pass here; the plan's pins and the launcher payload both carry every parent of both spellings at both crew prefixes; the leaf itself is not pinned.
    • Tools still work: no shipped app declares a mask on main, so every current spawn plans exactly as before; the pin stage is the existing one used for seal parents and skips absent names.
    • Backward compatible: files inside a declaring app's data folders stay creatable and editable by sandboxed processes; only renaming or removing the folders above a declared file is refused.
  • Existing tests: 10,223 sandbox, security, app-credential-mask and app-backend tests pass locally at -n 2; the Seatbelt profile golden fails identically on main on this host.
  • How to undo: revert the commit; the guard tuple goes back to empty on the namespace backend.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 10, 2026
@JLargent42

Copy link
Copy Markdown
Contributor Author

AI review disposition for aecbe07, addressed in 93bf904:

  • Opus 5.5 Review, sandbox_argv.py:441, the new nested parent pins strand a declared mask when the gateway moves data/ into a new apps/<app> on an update: fixed by changing where the pins land, not by dropping them. The declared parents are now their own list (mask_parent_pins), bound by a new last mask stage (pin_mask_parents) after every mask, file masks included. The mask itself is therefore placed on the outer mount, the one the host-side move keeps, and each recursive pin only adds a copy of it above; a running session's lookup after the move reaches the original. The seal-parent pins are back to byte-identical with main. Spec sentence corrected in app-kit-platform.md section 37 and security.md. Tests: test_a_credential_mask_parent_is_bound_over_itself_recursively, the stage-order lists (pin_mask_parents last), the payload test (their own list, not parent_pins). Residual, stated: after such a host-side move, that one session's pins on the replaced folder are gone until its next spawn; its masks are not.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 10, 2026
@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from 93bf904 to 251f350 Compare November 10, 2026 07:29
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 251f350

  • What rule changed: on the Linux namespace backend, every parent of an app-declared credentialMasks leaf this uid could rename now goes to a new launcher list, mask_parent_pins, bound over itself by a new last mask stage (pin_mask_parents), as on Seatbelt it already joined the literal rename guards. The seal-parent pins are unchanged. Before, app_mask_parents was () when the backend was the namespace launcher.
  • Before -> after: before, a sandboxed process could rename apps/<app>/data and the next spawn masked a path where nothing was left, leaving the credential plain at its new name. After, each such parent is bound over itself after every mask, so rename(2) refuses with EBUSY and the declared path keeps naming the file; because the pins land after the masks, a host-side app update that moves data/ into a new apps/<app> still finds the mask on the outer mount in a running session.
  • Worst case if wrong: a pin on a folder an app's own backend needs to create or remove would break that backend. That spawn's lifted spelling keeps its parents unpinned (test_namespace_leaves_the_parents_unpinned_for_the_leafs_own_backend); for every other spawn the folders stay writable inside, only their entries are fixed.
  • No regression:
    • Evidence checked: the new tests fail on main and pass here; the plan's pins and the launcher payload both carry every parent of both spellings at both crew prefixes; the leaf itself is not pinned.
    • Tools still work: no shipped app declares a mask on main, so every current spawn plans exactly as before; the pin stage is the existing one used for seal parents and skips absent names.
    • Backward compatible: files inside a declaring app's data folders stay creatable and editable by sandboxed processes; only renaming or removing the folders above a declared file is refused.
  • Existing tests: 10,223 sandbox, security, app-credential-mask and app-backend tests pass locally at -n 2; the Seatbelt profile golden fails identically on main on this host.
  • How to undo: revert the commit; the guard tuple goes back to empty on the namespace backend.

@JLargent42

Copy link
Copy Markdown
Contributor Author

AI review notes on 93bf904, addressed in 251f350:

  • First Principles, item 5, plan.get("mask_parent_pins", ()) guards an older payload the same package never sends: fixed. Read with plan["mask_parent_pins"] like every other key; test_an_older_payload_pins_no_credential_mask_parent deleted.
  • Design, a gateway app update reopens the gap for an already-running session: stated in app-kit-platform.md section 37. That session keeps its masks (the point of pinning after them) but loses its pins on the replaced folder until its next spawn.
  • Design, prove the mount semantics in a real namespace: added test_a_declared_credential_stays_masked_and_its_folders_stay_put to test_seal_parent_pin_real_sandbox.py, which the namespace-sandbox CI job already runs. Inside the sandbox, renaming apps/demo/data and apps/demo must fail with EBUSY, a sibling write must succeed, and the token must be unreadable before and after the test, playing the gateway, moves data/ into a new apps/demo mid-session.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 10, 2026
@Zedmor

Zedmor commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Code change approver recommendation: A person should decide

Automated, not a person, and not a review: a maintainer still decides.

decider-v3c@217fe607 · p_defect 0.62 · router R0 (approves only when p_defect <= 0.12, on changes of at most 400 changed lines) · head 251f3507e7 · 338 changed lines

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):

  • [goal_unmet/high] The stated goal is that a declared credential stays masked across sessions because no sandboxed process can rename the folders above it. After an ordinary app update during a running session, that session can rename apps//data. The next spawn then masks the declared path, which is now empty, an (src/kiro_crew/sandbox_launcher_parts/mask_stages.py)

If this recommendation is wrong, reply here; the replies are how the approver is evaluated.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 10, 2026
@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from 6cf90fe to 3ff76d7 Compare November 18, 2026 07:48
@JLargent42 JLargent42 changed the title fix(sandbox): pin a declared credential mask's parents on the namespace backend fix(sandbox): pin a credential-masking app's folder after the masks on the namespace backend Nov 18, 2026
@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: 3ff76d7

  • What rule changed: on the Linux namespace backend, the apps/<app> folder of each app that declares a credentialMasks file leaves parent_pins (bound before the masks by pin_seal_parents) and goes to a new launcher list, mask_parent_pins, which a new last mask stage (pin_mask_parents) binds over itself after every mask. Nothing else moves. The set of pinned folders is the one fix(sandbox): pin the parents of every hidden crew-home leaf #36327 pins on main. Seatbelt is unchanged.
  • Before -> after: before, an app update during a running session replaced apps/<app> and renamed data/ into it. The data/ pin and the masks had been placed through the old folder's pin, so they stayed with the retired folder, and the session read the restored credential plain until its next spawn. After, data/'s pin and the masks sit on the mount that the rename of data/ keeps, and the app folder still refuses a rename with EBUSY.
  • Worst case if wrong: if the order change did not hold, the app folder would still be pinned (after the masks instead of before), so rename protection is no weaker than main's. The update case would stay as exposed as on main. A failed pin refuses the spawn, as the seal-parent pins do.
  • Mount count: one extra recursive pin per declaring app per spelling, never nested, so nothing compounds (the GPT 6.1 mount-limit finding on the old recursive design no longer applies).
  • Stated residual (GPT 6.1 F2): the replacement apps/<app> that an update creates did not exist at spawn, so a running session can rename it until its next spawn. It is written in section 37, security.md, the manifest reference and a shortcut: comment. The fix is a layout change, tracked as a follow-up issue.
  • No regression:
    • Evidence checked: the new plan, payload and launcher tests fail with main's four source files and pass here. test_namespace_pins_every_parent_of_a_declared_leaf from fix(sandbox): pin the parents of every hidden crew-home leaf #36327 still holds across both lists. The real-namespace update test runs in CI's namespace-sandbox job; this host cannot create a user namespace.
    • Tools still work: with no declaring app, mask_parent_pins is empty and every spawn plans exactly as on main.
    • Backward compatible: the same folders are pinned, with the same writable contents.
  • Existing tests: 3,883 sandbox, seal and app-credential-mask tests pass locally at -n 2. The Seatbelt profile golden fails identically on main on this host (tmp-path regex escaping).
  • How to undo: revert the commit. apps/<app> goes back into parent_pins.

This PR stays flagged for human review.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Follow-up for the residual this PR states (a running session can rename the replacement apps/<app> that an update creates): #39037 proposes one top-level app-credentials folder, so a single pin covers every app and the mount count does not grow with apps. It needs the sandbox owner's OK before any code.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 18, 2026
@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from 3ff76d7 to c861977 Compare November 18, 2026 08:23
@JLargent42

Copy link
Copy Markdown
Contributor Author

AI review findings on 3ff76d7, addressed in c861977 (fix round 1):

  • Opus 5.5, sandbox_argv.py:559: under a linked data home, a resolved spelling of apps/<app> (for example one reached by walking an agentReadOnlyDirs seal through its link) stayed pinned before the masks, because pins were matched by string: fixed as suggested. A guard now moves to mask_parent_pins when os.path.realpath of it is a declaring app's folder, and only one spelling per folder is bound, because a second bind of the same folder would stack on the first and copy it. An operator read-only parent pin on that folder moves the same way. Test: test_a_linked_spelling_of_the_app_folder_is_pinned_after_the_masks_too, which fails on 3ff76d7.
  • PR Policy, Cross-Platform Portability: leaf.split("/"): fixed. The app folder now comes from str.partition("/data/") on the crew-relative leaf, which is /-separated by contract, so no path is split by hand.
  • CodeQL Analyze (javascript-typescript, python): both failed with "API rate limit exceeded for installation", not on a finding. They re-run on this push.
  • GPT 6.1 on 3ff76d7: no findings.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: c861977

  • What rule changed: on the Linux namespace backend, the apps/<app> folder of each app that declares a credentialMasks file leaves parent_pins (bound before the masks by pin_seal_parents) and goes to a new launcher list, mask_parent_pins, which a new last mask stage (pin_mask_parents) binds over itself after every mask. Nothing else moves. The set of pinned folders is the one fix(sandbox): pin the parents of every hidden crew-home leaf #36327 pins on main. Seatbelt is unchanged.
  • Before -> after: before, an app update during a running session replaced apps/<app> and renamed data/ into it. The data/ pin and the masks had been placed through the old folder's pin, so they stayed with the retired folder, and the session read the restored credential plain until its next spawn. After, data/'s pin and the masks sit on the mount that the rename of data/ keeps, and the app folder still refuses a rename with EBUSY.
  • Worst case if wrong: if the order change did not hold, the app folder would still be pinned (after the masks instead of before), so rename protection is no weaker than main's. The update case would stay as exposed as on main. A failed pin refuses the spawn, as the seal-parent pins do.
  • Matching: a pin moves to the after-mask list when it resolves (os.path.realpath) to a declaring app's folder, so a linked spelling moves too; one spelling per folder is bound.
  • Mount count: one extra recursive pin per declaring app folder, never nested, so nothing compounds (the GPT 6.1 mount-limit finding on the old recursive design no longer applies).
  • Stated residual (GPT 6.1 F2): the replacement apps/<app> that an update creates did not exist at spawn, so a running session can rename it until its next spawn. It is written in section 37, security.md, the manifest reference and a shortcut: comment. The fix is a layout change, tracked as a follow-up issue.
  • No regression:
    • Evidence checked: the new plan, payload and launcher tests fail with main's four source files and pass here. test_namespace_pins_every_parent_of_a_declared_leaf from fix(sandbox): pin the parents of every hidden crew-home leaf #36327 still holds across both lists. The real-namespace update test runs in CI's namespace-sandbox job; this host cannot create a user namespace.
    • Tools still work: with no declaring app, mask_parent_pins is empty and every spawn plans exactly as on main.
    • Backward compatible: the same folders are pinned, with the same writable contents.
  • Existing tests: 3,936 sandbox, seal, app-credential-mask and agent-read-only-dir tests pass locally at -n 2. The Seatbelt profile golden fails identically on main on this host (tmp-path regex escaping).
  • How to undo: revert the commit. apps/<app> goes back into parent_pins.

This PR stays flagged for human review.

@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from c861977 to fc16270 Compare November 18, 2026 08:48
@JLargent42

Copy link
Copy Markdown
Contributor Author

GPT 6.1 findings on c861977, addressed in fc16270 (fix round 2 of 2):

  • F1, sandbox_argv.py:609 / :566: realpath matching folded a link entry into the app folder's pin, so the link could be retargeted: fixed as suggested. Only a directory entry moves after the masks (not os.path.islink(pin)), both for the guard list and for the operator read-only pins. A link entry is pinned as itself and stays with the pins placed first. Test: test_a_link_into_the_app_folder_stays_pinned_before_the_masks, which fails on c861977.
  • F2, sandbox_argv.py:552: an app named data (apps/data/data/<entry>) was missed by partition("/data/"): fixed. The folder is read from the fixed components (apps/ prefix, then the name, then data/). Test: test_an_app_named_data_has_its_folder_pinned_after_the_masks, which fails on c861977.
  • Opus 5.5 on c861977: no findings.

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.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: fc16270

  • What rule changed: on the Linux namespace backend, the apps/<app> folder of each app that declares a credentialMasks file leaves parent_pins (bound before the masks by pin_seal_parents) and goes to a new launcher list, mask_parent_pins, which a new last mask stage (pin_mask_parents) binds over itself after every mask. Nothing else moves. The set of pinned folders is the one fix(sandbox): pin the parents of every hidden crew-home leaf #36327 pins on main. Seatbelt is unchanged.
  • Before -> after: before, an app update during a running session replaced apps/<app> and renamed data/ into it. The data/ pin and the masks had been placed through the old folder's pin, so they stayed with the retired folder, and the session read the restored credential plain until its next spawn. After, data/'s pin and the masks sit on the mount that the rename of data/ keeps, and the app folder still refuses a rename with EBUSY.
  • Worst case if wrong: if the order change did not hold, the app folder would still be pinned (after the masks instead of before), so rename protection is no weaker than main's. The update case would stay as exposed as on main. A failed pin refuses the spawn, as the seal-parent pins do.
  • Matching: a pin moves to the after-mask list when it resolves (os.path.realpath) to a declaring app's folder, so a linked spelling moves too; one spelling per folder is bound. A link entry is pinned as itself and stays before the masks, so it cannot be retargeted. The folder is read from the fixed apps/<app>/data/ components, so an app named data is covered.
  • Mount count: one extra recursive pin per declaring app folder, never nested, so nothing compounds (the GPT 6.1 mount-limit finding on the old recursive design no longer applies).
  • Stated residual (GPT 6.1 F2): the replacement apps/<app> that an update creates did not exist at spawn, so a running session can rename it until its next spawn. It is written in section 37, security.md, the manifest reference and a shortcut: comment. The fix is a layout change, tracked as a follow-up issue.
  • No regression:
    • Evidence checked: the new plan, payload and launcher tests fail with main's four source files and pass here. test_namespace_pins_every_parent_of_a_declared_leaf from fix(sandbox): pin the parents of every hidden crew-home leaf #36327 still holds across both lists. The real-namespace update test runs in CI's namespace-sandbox job; this host cannot create a user namespace.
    • Tools still work: with no declaring app, mask_parent_pins is empty and every spawn plans exactly as on main.
    • Backward compatible: the same folders are pinned, with the same writable contents.
  • Existing tests: 3,938 sandbox, seal, app-credential-mask and agent-read-only-dir tests pass locally at -n 2. The Seatbelt profile golden fails identically on main on this host (tmp-path regex escaping).
  • How to undo: revert the commit. apps/<app> goes back into parent_pins.

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.
@JLargent42
JLargent42 force-pushed the fix/32681-mask-rename-guard branch from fc16270 to b81cc76 Compare November 18, 2026 09:28
@JLargent42

Copy link
Copy Markdown
Contributor Author

Test-only follow-up on fc16270, now b81cc76: Backend Tests (3.12, 7) and Backend Tests (Windows) (2) failed the facade-mirror guard (test_facade_mirror_guards.py), because the new link test patched configured_readonly_layer on sandbox_argv instead of through the sandbox facade. It now patches the facade, and it still fails against the previous head's code. No source change. GPT 6.1 had no findings on fc16270. Opus 5.5 and CodeQL there failed on the installation API rate limit, not on a finding.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Sensitive change review

Head: b81cc76

  • What rule changed: on the Linux namespace backend, the apps/<app> folder of each app that declares a credentialMasks file leaves parent_pins (bound before the masks by pin_seal_parents) and goes to a new launcher list, mask_parent_pins, which a new last mask stage (pin_mask_parents) binds over itself after every mask. Nothing else moves. The set of pinned folders is the one fix(sandbox): pin the parents of every hidden crew-home leaf #36327 pins on main. Seatbelt is unchanged.
  • Before -> after: before, an app update during a running session replaced apps/<app> and renamed data/ into it. The data/ pin and the masks had been placed through the old folder's pin, so they stayed with the retired folder, and the session read the restored credential plain until its next spawn. After, data/'s pin and the masks sit on the mount that the rename of data/ keeps, and the app folder still refuses a rename with EBUSY.
  • Worst case if wrong: if the order change did not hold, the app folder would still be pinned (after the masks instead of before), so rename protection is no weaker than main's. The update case would stay as exposed as on main. A failed pin refuses the spawn, as the seal-parent pins do.
  • Matching: a pin moves to the after-mask list when it resolves (os.path.realpath) to a declaring app's folder, so a linked spelling moves too; one spelling per folder is bound. A link entry is pinned as itself and stays before the masks, so it cannot be retargeted. The folder is read from the fixed apps/<app>/data/ components, so an app named data is covered.
  • Mount count: one extra recursive pin per declaring app folder, never nested, so nothing compounds (the GPT 6.1 mount-limit finding on the old recursive design no longer applies).
  • Stated residual (GPT 6.1 F2): the replacement apps/<app> that an update creates did not exist at spawn, so a running session can rename it until its next spawn. It is written in section 37, security.md, the manifest reference and a shortcut: comment. The fix is a layout change, tracked as a follow-up issue.
  • No regression:
    • Evidence checked: the new plan, payload and launcher tests fail with main's four source files and pass here. test_namespace_pins_every_parent_of_a_declared_leaf from fix(sandbox): pin the parents of every hidden crew-home leaf #36327 still holds across both lists. The real-namespace update test runs in CI's namespace-sandbox job; this host cannot create a user namespace.
    • Tools still work: with no declaring app, mask_parent_pins is empty and every spawn plans exactly as on main.
    • Backward compatible: the same folders are pinned, with the same writable contents.
  • Existing tests: 3,938 sandbox, seal, app-credential-mask and agent-read-only-dir tests pass locally at -n 2. The Seatbelt profile golden fails identically on main on this host (tmp-path regex escaping).
  • How to undo: revert the commit. apps/<app> goes back into parent_pins.

This PR stays flagged for human review.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 18, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 18, 2026 11:10

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with configured_readonly_layer returning apps/demo/trust could assert that apps/demo is in mask_parent_pins exactly once and not in runtime_ancestor_guards.
  • _gateway_moves_the_app_data renames apps/demo before it moves data/. update_app moves data/ to .demo-data-tmp first. 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.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 18, 2026
@KiroCrewCaptain
KiroCrewCaptain merged commit 716a6a4 into main Nov 18, 2026
110 of 115 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/32681-mask-rename-guard branch November 18, 2026 11:31
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants