Repository navigation
fix(sandbox): write-protect git control files in the gateway's checkout - #24812
iamwhatever wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK On Linux, the description says the agent can get around the new mount pins and seals by creating one file, What this change shipsInventory (10 items) — 6 justifiedIntent: stop a sandboxed agent from choosing what the gateway's own unsandboxed git runs in its source checkout. FIX.
BlockersLinux namespace seals stop nothing the agent can't get around in one step — symptom-level [FIRST-PRINCIPLES-REVIEWED] c25dba3 Description read[DESCRIPTION-READ] 0a1b5f5faefff3d39309370bb715e7967e370309b2c8c74898aab0a544660134 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: the threat is named (the agent picking what the gateway's unsandboxed git runs), the seal covers only the gateway's own checkouts, and the breakage is listed and can be reverted. Notes
[DESIGN-REVIEWED] c25dba3 Description read[DESCRIPTION-READ] c1614abdd4edc072501b4e1caa4c3a61a3f492732c25d67a219b61bdd32ad24e 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: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: Nothing in this change touches the shell deny composite, so the shell rows I submitted are there to show that the area's daily git operations still pass that gate. The actual tightening is in two places the classifier cannot judge: the OS sandbox's read-only seals and pins, and the file-tool write gate. Neither got a verdict. Both refuse legitimate operations in the gateway checkout, some of which the diff names and some it does not, and those are listed under UNADJUDICATED below. TIGHTENING: Read-only seals and directory pins on the gateway checkout's git control files, applied in the namespace and Seatbelt sandboxes, plus a new file-tool write refusal on the same files. Both are aimed at one threat: a sandboxed agent writing a git control file that names a program the gateway's own unsandboxed ADJUDICATED: 19 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: I wrote rows for posix, windows and any.
The diff assumes posix paths in the seal and pin layer ( UNADJUDICATED:
[SCOPE-REVIEWED] c25dba3 |
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: |
a91a2e4 to
c3e4430
Compare
|
|
|
|
Sensitive change review
|
c3e4430 to
14a99f3
Compare
|
|
Sensitive change review
|
14a99f3 to
27d2bfd
Compare
|
Sensitive change review
|
|
612d7ea to
f02e010
Compare
Sensitive change review
|
f02e010 to
c77d018
Compare
Sensitive change review
|
c77d018 to
ee9bb8e
Compare
Sensitive change review
|
|
Problem / Motivation
Goal: A sandboxed agent cannot change the git config, hooks or attributes files that the gateway's own unsandboxed git reads in its install checkout, and ordinary git commits inside the sandbox keep working.
In a source-checkout install the agent works in the install checkout (
KIROCREW_PROJECT_DIR), and it can write there. The sandbox masks no part of.git, and the file-tool write gate does not cover.git/config. So an agent can edit.git/config, add a hook, or write.git/info/attributes. The gateway later runs git in that checkout outside the sandbox, and git runs whatever those files name.Why it matters
Any user running from a source checkout is exposed. A prompt-injected agent can pick a program that the gateway's own git runs as the user, outside every sandbox control. #24808 hardens the host-side caller (the update check). This PR is the second layer: the agent cannot write those files in the first place.
Not a goal
.gitin repositories other than the gateway's own checkouts. Agents there needgit push -uandgit remote add, which write.git/config. Those repositories get only the file-tool refusal.~/.gitconfigand other global or system git config..git/modules/*) beyond the file-tool refusal..gitattributes. Agents edit it, and an attribute can only pick a driver that some config file defines.What changed (motivation → approach → change)
The gateway's checkouts (
KIROCREW_PROJECT_DIRand its source tree) get the seal a packaged install root already has.sandbox_git_control.pyreads each checkout's layout on the host. Plain checkouts and linked worktrees are both handled.sandbox_argv.pypasses the layout to the planner.sandbox_plan.pyadds the pins and seals for both backends.The launcher (
sandbox_launcher_program.py,sandbox_launcher_parts/mask_stages.py) gains two stages.pin_dirsruns before every other mount, andreenter_pinned_cwdruns after the last one..github/workflows/ci.ymladds the real-namespace test to the namespace-sandbox lane.Pinned read-write (Linux bind over self, first): the git directory, and every directory above the checkout that the agent could rename. A mount point cannot be renamed or removed. So
mv .git .git.oldfollowed by a fresh.gitfails with EBUSY. Commits, branches and status still write objects, refs, the index and HEAD as before.Sealed read-only:
configandconfig.worktreehooks/andinfo/commondir, and a linked worktree's.gitfileinclude.path/includeIftargetcore.hooksPathdirectoryA missing
hooks/,info/orconfig.worktreein the resolved git directory is created empty first, so the agent cannot create it. A target that a config names is never created by the gateway. An absent one stays listed for Seatbelt and is logged. The directories above an include orhooksPathtarget are pinned like the checkout's.The host-side read is hardened. Config files are opened non-blocking and checked on the descriptor, so a FIFO cannot hang spawn prep or the write gate. Git itself lists include and
hooksPathnames (git config --includes --show-origin,GIT_DIR/GIT_COMMON_DIRpinned), so they resolve as the gateway's git resolves them. Each existing include is also listed on its own, so an inactiveincludeIfhides nothing. Acommondirfound in a plain checkout is never followed.On macOS, Seatbelt gets the same seals as write denies, plus literal rename guards on the pinned paths and on every ancestor of the checkout.
The launcher re-enters its cwd after mounting, so relative paths cannot skip the seals.
The file-tool write gate (
security/paths.py) refuses the same control paths, but only inside the gateway's checkouts. That coversconfig,commondir,hooks/,info/,worktrees/*/…andmodules/*/…, matched case-insensitively. Other repositories keep their file-tool route.The shipped dev skills stop writing the sealed config.
kirocrew-worktree-dev(and thelive_checkout_guard.pyhint) usesgit worktree add --no-track.kirocrew-prepare-prpushes with a plaingit push origin <branch>, without-u.Gap left on Linux: a plain checkout has no
.git/commondir, and git honours that file in any git directory. A bind seal needs an existing file to cover. A stand-in file doesn't work either: an empty one makes git fail, and libgit2 then refuses to open the repository (measured with pygit2). So on Linux a shell can still create that file, or an include orhooksPathtarget that a config names but that does not exist yet. Seatbelt's path rule blocks both on macOS. This is why the host-side guards in #24808 are still needed.Backwards compatibility
Breaking: inside the sandbox, the gateway's own checkouts (and their linked worktrees, which share the common config) reject writes to the git config, hooks and info files. These now fail there with EBUSY, EROFS or a Seatbelt deny:
git push -u,git branch --set-upstream-to, and a branch that tracks a remote (checkout -b x origin/x,worktree add -b x origin/main)git remote add,git config,gh pr checkoutpre-commit install,git lfs install,git sparse-checkout set,git submodule update --initOn Linux, a direct
rename(2)between two pinned directories (the parent workspace and the checkout) fails with EXDEV.mvfalls back to copying. The file tools refuse the same control paths inside those checkouts only.Writer sweep on origin/main @ f3a7d42: the shipped dev skills were the sandboxed writers, and they are changed here (readers below). The updater and Dev Fleet write from the gateway process, outside the sandbox.
Reader: src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-worktree-dev/SKILL.md -- entry: chat -- now
git worktree add --no-track, pinned by the real-sandboxworktreecontrol stepReader: src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-prepare-pr/SKILL.md -- entry: chat -- first push is
git push origin <branch>;gh pr create --headneeds no upstreamReader: src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-worktree-dev/scripts/live_checkout_guard.py:check -- entry: chat -- its suggested command now carries
--no-track; test_live_checkout.py passesReader: src/kiro_crew/dashboard/handlers/updates_check.py:_check_git_checkout -- entry: crew page -- runs in the gateway, unsandboxed; reads the same files, now unchanged by agents
Reader: src/kiro_crew/apps/builtins/dev_fleet/worktree_ops.py -- entry: app -- gateway-side git; reads the pinned paths, which are unchanged on the host
Reader: src/kiro_crew/security/paths.py:sensitive_write_path_refusal -- entry: chat|subagent|cron -- refuses only the gateway checkouts' control paths; test_sandbox_git_control.py::test_another_repository_keeps_its_file_tool_route
Tests
test/test_sandbox_git_control.pycovers the layout of a plain checkout, a linked worktree, includes,hooksPath, and missinghooks//info//config.worktree. It checks that an absentcommondiris listed but never created. It also checks that both renderers receive the pins and seals, that a carve-out cannot reopen a seal, and that the launcher stage order holds. It also covers:an absent include or
hooksPaththat is listed but never createda plain-checkout
commondirthat is not followeda FIFO at a config path, a BOM, a continued include line, and a symlinked
hooks/For the file-tool gate it covers refusals in the gateway checkout, case variants and a symlink into.git. It confirms that another repository and the checkout's ordinary files stay writable, and that the gate creates nothing.test/test_sandbox_git_control_real_sandbox.pyruns a real namespace sandbox for each tier. It is added to the namespace-sandbox CI lane..git/configby absolute or relative path, adding a hook, and writinginfo/attributesall fail with EROFS..gitor the checkout fails with EBUSY.git add,commit,branch,statusandworktree add --no-tracksucceed inside the sandbox. The test seals only its temporary repository, never the source checkout running it.Updated pins on existing tests:
test_sandbox_refactor_generated_programs.pypins an empty git layout and addspin_dirs: []to the launcher golden.test_sandbox_protected_name_holds.pypins one plain checkout and records its five leaf-only git names.test_sandbox_mount_checked.pycounts the new guarded pin mount.test/security_line_budget/gateway-checkout-git-control-fence.txtadds a+2row to the security package budget for the gate's import andorclause.spawn_audit_helpers.pylists the gather's fixed-argvgit configread as benign. It runs before the sandbox exists.Proof: not provable -- other: the fix is a new module; reverting it removes the import the new tests collect, so prove.py stops at collection
Manual verification
Gathered the layout on this host's own source install (a linked worktree with
extensions.worktreeConfigon). The pins and seals came out as expected. I could not run the real-namespace test locally, because nested user namespaces are denied there; the CI namespace-sandbox lane runs it. An independent reviewer saw only the diff. It found thecommondirvector, which is addressed and documented above, and a symlinked.git, which is now followed and logged. Its third finding was that theworktreeConfigparser could misjudge the setting;config.worktreeis now always created and sealed instead.Related Issues
Reported privately by an external researcher; no public issue. Host-side half: #24808.
Sibling sweep
Swept: git grep -nE 'install_root_targets|_WRITE_PROTECTED_HOME_PATHS' -- src/kiro_crew/
Sibling: src/kiro_crew/sandbox_tiers.py -- not affected -- install_root_targets seals the packaged install; a source checkout returns [] there by design, which this PR covers separately
Sibling: src/kiro_crew/edition_install_fence.py -- not affected -- enterprise packaged tree only; the git-control gate added beside it covers every edition
Pattern harvest
Not generalizable: the sandbox had one install shape (source checkout) with no seal; the new module covers that shape, and there is no second.
Checklist