Repository navigation
fix(sandbox): skip a leaf absent under a mask the launcher already placed - #15564
Conversation
ae5da10 to
56224a5
Compare
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the second-spelling record key (sandbox.py:8950) is normalized like the walk's [DESIGN-REVIEWED] ac62701 Description read[DESCRIPTION-READ] 9d274df937accfa2c0cb6a03a3be9316397c707c89cb79606bc67fbd58855161 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the one premise that rules out the smaller fix: that a symlinked- What this change shipsInventory (7 items) — 7 justifiedIntent: make sandboxed spawns succeed again when a hidden leaf sits under a directory the same launcher already masked — a FIX (regression from #15252, reproduced in the description and pinned by tests that fail on base).
[FIRST-PRINCIPLES-REVIEWED] ac62701 Description read[DESCRIPTION-READ] c359d23f90ec18646242dcf6fa8f82ce3fc1e8c736a818cc985bcaed57d847a5 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
…aced #15252 made an absent name that a pre-spawn pass recorded an occupant for refuse the spawn, so a protected object moved between the pass and the pin fails closed. A mask list also carries a leaf together with a directory above it: the readiness probe hides the whole data home while every crew hidden leaf under it stays listed. Once the directory's stand-in is bound, the leaf is absent from every later look at its name, and the file loop -- offered every directory entry, always after the directory loop -- reached ~/.kiro/crew/diag with its expectation still carried, read the absence as the object having vanished, and refused. Every probe spawn failed, /api/models answered 503 and Settings showed "Failed to load config". The launcher now records every name it has confirmed reaches one of its own stand-ins (each mask it mounts and reads back, and each second spelling the pin finds already covered), and an absent name skips when a proper ancestor is recorded there and, resolved again now, still reaches that stand-in. Names rather than identities, because the second spelling of a masked directory has no mount of its own and no expectation to compare against. A recorded ancestor that no longer reaches its stand-in refuses the leaf rather than walking higher. Reproduced against the real launcher on a host with a symlinked $HOME: standard mode with the probe's extra_hidden_dirs refused before and exits 0 after, with the data home and both spellings of diag unreachable inside the sandbox.
56224a5 to
ac62701
Compare
|
Disposition for GPT 5.6 F1 on The finding is correct and I verified the mechanism before changing anything: the window bind ( Fix: the launcher now records every window it binds ( Pinned by |
Opus 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: |
Two tests on main fail in the macOS backend suite, each for its own reason. - test_terminal_commands.py::TestRunProbe:: test_the_environment_is_an_allowlist_not_a_filtered_inherit finds KIROCREW_SANDBOX_TOOL in the probe child's environment. #15528 stamps that marker on every tree spawned through sandboxed_spawn_argv on purpose, because the runtime reconciler reads it back from the child. So it joins the named sandbox_injected set, with a leaked- sentinel in the parent like GRADLE_OPTS has, which keeps the check honest: the chokepoint overwrites the name, and a parent value must never reach the child under it. The test runs only where a live sandbox backend exists. GitHub's Linux runners have none, so the Linux shards skip it. - test_sandbox_mount_pinned_target.py:: test_the_directory_loop_records_every_window_it_binds, added by #15564, drives the private-window walk. That walk opens each component with bare os.O_PATH, which only Linux has, so the test raised AttributeError on Darwin. It now carries the file's _LINUX_LINK_PIN skip marker, like the other cases that need O_PATH. Failing job (macOS shard 4 of the PR #15309 run): https://github.com/kirodotdev/KiroCrew/actions/runs/36798238474/job/110167010707
#15680) Two tests on main fail in the macOS backend suite, each for its own reason. - test_terminal_commands.py::TestRunProbe:: test_the_environment_is_an_allowlist_not_a_filtered_inherit finds KIROCREW_SANDBOX_TOOL in the probe child's environment. #15528 stamps that marker on every tree spawned through sandboxed_spawn_argv on purpose, because the runtime reconciler reads it back from the child. So it joins the named sandbox_injected set, with a leaked- sentinel in the parent like GRADLE_OPTS has, which keeps the check honest: the chokepoint overwrites the name, and a parent value must never reach the child under it. The test runs only where a live sandbox backend exists. GitHub's Linux runners have none, so the Linux shards skip it. - test_sandbox_mount_pinned_target.py:: test_the_directory_loop_records_every_window_it_binds, added by #15564, drives the private-window walk. That walk opens each component with bare os.O_PATH, which only Linux has, so the test raised AttributeError on Darwin. It now carries the file's _LINUX_LINK_PIN skip marker, like the other cases that need O_PATH. Failing job (macOS shard 4 of the PR #15309 run): https://github.com/kirodotdev/KiroCrew/actions/runs/36798238474/job/110167010707
Problem / Motivation
Goal: Sandboxed spawns succeed again on hosts where a hidden leaf sits under a directory the same launcher hides, so the kiro-cli readiness probe passes and Settings loads.
Since #15252 landed, every readiness probe spawn on my host is refused with:
gateway.logcarries it every 30 seconds;KAS managed MCP initialization failed: kirocrew-core: failed (backend gone: exit rc=1)follows from the same refusal;/api/modelsanswers 503 and the Settings page shows Failed to load config. Thediagdirectory is present and the gateway is writing to it the whole time.Why it matters
Every operator whose sandbox tier hides a directory that is itself an ancestor of a listed leaf is hit. The readiness probe always is:
kiro_prerequisitepasses the whole data home (~/.kiro/crew) inextra_hidden_dirs, and every_CREW_HIDDEN_LEAVESentry lives under it. With the probe refused the CLI is reported unverified, the model list is unavailable, and Settings cannot render its config panel. No sandbox level short of lowering it clears the refusal.Not a goal
REQUIRED_MASK_TARGETS._verify_masked_nameor the read-only seal loop.What changed (motivation → approach → change)
Root cause.
_pin_mount_pathjudges an absent name by its carried expectation: a pass recorded an object here, nothing is here now, so the object moved -- refuse. That is right for a name nothing else covers. But the mask list carries a leaf together with a directory above it. The directory loop masks~/.kiro/crewby binding an empty stand-in over it; from then on~/.kiro/crew/diagis absent from every look at its name. The file loop is offered every directory entry too (files_json = files + hidden_dirs) and always runs after the directory loop, so it reachesdiag, opens the parent (the stand-in), finds nodiag, sees an expectation carried, and refuses. The builder already subtracts nested targets fromREQUIRED_MASK_TARGETSfor this exact reason ("absent because my parent's mask covers me"), but that subtraction never applied to the carried expectations #15252 added, and it could not: it is lexical against the mask list, while the second spelling of a masked directory (a symlinked$HOME) is not in that list.Approach. Decide it against the filesystem, at the pin, the way #15252 decides the second-spelling case. The launcher records in
_MASKED_NAMESevery name it has confirmed reaches one of its own stand-ins: each directory mask after its read-back (_verify_masked_name), the nested re-hide, the ssh mask, and each second spelling the pin finds already covered. When a name is absent -- the leaf itself, or the directory holding it --_covered_by_own_maskwalks the name's proper ancestors; if one is recorded, that ancestor is resolved again NOW and must still reach the recorded stand-in. Names rather than identities, because the second spelling of a masked directory has no mount of its own and no expectation to compare a stand-in against, yet covers the leaves under it. A recorded ancestor that no longer reaches its stand-in refuses the leaf rather than walking higher. A link at the ancestor is accepted only when it is the link the pin itself followed, as the read-back accepts it. A private window met on the way up ends the walk with a refusal: the window mounts the real tree back over the stand-in read-write, so a leaf beneath it (apps/meetings/data/editsunder theapps/meetings/datawindow) resolves into the real tree and no stand-in above covers it -- the launcher records every window it binds in_BOUND_WINDOWSfor exactly this test.Change.
src/kiro_crew/sandbox.py(launcher template):_MASKED_NAMES,_BOUND_WINDOWS,_covered_by_own_mask, the check ahead of both absence refusals in_pin_mount_path, the four mask recording sites and the window recording site.docs/system-specs/modules/security.mdgains the paragraph that states the invariant and the residual it does not cover.Backwards compatibility
Compatible: the only behaviour that changes is an absent name whose ancestor verifiably reaches this launcher's own stand-in, which today refuses the spawn and now skips as the already-masked leaf it is. Every other absence, and every present-but-changed occupant, takes exactly the branch it took before.
Tests
test/test_sandbox_mount_pinned_target.py, against the shipped pin lifted from the built script:test_a_leaf_absent_under_a_directory_this_launcher_masked_skips-- a leaf and a deeper leaf under a masked parent skip in both absence branches, in the dir loop's kind and the file loop's kind, and as a required target.test_an_absent_leaf_skips_only_when_the_ancestor_still_reaches_its_stand_in-- the two controls: no recorded name refuseshas vanished; a recorded name whose ancestor now reaches a different directory refuseshas vanished.test_the_directory_loop_records_every_name_it_masks-- the shipped loops write the record, after the read-back, for the credential-dir and ssh masks, and every recorded stand-in is one this launcher registered.test_a_leaf_absent_inside_a_bound_window_is_not_covered_by_the_mask_above--editsrenamed away between the window bind and the nested re-hide refuseshas vanished; the same absence with no window bound skips.test_the_directory_loop_records_every_window_it_binds-- the shipped loop records a bound window and its mask root.test_a_second_spelling_that_reaches_this_launchers_own_stand_in_skipsnow also asserts the covered spelling is recorded.Mutation check, baseline green first, each mutation classified red / green / broken: removing the leaf-absent skip, removing the parent-absent skip, trusting the record without re-resolving, dropping the dir-loop record, dropping the second-spelling record, stopping the ancestor walk at the parent, dropping the window check, and dropping the window record each turn at least one test red (eight mutations, all red, baseline green).
test/test_sandbox*.py: 2088 passed, 1 pre-existing failure (test_kill_broadcast_denied_targeted_allowed_e2e, red on unmodified main in this environment too).Manual verification
Against the REAL launcher on the affected host (symlinked
$HOME,/home/u -> /local/home/u),sandboxed_spawn_argv(["/usr/bin/env", "/bin/true"], mode="standard", extra_hidden_dirs=(~/.kiro/crew, ~/.kirocrew))-- the probe's exact shape -- run without thesystemd-runscope: rc 1 with the refusal above on main, rc 0 on this branch. Inside the fixed sandboxls -A ~/.kiro/crew | wc -lprints 0 and both~/.kiro/crew/diagand/local/home/u/.kiro/crew/diaganswerNo such file or directory, while the hostdiagholds 3 entries: the masks hold, the leak the refusal guards against is not opened.Related Issues
Regression from #15252 (re-land of #13715). No issue filed.
Pattern harvest
Rule candidate: review-prompt
Pattern: a fail-closed check on "name absent" added to a loop whose earlier iterations legitimately remove names (mask-then-list-under-it); the new refusal must be tested with the list shapes real callers pass (
extra_hidden_dirs= whole data home), not only with a single leaf.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement