Repository navigation
fix(sandbox): hand the launcher one name per crew directory on a symlinked home - #15729
Conversation
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Spawn once on a plain home with the legacy What this change shipsInventory (8 items) — 8 justifiedIntent: FIX — a gateway on a symlinked home verifies Kiro CLI again (models and balance load) by handing the launcher one name per crew directory. Provenance checked: reproduction in the description, red-on-main test, prior incidents #15252/#13715.
Checks run: no existing mechanism folds directory spellings (the "alias pass" / [FIRST-PRINCIPLES-REVIEWED] 6fe2b20 Description read[DESCRIPTION-READ] 7971642653667a31e596aa868380dd166dd761e9937af4c2225d1548f5131bf0 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The fold also fires on plain homes with the legacy WatchThe description concedes it: "both prefixes then reach the data home and the fold collapses them too, but no new test pins that layout." On a non-symlinked home with the migration link, [DESIGN-REVIEWED] 6fe2b20 Description read[DESCRIPTION-READ] ce6a709981e2d88700d8517a315ba581e644afb412be6233f3ac7d5205961c78 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 5.6 Review — ✅ human override acceptedHuman judgment by @chenmingwei23 overrides the GPT 5.6 finding for [GPT-OVERRIDE] 6fe2b20 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: |
b9fa8c7 to
8aef089
Compare
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: |
3af904e to
7409611
Compare
7409611 to
c384a08
Compare
c384a08 to
67c2bfa
Compare
67c2bfa to
3c81a4f
Compare
3c81a4f to
3674249
Compare
3674249 to
547180f
Compare
ad1c2d9 to
58bf81f
Compare
58bf81f to
51cbc2e
Compare
…inked home The launcher keeps every record per NAME -- the occupant a pre-spawn pass saw (MASK_OCCUPANTS), the stand-in a loop placed (_MASKED_NAMES), the window it opened (_BOUND_WINDOWS) -- and compares each against the filesystem by identity. The tier lists spell every crew leaf under $HOME/<prefix> and the passes spell it under config_dir(), which is resolved, so on a host whose home is a link (/home/u -> /mnt/home/u) the launcher is handed two names for one directory and the records disagree with what either name reaches. #13715, #15252 and this PR's own symptom are all that one shape. namespace_argv now decides, once per crew root and beside the passes that already stat those roots, which $HOME-joined roots are another NAME for the data home (_crew_home_alias_roots: the root's components resolve to the canonical path -- resolution, not identity, since a bind mount of the data home at the alias shares its (st_dev, st_ino) but is a second mount on which a mask placed at the canonical path does not appear, so it keeps its own entry), and _build_launcher_script folds every path under such a root onto the resolved spelling before it emits a list -- hidden, read-only, files, carve-outs, windows, writable, exposures, required targets and the occupant map alike. Pure string work in the builder, so it still makes no filesystem call. A tier entry with no relocated twin (.vault) is respelled rather than dropped, so no rule is lost; a root string-equal to the data home is no alias and is left alone. The launcher itself gains no skip for a second spelling: a stand-in reached at a name no pass vouched for is not evidence that the name is another spelling of anything, and accepting it by membership in _OWN_STAND_INS alone would let a writer who can reach the shared-temp fallback park a registered stand-in on a later credential path and have its mask skipped. Handed two spellings, the launcher still refuses, and test_sandbox_mount_pinned_target.py keeps that refusal pinned as the reproduction the fold makes unreachable. The test harness there gains a _CoveringLibc whose directory bind hides its target, which is what makes the absent branches reachable in a test at all. test_sandbox_symlinked_home_launcher.py drives the real pass and builder under a symlinked home and asserts one spelling per directory, the carried leaf identity under a listed name, and the whole hiding region running to the end against the script those producers write, with a bind that hides its target. The fold is a decision made in the producer and acted on in the child, and the home link that makes the two spellings one directory is a name a writer could re-aim in between. Each alias therefore travels with the (st_dev, st_ino) it rested on, and the launcher re-reads every alias ahead of the first hiding mount and refuses the spawn unless it still reaches that directory -- under BOTH spellings, since the alias alone would pass a swap that puts a fresh directory under the canonical name and re-aims the alias at the original -- so the folded rules never stand for an alias that has moved or a data home that has been replaced. Both launcher gates test the alias by RESOLUTION, as the producer does, not by (st_dev, st_ino): a second mount of the data home shares the identity under another name and carries none of the masks placed on the canonical entries, so identity would pass an alias re-aimed at such a mount. The canonical spelling is held to the recorded identity, a question about an object rather than a name. The first read runs before the mounts, so a link re-aimed right after it would hold until the masks land; once every hiding mount is placed the launcher resolves each alias once more and refuses unless it still names the canonical path. Both sides are resolved before they are compared: the canonical is the spelling the passes record under, and on a default data home it is itself a link (~/.kiro/crew -> ~/.kirocrew), so comparing against the raw string would refuse every spawn on that layout.
51cbc2e to
6fe2b20
Compare
|
/ai-review override gpt 6fe2b20: The bypass requires a pre-existing second mount of the data home that only a root-privileged host actor can create (the payload cannot: caps dropped at sandbox.py:10317, mount seccomp-denied per sandbox.py:10330), and in exactly that configuration the unmasked second mount is already directly readable at its own path, so pinning the alias prevents no exposure the deployment has not already granted. |
Human judgment recorded@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Problem / Motivation
Goal: A gateway on a host whose home directory is a symlink verifies Kiro CLI again, so the model list and the account balance load after a restart, and the launcher stops being handed two names for one crew directory.
Since #15252 landed, every Kiro CLI readiness probe on such a host (
/home/u -> /mnt/home/u) is refused by the sandbox launcher:The gateway logs this every 30 s,
/api/modelsand the balance endpoint come back empty, and the dashboard shows "Failed to load" in both places.Why it matters
Any developer host with a symlinked home loses model selection and account display entirely on the first gateway restart after upgrading. There is no workaround short of lowering the sandbox level. The same shape -- two names for one directory, records kept per name -- is what broke every agent spawn in #13715 and what #15252 patched one branch of; without removing the duplicate at the source, the next per-name record added to the launcher breaks these hosts again.
Not a goal
/Usersis not conventionally a link, and that builder is left as it is..kiro/crew -> .kirocrewalias layout on a host whose home is NOT a link: both prefixes then reach the data home and the fold collapses them too, but no new test pins that layout._covered_by_own_mask's contract.What changed (motivation → approach → change)
Symptom: the probe refuses as above. Root cause: the launcher keeps every record per NAME -- the occupant a pre-spawn pass saw (
MASK_OCCUPANTS), the stand-in a loop placed (_MASKED_NAMES), the window it opened (_BOUND_WINDOWS) -- and compares each against the filesystem by identity. The tier lists spell every crew leaf under$HOME/<prefix>; the passes spell it underconfig_dir(), which is resolved. Under a symlinked home those are two names for one directory. Here the directory loop masked the data home once per spelling, the second bind moved the resolved name onto a stand-in the record for it did not name, the file loop founddiagabsent beneath it, and_covered_by_own_maskread the disagreement as a vanished object.One change, at the source.
namespace_argvdecides once per crew root, beside the passes that already stat those roots, which$HOME-joined roots are another NAME for the data home (_crew_home_alias_roots, one path resolution per root: the root's components resolve to the canonical path -- resolution rather than(st_dev, st_ino)identity, because a bind mount of the data home at the alias shares the identity yet is a second mount on which a mask placed at the canonical path does not appear, so it keeps its own entry; GPT F1 onad1c2d9896), and_build_launcher_scriptfolds every path under such a root onto the resolved spelling before emitting any list -- hidden, read-only, files, carve-outs, windows, writable, exposures, required targets and the occupant map (_fold_crew_home_alias). Pure string work in the builder, so it still makes no filesystem call (test_the_builder_does_not_stat_the_hidden_pathsholds). A tier entry with no relocated twin (.vault) is respelled rather than dropped, so no rule is lost; a root string-equal to the data home is no alias and is left alone; a genuinely relocated home (KIROCREW_HOME=/srv/crew) keeps its own rule. The fold is decided in the producer and acted on in the child, and the home link that makes the two spellings one directory is a name a writer could re-aim in between: each alias travels with the(st_dev, st_ino)it rested on (CREW_HOME_ALIASES), and the launcher checks every alias ahead of the first hiding mount: the canonical spelling must still hold the recorded(st_dev, st_ino)(a fresh directory swapped in under the canonical name would take the folded masks while the original sat unmasked wherever it went), and the alias must still RESOLVE to where the canonical path resolves (both sides resolved: the canonical is the passes' spelling and on a default data home is itself the~/.kiro/crew -> ~/.kirocrewlink; against the raw string every spawn on that layout would be refused, GPT/Opus/FP on51cbc2ed58) -- resolution, not identity, at both launcher gates (GPT F1 on58bf81f0c5), because a second mount of the data home shares the identity under another name and carries none of the masks placed on the canonical entries, so identity would pass an alias re-aimed at such a mount. That read runs before the mounts, and a link re-aimed right after it holds until the masks land (GPT F1 on3c81a4fbb4), so once every hiding mount is placed the launcher resolves each alias once more and refuses unless it still names the canonical path -- an alias whose components lead there reads the masks exactly as the canonical does; a re-aimed alias leads somewhere unmasked.The launcher gains no skip for a second spelling. An earlier revision of this PR let
_pin_mount_pathaccept a name with no carried expectation whose object was a directory stand-in in_OWN_STAND_INS; a stand-in reached at a name no pass vouched for is not evidence that the name is another spelling of anything, and accepting it by membership alone would let a writer who can reach the shared-temp fallback park a registered stand-in on a later credential path and have its mask skipped (GPT F1 on67c2bfaef0). Handed two spellings, the launcher refuses exactly as before this PR; the fold is what makes that input unreachable.Tests:
_runintest_sandbox_mount_pinned_target.pytakes list and libc overrides;_CoveringLibcemulates a directory bind by hiding its target (rename-over on one filesystem), which is what makes the absent branches reachable in a test at all -- the recording stand-in leaves every leaf visible, which is why #15252's gap was not caught.test_a_data_home_handed_to_the_launcher_under_two_spellings_is_refuseddrives the loops with the duplicate lists the builder used to emit and pins the refusal those lists produce, so the reproduction stays on record. Newtest_sandbox_symlinked_home_launcher.pydrives the real pass and builder under a symlinked home and pins the fold: one spelling per directory inSENSITIVE_DIRS, the probe's three spellings folded to one, the carried leaf identity under a listed name, a relocated home still listed, a bind-mounted data home sharing the identity but not folded, the whole hiding region running to the end against the script those producers write for such a host, the alias carried with its identity, a plain home folding nothing, a home link re-aimed after the fold refusing the spawn with nothing mounted, a data home swapped under a still-true alias refusing on the canonical spelling, an alias re-aimed between the first read and the mounts refusing on the post-mount read, an alias re-aimed at a second mount sharing the data home's identity refusing at both gates, the legacy-link canonical under a symlinked home passing both gates on an untouched filesystem and refusing once the alias is re-aimed, and the post-mount read pinned after the last hiding mount.Backwards compatibility
Compatible: a host whose
$HOMEcrew roots are not the data home gets byte-identical lists (_crew_home_alias_rootsreturns nothing, the fold is the identity). On a symlinked home the lists shrink to one spelling per directory; every directory masked before is masked after, under the spelling the pre-spawn passes already use, and a carve-out or window named under the alias spelling is folded the same way so it still lifts or re-opens what it asked for.Tests
test_a_data_home_listed_under_two_spellings_is_masked_once: red on main (has vanished (it is absent)), green with commit 1; red again when only the pin branch is knocked out.test_sandbox_symlinked_home_launcher.py:test_the_probes_home_spellings_fold_onto_the_data_homeandtest_the_launcher_is_handed_one_spelling_per_directoryare red with commit 1 alone, green with commit 2.test/test_sandbox*.pyfiles +test_kiro_prerequisite*.py+test_cron_apps_secret_mask.py: 2495 passed, 7 skipped. The 13 other test files that touch the builder ornamespace_argv: 1614 passed, 9 skipped.Success: no issues found), comment-history gate: clean.Manual verification
The probe launcher the affected host actually generates (symlinked home, 177
SENSITIVE_DIRSbefore the fold, occupant recorded fordiagunder the resolved spelling) was rebuilt from this branch and its hiding loops replayed with the covering bind: the unfixed script refuses with the live message; with commit 1 it runs to the end with both home spellings recorded against one stand-in; with commit 2 the data home anddiageach appear once, under the resolved spelling, and it runs to the end.Screenshots / video
N/A — no UI change.
Related Issues
Follow-up to #15252 and #13715.
Pattern harvest
Rule candidate: review-prompt
Pattern: "a producer that lists filesystem objects by path for a consumer that keeps per-name records must emit one name per object; two spellings of one directory make every identity check read the second as a swap"
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement