Repository navigation
fix: guard parent folders of caller-provided hidden paths in the Linux sandbox - #39551
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 The caller-mask guards on Linux land at mechanism level. The reversed "Seatbelt only" pin has support in the base's own reasoning that a later session re-resolves a masked path by name. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: stop a sandboxed agent from renaming the folders above a caller-hidden path on Linux, so a later session's mask does not miss the moved content. FIX.
[FIRST-PRINCIPLES-REVIEWED] da205dd Description read[DESCRIPTION-READ] db32fdd47f4006c125f15d3bc5867d9fa5cc0b3f34c6ccf05c6337227cd22c7b 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. This applies the documented rule that every hidden spelling's parent is guarded on both backends ( Notes
[DESIGN-REVIEWED] da205dd Description read[DESCRIPTION-READ] 56b605d028139168ed0d80b122ee19e4b8e23eeb73cd899f7a804342a445313e 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 |
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: |
GPT 6.1 Review — ✅ human override acceptedHuman judgment by @chenmingwei23 overrides the GPT 6.1 finding for [GPT-OVERRIDE] da205dd This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
Plan-level tests for both backends: a caller-provided hidden file under a writable parent gets a guard on the parent and its ancestors, the file stays write-sealed, and the built-in guard set is unchanged. The namespace expectations fail on main.
Hidden paths a caller passes to the sandbox now get the same parent-folder rename guards as the built-in hidden paths on the Linux backend, limited to the folders this user could rename. The macOS guards are unchanged. Parents stay writable and the hidden set is unchanged.
bb513e6 to
da205dd
Compare
Sensitive change review
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own. Extends the existing parent-rename pins (renameable-by-uid filter, pin_seal_parents, app folder pinned after masks) to caller extra_hidden_dirs on the Linux namespace backend, matching the documented rationale for crew-home hidden leaves (a Linux mask moves with its parent so the next spawn reads the leaf). The Seatbelt output is unchanged; the namespace plan keeps only guards above live, non-cancelled caller masks, folded consistently with mask paths. Tests would fail without the change. No concrete regression path found; spec drift, missing real-sandbox coverage and the added EXDEV cost are noted as non-blocking. Tier: 2, held for a person: security-sensitive path. 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 |
Sensitive change review
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the Linux follow-up to #39273. On this head the review read the full diff and confirmed the namespace branch now builds caller guards with _renameable_ancestor_guards, the same helper the built-in and operator pins use. The plan keeps only guards above a live, uncancelled caller mask, the pins run before the masks with a recursive bind, and no mask, seal or read-only mount is undone. All 6 new or changed tests fail at the test-only commit 46513a4 and pass at the head. Done well: no new pin mechanism, so Linux and macOS now pick the same guard set.
Two things need to change before merge. Both are about what the PR says, not the code.
## Real-machine verificationsays N/A, but this diff changes what every Linux spawn withextra_hidden_dirsmounts, and a pin that cannot be placed stops the spawn. The repository allows N/A only when the diff runs nothing. Please reproduce on the base (a parent such as~/.configabove a caller mask can be renamed inside the sandbox), run the same command on this head (the rename returnsEBUSY, sibling writes still work, the spawn exits 0), and record machine, before, after and cleanup. A caller-mask case intest/test_seal_parent_pin_real_sandbox.pywould also keep this pinned in CI.## Backwards compatibilitysays "Removes nothing" and "nothing that works today is rejected". Inside the sandbox, renaming or removing a guarded parent such as~/.config,~/.dockeror~/.kubenow fails withEBUSY, a rename across one of those folders fails withEXDEV, and a pin that cannot be placed stops the spawn. Please say so, with theReader:lines the take-away rule asks for. This needs only a body edit.
Security: this touches the sandbox files and only adds pins. No mask, seal or refusal is removed, the pins keep every seal and mask below them, and a parent the check cannot inspect counts as renameable, so the check fails toward pinning.
Optional:
- The
not m.cancelledandorigin == "caller"predicates in the new plan filter can be deleted without any test going red. - The body's test counts (4 then 87) should be 6 then 89.
|
Thanks for the review. The body is updated on the same head (da205dd), no code change:
The two optional predicate cleanups are noted as a follow-up. |
|
Real-machine verification is now filled in, on the same head (da205dd), no code change. It ran in the
Both draft PRs are closed now. The backwards-compatibility text and the 6/89 test counts are as updated earlier. |
|
Thanks for the body update. On this head (da205dd) the review read the full diff again. The Linux branch reuses Follow-up on the earlier change request:
This PR needs a maintainer for two things. Someone must run the real namespace sandbox, or decide the evidence is enough. Someone must also clear the PR Readiness failure: one AI lane finding points at Security: this PR changes sandbox files but only adds pins. It removes no mask, seal or refusal, so it does not widen what the sandbox allows. Optional:
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for the Linux follow-up to #39273. On this head the review read the full diff. It also confirmed that reverting the two production hunks makes exactly the six named tests fail, while the head passes 89. The new tests use only tmp_path and monkeypatch. Done well: Linux and macOS now build caller guards from the same caller_parents list with the existing helpers, and a caller parent that is an app folder is still pinned after the masks.
Follow-up on the earlier change request:
- Real-machine verification: fixed. The two namespace-sandbox jobs named in the body ran, both concluded success, and their logs show
rename rc=renamedon main plus the test, andrc=EBUSY/rc=EXDEVon this head plus the test. The earlier follow-up comment that called this pending read an older body. - Backwards compatibility: fixed. The body names the
EBUSY/EXDEVcost and the fail-closed spawn, and addsReader:lines. The test counts are corrected.
Security: this touches the sandbox files, but it only adds rename pins. It removes no mask, seal or refusal. Pins are placed before the masks and keep every seal below them. A parent the check cannot inspect counts as renameable, so the check fails toward pinning. Nothing that main refuses is now allowed.
Optional:
- Commit the real-sandbox case from the draft PR (
TestACallerHiddenFilesParentStaysInPlace) to this repository, so CI keeps checking that a caller parent pin refuses a rename. - Add one sentence to
docs/system-specs/modules/security.mdnear line 2276: the existing, renameable parents of callerextra_hidden_dirsentries are pinned the same way, with the sameEBUSY/EXDEVcost. - No test fails if you delete the caller-side
app_dir_pins.setdefaultloop insandbox_argv.py(around line 600). A case where the spawn lifts the app's declared leaf withextra_visible_dirsand asserts the app folder is inmask_parent_pinswould catch that.
|
/ai-review override gpt da205dd false-positive: the superseded GPT block (run 44692496479 attempt 1) pointed at test/integration/test_app_release_upgrade_auth.py:523, which this PR does not touch; its diff is only sandbox_argv.py, sandbox_plan.py and test_sandbox_plan.py. GPT runs 44697952448 and 44692496479 attempt 2 on this head found no blocking issue. |
Human judgment recorded@chenmingwei23 recorded a false-positive release (class
This decision applies only to this commit. A new push requires a new judgment. |
Problem / Motivation
Goal: Hidden paths a caller passes to the sandbox get the same parent-folder rename guards as the built-in hidden paths, on Linux and macOS.
The Linux sandbox now follows the same rule as the built-in hidden paths.
Why it matters
Callers that pass
extra_hidden_dirsexpect the same protection as the built-in hidden set. The guard set should not depend on who named the path or on the backend.Not a goal
What changed (motivation -> approach -> change)
Reuse the existing guard helpers so caller-provided hidden paths are guarded like the built-in ones in the Linux sandbox. The macOS guards are unchanged.
Backwards compatibility
Behaviour change on the Linux namespace backend only (macOS already guarded these paths): inside the sandbox, the parent folders of a caller-provided hidden path (for example
~/.config,~/.dockeror~/.kubewhen a file below them is hidden) are now pinned. Renaming or removing such a parent fails withEBUSY, and renaming something across one of them fails withEXDEV. Files inside those folders stay readable and writable as before. If a pin cannot be placed, the spawn stops instead of running without the guard.Removes nothing: no path, key, validator or function is removed; the change only adds pins, and no mask, seal or read-only mount is undone.
Reader: src/kiro_crew/sandbox_argv.py:_live_plan_host -- chat -- a session spawn with extra_hidden_dirs now lists the renameable parents of each caller entry; test_namespace_guards_every_ancestor_of_a_caller_mask_against_rename
Reader: src/kiro_crew/sandbox_plan.py:_namespace_plan -- app -- an app backend spawn pins a caller parent that is the app's own folder after the masks, like the read-only and operator pins; test_live_host_pins_a_caller_parent_that_is_an_app_folder_after_the_masks
Reader: src/kiro_crew/sandbox_argv.py:_live_plan_host -- subagent -- only parents this uid could rename are pinned, so a spawn with a hidden path under a foreign or missing folder starts as before; test_live_host_filters_caller_parents_by_what_this_uid_can_rename
Tests
test_namespace_guards_every_ancestor_of_a_caller_mask_against_rename: Linux plan lists the parent and ancestors of a caller entry, drops unrelated host guards, and keeps the built-in guards in front.test_a_caller_mask_file_is_sealed_and_its_parent_guarded_on_both_backends: a caller hidden file keeps its write seal on macOS, its parent is guarded on both backends, and the built-in guards are the same with and without the entry.test_live_host_guards_only_the_caller_ancestors_that_exist: both backends list existing parents only.test_seatbelt_guards_every_ancestor_of_a_caller_mask_against_rename: the Linux expectation is updated.Proof: not provable -- other: prove.py was not run on the crew; red then green was run by hand (6 failed on the test commit, 89 passed with the fix).
Manual verification
N/A -- unit coverage of the plan builders is sufficient; no real sandbox run.
Real-machine verification
Run on the KiroCrew CI runner of the
Backend Tests (namespace sandbox)job (GitHub-hosted ubuntu-latest, unprivileged user namespaces enabled, the real namespace sandbox), through two throwaway draft PRs that add one test,test/test_sandbox_hidden_leaf_parent_pins.py::TestACallerHiddenFilesParentStaysInPlace::test_renaming_the_parent_folder_is_refused. In a temporary HOME it hides a file under~/.config, then inside the sandbox renames~/.configand moves a file across it.Machine: GitHub Actions ubuntu-latest, x86_64, namespace sandbox job
Before (main + test, #39806 dcb2e1c): the test is marked xfail(strict) there; https://github.com/kirodotdev/KiroCrew/actions/runs/44696690856/job/136157513808 ->
REALMACHINE-39551 rename rc=renamed err=; cross rc=ENOENT err=No such file or directory(the parent rename succeeds; 1 xfailed)After (head da205dd + test, #39807 2aca059): https://github.com/kirodotdev/KiroCrew/actions/runs/44695215425/job/136152949502 ->
REALMACHINE-39551 rename rc=EBUSY err=Device or resource busy; cross rc=EXDEV err=Invalid cross-device link(passed)Cleanup: hosted runner, temporary HOME removed; both draft PRs closed
Screenshots / video
N/A -- no user-visible UI change.
Related Issues
None linked.
Sibling sweep
Swept: git grep -n "caller_ancestor_guards" -- src test
Sibling: src/kiro_crew/sandbox_plan.py -- changed here
Sibling: src/kiro_crew/sandbox_argv.py -- changed here
Sibling: src/kiro_crew/sandbox_plan.py (macOS plan) -- not affected -- already guarded
Pattern harvest
Not generalizable: one-off difference between the two sandbox backends.
Checklist
fix: guard parent folders of caller-provided hidden paths on Linux)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.