Skip to content

fix(sandbox): write-protect git control files in the gateway's checkout - #24812

Open
iamwhatever wants to merge 1 commit into
mainfrom
fix/sandbox-git-control-protect
Open

iamwhatever wants to merge 1 commit into
mainfrom
fix/sandbox-git-control-protect

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Hardening the host-side git callers. That is fix(updates): neutralize repo-local git exec config in the update check #24808 and its follow-ups.
  • Protecting .git in repositories other than the gateway's own checkouts. Agents there need git push -u and git remote add, which write .git/config. Those repositories get only the file-tool refusal.
  • ~/.gitconfig and other global or system git config.
  • Submodule git directories (.git/modules/*) beyond the file-tool refusal.
  • The tracked .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_DIR and its source tree) get the seal a packaged install root already has.

  • sandbox_git_control.py reads each checkout's layout on the host. Plain checkouts and linked worktrees are both handled. sandbox_argv.py passes the layout to the planner. sandbox_plan.py adds the pins and seals for both backends.

  • The launcher (sandbox_launcher_program.py, sandbox_launcher_parts/mask_stages.py) gains two stages. pin_dirs runs before every other mount, and reenter_pinned_cwd runs after the last one.

  • .github/workflows/ci.yml adds 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.old followed by a fresh .git fails with EBUSY. Commits, branches and status still write objects, refs, the index and HEAD as before.

  • Sealed read-only:

    • config and config.worktree
    • hooks/ and info/
    • commondir, and a linked worktree's .git file
    • every include.path / includeIf target
    • the core.hooksPath directory

    A missing hooks/, info/ or config.worktree in 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 or hooksPath target 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 hooksPath names (git config --includes --show-origin, GIT_DIR/GIT_COMMON_DIR pinned), so they resolve as the gateway's git resolves them. Each existing include is also listed on its own, so an inactive includeIf hides nothing. A commondir found 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 covers config, commondir, hooks/, info/, worktrees/*/… and modules/*/…, matched case-insensitively. Other repositories keep their file-tool route.

  • The shipped dev skills stop writing the sealed config. kirocrew-worktree-dev (and the live_checkout_guard.py hint) uses git worktree add --no-track. kirocrew-prepare-pr pushes with a plain git 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 or hooksPath target 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 checkout
  • pre-commit install, git lfs install, git sparse-checkout set, git submodule update --init

On Linux, a direct rename(2) between two pinned directories (the parent workspace and the checkout) fails with EXDEV. mv falls 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-sandbox worktree control step
Reader: src/kiro_crew/builtin_skills/kirocrew-dev/kirocrew-prepare-pr/SKILL.md -- entry: chat -- first push is git push origin <branch>; gh pr create --head needs no upstream
Reader: 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 passes
Reader: 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.py covers the layout of a plain checkout, a linked worktree, includes, hooksPath, and missing hooks//info//config.worktree. It checks that an absent commondir is 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 hooksPath that is listed but never created

  • a plain-checkout commondir that is not followed

  • a 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.py runs a real namespace sandbox for each tier. It is added to the namespace-sandbox CI lane.

    • Writing .git/config by absolute or relative path, adding a hook, and writing info/attributes all fail with EROFS.
    • Replacing or moving the config, hooks, .git or the checkout fails with EBUSY.
    • The host files are unchanged afterwards.
    • The control: git add, commit, branch, status and worktree add --no-track succeed 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.py pins an empty git layout and adds pin_dirs: [] to the launcher golden.
    • test_sandbox_protected_name_holds.py pins one plain checkout and records its five leaf-only git names.
    • test_sandbox_mount_checked.py counts the new guarded pin mount.
    • test/security_line_budget/gateway-checkout-git-control-fence.txt adds a +2 row to the security package budget for the gate's import and or clause.
    • spawn_audit_helpers.py lists the gather's fixed-argv git config read 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.worktreeConfig on). 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 the commondir vector, which is addressed and documented above, and a symlinked .git, which is now followed and logged. Its third finding was that the worktreeConfig parser could misjudge the setting; config.worktree is 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

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 27, 2026 08:40
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c25dba32cb5b2527d7fc43a069958973d250dda3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/sandbox_argv.py

  • src/kiro_crew/sandbox_git_control.py

  • src/kiro_crew/sandbox_launcher_parts/mask_stages.py

  • src/kiro_crew/sandbox_launcher_program.py

  • src/kiro_crew/sandbox_plan.py

  • src/kiro_crew/security/paths.py

  • @iamwhatever comment (15 comments checked, none complete): does not name the current head c25dba3; post it again for this head

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: c25dba32cb5b2527d7fc43a069958973d250dda3
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🔴 BLOCK

Premise-level review of c25dba32cb5b2527d7fc43a069958973d250dda3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: BLOCK

On Linux, the description says the agent can get around the new mount pins and seals by creating one file, .git/commondir. That layer adds breakage and new spawn-fatal paths without closing the attack it was built for.

What this change ships

Inventory (10 items) — 6 justified

Intent: stop a sandboxed agent from choosing what the gateway's own unsandboxed git runs in its source checkout. FIX.

  1. Linux: writes to the checkout's .git/config, hooks/, info/, includes and hooksPath fail with EROFS — symptom-level, bypassed via commondir
  2. Linux: .git, the checkout and renamable ancestors can't be moved (EBUSY); renames between them get EXDEV — oversized
  3. Linux: the spawn now aborts if a pin bind or the cwd re-entry fails — oversized
  4. Gateway creates empty hooks/, info/, config.worktree before each spawn — rides along, needed only for Linux binds
  5. macOS: Seatbelt denies writing, creating and renaming the same control paths — justified
  6. File-tool gate refuses control paths only in the gateway's checkouts — justified
  7. Gateway lists config includes with a trusted git before spawning — justified
  8. Agents in the gateway checkout lose push -u, remote add, git config, pre-commit install — justified
  9. Shipped skills use --no-track and push without -u — justified
  10. Namespace CI lane runs the new real-sandbox test — justified

Blockers

Linux namespace seals stop nothing the agent can't get around in one step — symptom-level
Trigger: the description says "on Linux a shell can still create that file", and git "honours that file in any git directory", taking config and hooks/ from the directory it names.
Outcome: Linux users pay for EXDEV renames, the loss of push -u/remote add, a fourteenth guarded mount and two new spawn-fatal paths. Meanwhile echo /evil > .git/commondir still controls what host git runs. #24808 is the real fix.
Subtraction: drop git_control_pins, pin_dirs, reenter_pinned_cwd and the namespace git_control_readonly/_ensure_* path. Keep the Seatbelt and file-tool layers.
Clears when: the Linux namespace layer is removed, or it also closes creating commondir.

[FIRST-PRINCIPLES-REVIEWED] c25dba3

Description read

[DESCRIPTION-READ] 0a1b5f5faefff3d39309370bb715e7967e370309b2c8c74898aab0a544660134

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c25dba32cb5b2527d7fc43a069958973d250dda3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • On Linux the main harm survives: per the description, "a shell can still create that file [.git/commondir], or an include or hooksPath target", so git can still be pointed at agent-written config. Linux pays the cost (no git push -u, git remote add, gh pr checkout, pre-commit install) while fix(updates): neutralize repo-local git exec config in the update check #24808 does the actual protecting. State a merge order that puts fix(updates): neutralize repo-local git exec config in the update check #24808 first, so Linux is never covered by this layer alone.
  • _renamable pins every ancestor whose parent the host user can write, such as ~/src. That turns renames from the workspace into the checkout into EXDEV well outside .git. Confirm that in-sandbox atomic-write tools never stage a temp file across that boundary.
  • Every spawn now runs a git config --includes subprocess while preparing the sandbox. Caching the result by the config files' mtime would keep this cost off the spawn path.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c25dba32cb5b2527d7fc43a069958973d250dda3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c25dba3

Verdict parsed from the review's SHA-scoped output markers for commit c25dba32cb5b2527d7fc43a069958973d250dda3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c25dba32cb5b2527d7fc43a069958973d250dda3 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does c25dba32cb5b2527d7fc43a069958973d250dda3 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 15 classified, 0 newly refused, 15 still allowed.
  • ubuntu-latest (platform posix): 15 classified, 0 newly refused, 15 still allowed.
  • windows-latest (platform windows): 12 classified, 0 newly refused, 12 still allowed.

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 git then runs. The hunks are +``config`` can name programs git executes (``core.fsmonitor``, ``core.sshCommand``, a filter or diff driver), ``hooks/`` holds programs git runs in src/kiro_crew/sandbox_git_control.py, and + matched = matched or _git_control_write(path_str, base_dir) in src/kiro_crew/security/paths.py.

ADJUDICATED: 19 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: I wrote rows for posix, windows and any.

  • posix: the git commands the diff's own skills and the guard remedy now prescribe (worktree add --no-track, git -C "$KIROCREW_PROJECT_DIR" fetch, plain git push origin <branch>, rev-parse --absolute-git-dir, merge-base --is-ancestor), reads of .git/config and .git/hooks, and the include-gather argv itself.
  • windows: the same worktree, fetch and read operations, spelled with \ separators, %KIROCREW_PROJECT_DIR%, and type/dir.
  • any: only the path-free git verbs.

The diff assumes posix paths in the seal and pin layer (os.sep ancestors, Linux bind mounts, Seatbelt rules). It assumes Windows spellings only in the file-tool gate (\→/ and case-folding in _component_path), and no shell row can reach that gate.

UNADJUDICATED:

  • OS sandbox seal and pin layer. Call path: sandbox_argv._live_plan_host → resolved_git_control_layout() → PlanHost.git_control_* → _namespace_plan / _seatbelt_plan → launcher pin_dirs + seal_readonly, or Seatbelt deny file-write*. Inside a sandbox whose checkout is the gateway's own (KIROCREW_PROJECT_DIR or the source checkout), these legitimate operations now fail with EROFS or EBUSY:

    • Writes to .git/config the diff names: git push -u origin feat/x, which the committed corpus already holds as an allowed shell row and which now fails at run time there; git remote add; git config user.email …; pre-commit install; and a git worktree add or git checkout -b x origin/y that sets up tracking.
    • Writes the diff does not name:
      • git branch --set-upstream-to=origin/x
      • git remote set-url
      • git sparse-checkout set <dir>, which writes info/sparse-checkout and core.sparseCheckout
      • git lfs install, which writes hooks/
      • git submodule init / git submodule update --init, which write the submodule.* keys in the top-level config
      • adding a local ignore to .git/info/exclude from the shell
    • On Linux, rename(2) between two pinned directories now fails with EXDEV. That breaks atomic-rename writers moving a file from the workspace parent into the checkout. mv falls back to copying.
  • File-tool write gate. Call path: sensitive_write_path_refusal → _git_control_write → _is_gateway_git_control. In the gateway checkout it now refuses file-tool edits to:

    • .git/info/exclude
    • .git/modules/<sub>/config
    • .git/hooks/*
    • the .git path itself

    The match is case-folded, so on a case-sensitive Linux filesystem it also refuses an unrelated .GIT/CONFIG in that checkout. The inputs I would have submitted are those paths, in posix form and in drive-letter C:\…\.git\info\exclude form. No leg classifies a file-tool path, so none of them got a verdict.

  • Narrowing to consider (argued, not confirmed). .git/info/exclude and info/sparse-checkout name no program git runs, so they fall outside the threat as stated. The seal on info/ could become a seal on info/attributes alone, and the file-gate's _GITDIR_CONTROL_TREES entry for info could become a leaf rule for info/attributes. Either change would keep these operations working and leave every driver-selecting file sealed.

[SCOPE-REVIEWED] c25dba3

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c25dba32cb5b2527d7fc43a069958973d250dda3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c25dba3

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c25dba32cb5b2527d7fc43a069958973d250dda3 false-positive: <reason, 20 to 500 characters>

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=78a4475d68eb named control targets (continuations, absent targets, renamable parents)

fixed in c3e4430: _config_entries joins backslash-newline continuations before reading include.path / core.hooksPath.
fixed in c3e4430: _seal_named keeps every named include and hooksPath; an absent one is created empty (parent must exist) and sealed; a symlinked hooks/ seals its target.
fixed in c3e4430: every renamable directory above both the named and the canonical spelling is pinned and guarded, so rename-and-recreate fails EBUSY.
Residual, logged at gather: a symlink link itself cannot be pinned; its target is sealed.
Tests: test_include_targets_and_hooks_path_are_sealed, test_an_absent_hooks_path_is_created_and_sealed, test_an_include_continued_on_the_next_line_is_sealed, test_a_symlinked_hooks_dir_seals_its_target.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=37bc8efd2e03 isolate the imported source checkout in the real-sandbox test

fixed in c3e4430: the repo fixture monkeypatches sandbox_git_control._own_source_checkout to None, so the gather sees only the temporary repository and never creates files in the checkout running the test.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=b0acacfee0bd file-tool refusal covered every repository

fixed in c3e4430: git_control_write now refuses only paths inside the git directories of gateway_checkout_roots() (read-only lookup via _resolve_gitdir, creates nothing), the same files the OS seal covers.
Other repositories keep their file-tool route: test_another_repository_keeps_its_file_tool_route; the gate creating nothing: test_the_gate_creates_nothing.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=fc2739e0898b unlisted broken readers: the shipped kirocrew-dev skills

fixed in c3e4430: kirocrew-worktree-dev uses git worktree add --no-track (and live_checkout_guard.py suggests the same); kirocrew-prepare-pr first push is git push origin without -u.
The real-sandbox control now runs worktree add --no-track inside the sandbox and requires success.
Backwards compatibility now lists both skills and the guard as Reader lines and names every git command that fails in the gateway checkout; the false no-sandboxed-writer claim is removed.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c3e4430
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins (plan.get default); hosts without a source checkout plan no pins (test_a_host_without_a_checkout_plans_no_pins).
    • Existing tests (which suites passed on this head): local sandbox plan/launcher/argv/seatbelt/facade suites (1965 passed), skill suites (537 passed); CI running on this head.
  • How to undo: revert this commit; no data or config migration is involved (created files are empty hooks/, info/, config.worktree and absent include targets, which git reads as nothing).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@iamwhatever
iamwhatever force-pushed the fix/sandbox-git-control-protect branch from c3e4430 to 14a99f3 Compare October 27, 2026 09:41
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=1ecaa8c4d4b0 gateway creates config-named paths / FIFO can hang the reader

fixed in 14a99f3: the gateway never creates a target a config names (include, core.hooksPath); only hooks/, info/ and config.worktree in the resolved git dir are created. An absent named target stays listed for Seatbelt and is logged.
fixed in 14a99f3: a commondir in a plain checkout is never followed, so no agent-pointed config is parsed.
fixed in 14a99f3: _read_small opens O_NONBLOCK and judges S_ISREG and size on fstat of the descriptor.
Tests: test_an_absent_hooks_path_is_listed_but_never_created, test_a_commondir_in_a_plain_checkout_is_not_followed, test_a_fifo_at_a_config_path_does_not_block.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=88c0b548dc3c UTF-8 BOM before the first section

fixed in 14a99f3: config text is decoded with utf-8-sig, so a leading BOM is dropped as git drops it. Test: test_a_config_starting_with_a_bom_is_read.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 14a99f3
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins; hosts without a source checkout plan no pins (test_a_host_without_a_checkout_plans_no_pins); the gateway creates no file a config names.
    • Existing tests (which suites passed on this head): local sandbox plan/launcher/argv/seatbelt/facade suites (1968 passed), skill suites (537 passed); lint gates (isort, flake8, mypy, black 26.10.1, subprocess-encoding, comment-history) pass locally.
  • How to undo: revert this commit; no data or config migration (created files are empty hooks/, info/ and config.worktree, which git reads as nothing).

@iamwhatever
iamwhatever force-pushed the fix/sandbox-git-control-protect branch from 14a99f3 to 27d2bfd Compare October 27, 2026 10:49
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=88c0b548dc3c symlinked primary configs left their target parents unpinned

fixed in 612d7ea: config, config.worktree, commondir and the linked-worktree .git file now go through _seal_named, so a symlinked one seals its canonical target and pins every renamable parent of both spellings.
Test: test_a_symlinked_config_pins_its_target_parents.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 612d7ea
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins; hosts without a source checkout plan no pins; the gateway creates no file a config names.
    • Existing tests (which suites passed on this head): locally every test/test_sandbox*.py, test_security_gate_liveness.py and test_spawn_audit.py (3403 passed); prior head 502bbf4 passed CI and macOS test lanes.
  • How to undo: revert this commit; no data or config migration (created files are empty hooks/, info/ and config.worktree, which git reads as nothing).

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 28, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=88c0b548dc3c sandbox prep executed a PATH-selected git

fixed in f02e010: _config_closure resolves git with platform_compat.trusted_git_bin() (fixed system dirs, never PATH) and seals nothing extra when it returns None, so an agent-planted venv bin/git is never run.
Test: test_a_git_on_path_is_never_run.

@iamwhatever
iamwhatever force-pushed the fix/sandbox-git-control-protect branch from 612d7ea to f02e010 Compare October 28, 2026 07:41
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f02e010
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins; hosts without a source checkout plan no pins; the gateway creates no file a config names and runs only a trusted git.
    • Existing tests (which suites passed on this head): locally test_sandbox_git_control.py (70 passed) and the full test/test_sandbox*.py set on the prior head (3403 passed).
  • How to undo: revert this commit; no data or config migration (created files are empty hooks/, info/ and config.worktree, which git reads as nothing).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 28, 2026
@iamwhatever
iamwhatever force-pushed the fix/sandbox-git-control-protect branch from f02e010 to c77d018 Compare October 28, 2026 08:38
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c77d018
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins; a plain checkout without commondir plans with no log line (test_the_spawn_plan_logs_each_refusal_under_the_sandbox_logger passes against a plain-clone project dir).
    • Existing tests (which suites passed on this head): locally every test/test_sandbox*.py (3367 passed) plus the plain-clone rerun of the CI failure.
  • How to undo: revert this commit; no data or config migration (created files are empty hooks/, info/ and config.worktree, which git reads as nothing).

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 28, 2026
kyleseaman
kyleseaman previously approved these changes Oct 28, 2026
@kyleseaman
kyleseaman enabled auto-merge (squash) October 28, 2026 15:58
@iamwhatever
iamwhatever force-pushed the fix/sandbox-git-control-protect branch from c77d018 to ee9bb8e Compare October 29, 2026 01:01
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: ee9bb8e
  • What rule changed: the OS sandbox pins the gateway checkouts git directories (and renamable ancestors) and seals their git control files read-only; the file-tool write gate refuses the same control paths inside those checkouts only.
  • Before -> after (what was allowed/blocked, now): before, a sandboxed agent could write .git/config, .git/hooks/*, .git/info/attributes of the install checkout and move .git aside; now those writes fail (EROFS/EBUSY, Seatbelt deny) while objects/refs/index/HEAD/logs stay writable.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): in-sandbox git in the install checkout that writes config fails (push -u, remote add, tracking branches); a failed pin bind refuses the spawn like any other failed sandbox mount.
  • Evidence checked (which sandbox result proves it): test/test_sandbox_git_control_real_sandbox.py in the namespace-sandbox lane (EROFS/EBUSY on every attack, host files unchanged, commit/branch/status/worktree add --no-track succeed); seatbelt render asserted in test_sandbox_git_control.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): git add/commit/branch/status/worktree add --no-track inside the real sandbox succeed; dev skills switched to --no-track and plain push.
    • Backward compatible (old config / old data / old callers still work, how checked): older launcher payloads without pin_dirs read as no pins; a plain checkout without commondir plans with no log line. This head is a pure rebase of c77d018 onto main 2859f88; the only conflict was the package line budget in test_security_gate_liveness.py (32,798 + 2 = 32,800). Main's host-side refusals from fix(updates): neutralize repo-local git exec config in the update check #24808/fix(git): apply repo-exec neutralization to remaining host-side git callers #24822 are unchanged.
    • Existing tests (which suites passed on this head): locally test_sandbox_git_control.py, test_sandbox_git_control_real_sandbox.py, test_sandbox_mount_checked.py, test_sandbox_protected_name_holds.py, test_sandbox_refactor_generated_programs.py, test_security_gate_liveness.py (168 passed, 3 skipped); CI backend and sandbox lanes green on this head.
  • How to undo: revert this commit; no data or config migration (created files are empty hooks/, info/ and config.worktree, which git reads as nothing).

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=48ded8310a58 product-shape change without accepted RFC

Rebutted: the RFC this blocker asks for is merged on the base. docs/request-for-change/rfc-sandbox-gateway-checkout-git-seal.md landed in #25692 (merged 2026-10-29T16:27:43Z), and its row in docs/request-for-change/README.md reads accepted.
Its section 2 records the decision: inside the sandbox, the git control files of gateway_checkout_roots() (KIROCREW_PROJECT_DIR and the source checkout) are read-only, and the git directory and renamable ancestors are pinned.
Its section 3 lists the losses this blocker named (git push -u, git remote add, gh pr checkout, pre-commit install in the gateway checkout) and records that a separate clone and every other repository are unaffected; section 2 records the skills' --no-track change.
The review ran on 2026-10-27, before that RFC merged. The rebased head c25dba3 sits on a base that carries it, and sandbox_git_control.py is unchanged by the rebase.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants