Repository navigation
fix(sandbox): inherit permanent userns probe verdict - #20822
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the inherited hint can only seed the same permanent failure that a fresh probe returns, and the spawn chokepoint overwrites or removes any value a caller supplies. Notes
[DESIGN-REVIEWED] 09585d8 Description read[DESCRIPTION-READ] 8170f4ad6f66b238c58606638b1a1d748382a8e51f8232bc8b3ab9c1a66abee5 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 (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the change handles one reported defect (#20811) where it starts, and the env handoff is its only new surface. What this change shipsInventory (4 items) — 4 justifiedIntent: on a Linux host without user namespaces, the gateway should log the permanent sandbox-probe failure once per boot, not once per sandboxed child. FIX.
[FIRST-PRINCIPLES-REVIEWED] 09585d8 Description read[DESCRIPTION-READ] 2c3a6b157138ebd0ed409e96273990e8af0cc12ac953a475367b5f0a9ad16d0f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 09585d8 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
59c117c to
fe7278c
Compare
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
Disposition for an earlier head, kept for the record (no longer a ledger record):
|
|
First Principles' pre-merge check on
|
|
HOLD at 8e9c6e8 for a human maintainer. No code finding. This changes how a sandbox child chooses its isolation backend. The child now trusts an inherited The change reads as fail-closed:
Every lane passes or reports no findings, and the First Principles pre-merge check has a traced reply. Sensitive Change Review is red as the fork sensitive-path gate. A maintainer's approval or the author's reasoning template clears it. — crew-pr-reviewer (r116) |
Head branch was pushed to by a user without write access
8e9c6e8 to
8f5a477
Compare
8f5a477 to
09585d8
Compare
|
HOLD for a maintainer at 09585d8. This changes how a sandbox child picks its isolation backend: it trusts an inherited The head is a rebase of the 8e9c6e8 we held in r116, and I still found no defect. The child accepts the hint only on Linux, only under both exact spawn stamps and only as a permanent failure, so it can select AI findings judged non-blocking: Design suggests a comment on What clears the hold: a maintainer takeover so Sensitive Change Review passes, plus a human review of the env-based backend handoff. — crew-pr-reviewer (r135) |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved on behalf of the watch holder (bolichen). Design and First Principles pass on this head (or skipped / author override), UX skipped or pass, no conflict, no open change request.
Problem / Motivation
Goal: A gateway on a Linux host without usable user namespaces logs the permanent probe failure once per boot instead of once per sandbox child.
The user namespace probe caches its permanent verdict only in the process that runs it. Each sandboxed child starts a new Python process with a cold cache, repeats the fork and unshare probe, and writes the same WARNING with its own PID. One affected host logged 17 duplicate warnings in 57 minutes.
Why it matters
Repeated warnings hide actionable log events and make one permanent host limitation look like many new failures. Each child also repeats a probe whose permanent result is already known by its parent.
Not a goal
What changed (motivation → approach → change)
In
src/kiro_crew/sandbox_spawn.py,sandboxed_spawn_argvstamps every returned child environment withKIROCREW_SPAWNEDandKIROCREW_SANDBOX_TOOL, including the degraded and no-backend paths. It writes the parent process's permanent Linux user namespace failure reason and remedy beside those stamps. It removes the value when no permanent verdict exists, so a transient failure and a caller-supplied stale value cannot propagate.In
src/kiro_crew/sandbox_wrap.py, a Linux child accepts the verdict only when both spawn stamps have their exact KiroCrew values. The child seeds its direct and background probe caches from the inherited permanent verdict. It neither probes nor logs. A child without the hint follows the existing probe and WARNING behavior. Thesrc/kiro_crew/sandbox.pycompatibility facade andtest/test_sandbox_refactor_facade.pyownership inventory expose and pin the new owner names.The hint cannot widen capability. It can only seed a permanent failure and select the same
noneresult that an identical probe returns. It cannot select thenamespacebackend. The chokepoint overwrites or removes any caller value after the environment scrub. A process that can choose all three values for another process already controls that descendant's exec environment, and existing kernel confinement survives exec.The per-process
SECURITY: no OS-level sandboxwarning from_warn_no_isolationis unchanged, deliberately. It states that this process's own agent subprocesses run without credential isolation, so each child still logs it once.agent.sandbox_allow_no_isolationremains the operator's acknowledgment that downgrades it to INFO. Only the host probe's permanent verdict is inherited.Backwards compatibility
Compatible: parent probe behavior, backend selection, failure guidance, and transient retries keep their existing contracts.
Removes nothing: the change carries one already-known permanent verdict into a child process.
Tests
test/test_sandbox_backend_cache.pycovers the production and rejection paths through the realsandboxed_spawn_argvenvironment chokepoint:KIROCREW_SANDBOX_ACTIVEmarker replaces a forged caller value, spawns a child, and the child performs no direct or background probe and emits no probe log.The current head is
09585d82a1, one commit directly on37e010610cand a clean rebase of8f5a4776d6. Main's changes since then (insandbox.py,sandbox_wrap.py,test_sandbox_backend_cache.pyandtest_sandbox_refactor_facade.py) moved only context around this change's hunks: every per-file patch ID is identical. It was validated as67e406fea7, the same patch on83986247fb; main's five newer commits touch none of this change's files. There, the complete sandbox selection (everytest_sandbox*.pyandtest_*sandbox*.pymodule) passed (3,593 tests, 20 skipped), and Black, subprocess encoding, isort, flake8, mypy, Comment History, brand, docs lint, file line cap, harness parity, and the flake-pattern and wait-discipline ratchets pass. On this head, the repository-wide facade-mirror, link-screen and dashboard-files composition guards pass (147 tests). Onf2ac3dab44, the focused cache, facade, create-guard, and spawn-audit selection passed 663 tests, and the new tests passed 20 times serially, 10 times with four workers beside their neighbors, and in reverse order; the related-test local gate's 84 failures and seven collection errors on that base reproduced on pristine main at the time.Manual verification
On a Linux host where
unshare(CLONE_NEWUSER)fails with EPERM, atf2ac3dab446fwith an isolatedKIROCREW_HOME, a parent ran the real probe and logged one permanent WARNING. It built each child through the realsandboxed_spawn_argv(first-party no-backend path, systemd-run scope). Fresh child interpreters importingkiro_crew.sandboxresolvednoneon both the directdetect_backendand thewarm_backendpaths, with zero_probe_unshare_oncecalls and no probe log. The same child with only_KIROCREW_USERNS_FAILUREremoved probed once and logged the WARNING.Related Issues
Closes #20811
Pattern harvest
Rule candidate: review-prompt
Pattern: a parent process caches a permanent host capability verdict but repeatedly spawned children do not inherit it and repeat the same probe and warning.
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. See the Licensing section of
CONTRIBUTING.md.