Repository navigation
fix: tighten a third sandbox file guard on fresh installs - #36096
bolichen97 wants to merge 1 commit into
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix calls the gateway's own Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: stop an agent started before the gateway's first run from planting the signing key the gateway later trusts. FIX.
[FIRST-PRINCIPLES-REVIEWED] 7a586a1 Description read[DESCRIPTION-READ] 7ee86d425464bfbb39e37ad212ce17a12d5af3a6a6ba5aef084cf764173366b1 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: running the gateway's own create-once path avoids a key the boot would refuse, and it follows the same materialise-then-require pattern as the Notes
[DESIGN-REVIEWED] 7a586a1 Description read[DESCRIPTION-READ] d0ca8a05068fa139c72345a36fa872e5ae235d65b06b6080311b7e1a4fc51fee 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 — ✅ no blocking findingsGPT 6.1 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: |
b7cf0ca to
39e7f52
Compare
|
Rebased: main moved in docs/system-specs/modules/security.md, src/kiro_crew/sandbox.py, test/test_sandbox_refactor_facade.py since this head's CI ran (2f7e9f2 -> b2aac45); CI re-running. The Build Wheel, Build Desktop and E2E (stub ACP backend) reds on the old head were main's: [operator: bolichen97] |
On a data home where the gateway has not started yet, the agent sandbox protects one more of its protected files from the first agent start, not only once the gateway has created it. Part of #10716
39e7f52 to
7a586a1
Compare
|
Rebased: main moved in src/kiro_crew/sandbox_argv.py (a merge conflict: #33589 added a launcher step at the same spot; both kept, in their original order), src/kiro_crew/sandbox.py, docs/system-specs/modules/security.md and test/test_sandbox_refactor_facade.py since this head's CI ran (b2aac45 -> 00c5418); CI re-running. The reds on the previous head were never verdicts on the code: the CI installation's API rate limit was spent when they ran, so Await Fast Gate and the review lanes failed closed before judging anything. This push re-runs them. [operator: bolichen97] |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR adds _materialize_signing_key_mask_target, which runs the gateway's own key-creation path (_load_or_create_secret) before each namespace spawn when token_signing.key is absent. The already-masked key therefore exists from the first agent start, and an agent can no longer write a key the gateway would accept. It runs before the legacy-temp sweep, the staging-link cleanup and the hard-link check, so a staging link left behind by key creation is removed before the check could refuse. Creation waits while a pre-upgrade temp is present, matching the sweep's keep-for-rename choice. The ephemeral fallback leaves the name absent and the spawn goes ahead as before, so there is no new refusal. An existing key is never rewritten. The masked set does not grow. The new tests cover creation (the gateway loads the same key, file is owner-only), an existing key and the hold-off, and the existing ordering and required-set tests are updated. No blocking defects found. 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 |
|
[operator: bolichen97] The red It is tracked in #28212, and #28293 is the open fix. This PR waits for that fix and is rebased onto it once it merges; no rerun is spent on a test with this many reports. |
Problem / Motivation
Goal: On a data home where the gateway has not started yet, the agent sandbox protects one more of its protected files from the first agent start, not only once the gateway has created it.
Part of the class of cases tracked in #10716: that issue already describes, in public, how this protection reached a file only once it existed. #30449 and #31810 closed two cases; this PR closes one more.
Why it matters
An agent can be started from the command line before the gateway has ever run on a home. Until the gateway's first start created this file, such an agent could write it, and the gateway would then trust what it found.
Not a goal
What changed (motivation → approach → change)
The sandbox could protect this file only once it existed, and the gateway creates it at its first start. A stand-in will not do here, because a stand-in of the wrong size stops the gateway from starting. So before the first agent start on a home that has none, the sandbox now runs the gateway's own creation step, which leaves exactly the file the gateway would have made. A home that already has the file is not modified. Creation waits while a leftover from an older version is present, so the recovery the docs describe for that leftover stays possible. The security spec in docs records the case.
Backwards compatibility
Compatible: the gateway reads the same kind of file it would have created itself, and a home that already has one is not modified.
Removes nothing: no reader loses access to anything; the change only makes an existing protection apply earlier.
Tests
New tests drive the step on a scratch data home: a home without the file gets one that is owner-only and that the gateway then uses unchanged; a home that has one keeps it untouched and still counts as protected; a leftover from an older version holds the creation off. The existing check that every file the sandbox creates is required at launch now names this file, and the sandbox ordering and facade pins list the new step.
Determinism: the changed test files passed 20 of 20 runs in one process, 10 of 10 with four workers beside two sibling test files, and one run in a shuffled order (seed 22157).
Proof: PROVEN 4 tests fail without the fix (head 7a586a1)
Manual verification
Run on Ubuntu 24.04 (Linux) in a real agent sandbox, each time on a fresh scratch data home with no gateway started:
Permission deniedwrite: okRead-only file systemA home that already had the file kept it byte-identical across an agent start, and the agent could neither read nor change it.
Screenshots / video
N/A — no user-visible change.
Related Issues
Part of #10716
Sibling sweep
Swept: every file the same protection covers, on origin/main @ 00c5418.
Siblings: tracked in #10716 -- the remaining cases each need their own reader review.
Pattern harvest
Not generalizable: each protected file needs its own review of what its readers accept, so no single rule covers the class.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Submitted under the project's Apache-2.0 license.