Repository navigation
fix(updates): neutralize repo-local git exec config in the update check - #24808
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: one shared isolated-fetch helper fixes the hook race for both callers, and the one refusal it adds (repo-set pack programs, helper remotes) is listed as breaking and accepted. Notes
[DESIGN-REVIEWED] 51fdf7e Description read[DESCRIPTION-READ] 656cdd415de15e96ea17a32a626bcfee04e0467aa8426a908aeddec133db39fd 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item closes a host-exec route the description reproduced. Two comments and the helper's name describe a tracking-ref pin that the helper itself says it deliberately does not do. Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: stop the source-checkout update check from running a program named by the checkout's own git config or attributes. FIX.
[FIRST-PRINCIPLES-REVIEWED] 51fdf7e Description read[DESCRIPTION-READ] 75e221849c2b6a4c9fe2452d0255218d4fc059575c0e4a1848210a43165fe67a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 51fdf7e 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: |
5ef256b to
34f3bbc
Compare
34f3bbc to
4ccc23b
Compare
4ccc23b to
9b44835
Compare
9b44835 to
3699155
Compare
3699155 to
e722b7c
Compare
b436b4c to
61304bb
Compare
|
/ai-review override gpt 61304bb false-positive: withheld credentials not exposed; fetch fails loudly (git_fetch_failed), only a checkout whose HTTPS auth comes solely from a conditional global include, recoverable via kirocrew update — the unbounded-harm fence misclassifies a niche visible regression |
Human judgment recorded@iamwhatever recorded a false-positive release (class
This decision applies only to this commit. A new push requires a new judgment. |
61304bb to
06caa8e
Compare
06caa8e to
3c47073
Compare
3c47073 to
51fdf7e
Compare
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 for docs only), UX skipped or pass, all checks green, no conflict, no open change request.
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]: Review findings still true on main after this merged are tracked in 25508: the update check now drops the user's credential helper ( |
Problem / Motivation
Goal: The update check never runs a program that the checkout's own git config or attributes name.
_check_git_checkoutruns at boot, every 12 hours, and on the dashboard's Check button. It runsgit fetch,rev-parse,rev-list,showanddiffon the host withcwd=KIROCREW_PROJECT_DIRand no guards. On a source-checkout install that directory is a tree agents can write. A repo-localcore.sshCommand,core.fsmonitor,core.hooksPath,diff.external,remote.<name>.uploadpack, or a.gitattributesdiff driver withdiff.<drv>.textconvtherefore runs on the host, outside the sandbox. Reproduced on main for each of these, plus the same keys reached throughinclude.path.Why it matters
Every source-checkout install runs this check by itself. A program planted in
.git/configruns as the gateway user with no sandbox, with no click needed.Not a goal
POST /api/updateendpoint's own git calls (updates_apply.py), and the unattended apply'sgit reset --hardstep. The unattended apply's FETCH is in scope and is fixed here (it shares the new helper); the reset is a separate step with its own preflight and is not touched.What changed (motivation → approach → change)
Root cause: the check spawned a bare
gitwith the inherited environment, while the unattended apply already had guards inupdate_governance._check_git_checkoutnow uses those shared guards. It resolves git withtrusted_git_bin(), runs every call withgit_command_env(), and refuses before any git call whenrepo_exec_config_reason()names a reason. A refusal is a failed check (git_read_failed), with a log line saying why.git diffadds--no-textconv --no-ext-diff, andgit showadds--no-textconv, so no attribute can send them to a driver..git/configin the window between the one-time preflight read and the fetch. A review won that race ~17% of the time, including with a config-definedhook.<name>.command(git 2.54+) that no-cpin or fetch flag closes (even aFETCH_HEAD-only fetch opens a ref transaction). The close is a new shared helper,fetch_and_pin_upstreaminupdate_governance, used by BOTH the check and the unattended apply fetch: it fetches against a throwaway git dir the gateway owns (GIT_DIRthere, so git reads its hook-free config) while objects land in the checkout's store, and returns the fetched commit OID both callers use directly. One fix for one bug class in two callers; this closes the apply-path variant too. It stays correct for real checkouts: object store, common git dir and fetch "have"s come from git layout probes (worktrees/submodules too, not justproj/.git); haves mean only the delta transfers; it fetchesrefs/heads/<branch>and verifies a commit (a same-named upstream tag cannot stand in);cwd=projresolves a relative or~local remote against the checkout; it copies a shallow clone's boundary, inherits the object format (SHA-256) and forwardshttp.*.extraHeaderauth throughGIT_CONFIG_*env (which git never re-splits at=); and the scratch dir sits under the sandbox-masked crew scratch root so a same-UID agent cannot race a hook in. No ref in the checkout is written; the tracking ref stays as the lastgit fetchleft it.git_command_env()setsGIT_ALLOW_PROTOCOL=file:git:ssh:http:https(no repo-named helper transport),GIT_PROXY_COMMAND="", andGIT_NO_LAZY_FETCH=1(a partial clone's on-demand fetch would bypass the isolated fetch). The isolated fetch alone pinsPATHto the trusted system dirs, since its git is absolute and other callers spawn a baregit.repo_exec_config_reasonrefuses acommondirredirect (a.git/commondirbeside a plain.gitdirectory, or a resolved common dir that is not that.git): a sandboxed agent can plant.git/commondireven under a bind seal, redirecting git's config and hooks. Closes the Linux commondir gap from fix(sandbox): write-protect git control files in the gateway's checkout #24812; a linked worktree (.gita file) is unaffected.count_divergencetakes optionalgit=andenv=, so the check runs it the same way.Backwards compatibility
Breaking:
repo_exec_config_reasonnow refuses a checkout whose config sets anyremote.<name>.uploadpackor.receivepack, and the update check now refuses on that function's reasons. It also refuses remote-helper (<helper>::) remotes. Writer sweep on origin/main @ f3a7d42: no code in the repo writes these keys into the install checkout. A user who set them by hand gets a failed check with a log line that names the key, andkirocrew updateis unchanged.Reader: src/kiro_crew/platform/update_capability.py:_git_route -- entry: release -- a refused repo already reports no unattended git route; test_update_capability.py passes
Reader: src/kiro_crew/slack/gateway_runtime/update_apply.py:_auto_apply_update -- entry: release -- refuses the unattended apply with the existing log line, and its fetch now goes through the shared helper, resetting to the OID the helper returns; test_slack_gateway_update_apply.py / test_slack_gateway_update_reset.py pass
Reader: src/kiro_crew/dashboard/handlers/updates_check.py:_check_git_checkout -- entry: crew page -- new caller, compares against the OID the helper returns; test_update_check_git_exec_neutralized.py
Reader: src/kiro_crew/git_divergence.py:count_divergence -- entry: crew page -- new kwargs default to the old behaviour; test_git_divergence.py passes
Tests
test/test_update_check_git_exec_neutralized.pydrives the real check against real git repos with a marker program:A clean clone one commit behind still reports the update, version, distance and changelog line.
These must not run:
core.fsmonitor,diff.external,core.hooksPathand default hooks,core.sshCommand, a.gitattributestextconv driver,include.pathandincludeIf,remote.origin/tracked-remoteuploadpack,fetch.all, and agitplaced on PATH.Race tests: the refusal answers "clean" and the vector is planted anyway, for uploadpack (origin, tracked,
fetch.all),core.gitProxy,remote.<n>.vcs,pwn::URLs and textconv. With the fetch flags removed, the first four ran.Race tests, for BOTH callers: with the exec-config preflight answered "clean" (the race won every time), a vector planted anyway must still not run —
hook.<name>.commandandcore.hooksPathhooks most of all, which no pin or flag closes, plus uploadpack,core.gitProxy, remote-helper and textconv vectors. The apply path has the same marker test driving_auto_apply_update.test_dashboard_updates_coverage.py's stand-in-git timeout/cancel tests now drive the shared helper directly (the fetch lives there), proving a hung fetch and its transport helper are killed and reaped.Proof: PROVEN test/test_dashboard_updates_coverage.py::TestGitFetchTimeoutReapsTheHelper::test_a_cancelled_fetch_ends_git_and_its_helper, test/test_spawn_audit.py::test_benign_allowlist_has_no_stale_entries, test/test_update_check_git_exec_neutralized.py::test_a_pinned_fixed_key_program_does_not_run[core.fsmonitor], test/test_update_check_git_exec_neutralized.py::test_a_pinned_fixed_key_program_does_not_run[diff.external], test/test_update_check_git_exec_neutralized.py::test_repo_hooks_do_not_run (head 51fdf7e)
Manual verification
Reproduced each vector on main (the marker ran), then ran the same script on this branch (no marker; a clean checkout still reports
succeededwith the changelog line). An independent reviewer that saw only the diff tried 23 vectors; the only break it found was the preflight-vs-fetch race, which the shared isolated-fetch helper closes (verified: a plantedhook/core.hooksPathreference-transaction hook runs on a normal fetch but not through the helper, whose own git dir names no hook).Follow-up
includeIf "gitdir:..."loses them on the isolated fetch (the include no longer matches). The check fails loudly (git_fetch_failed);kirocrew updatestill works. Fix later by forwarding onlysystem/global-scopecredential.*(viagit config --show-scope), neverlocal/worktree. GPT finding overridden for head 61304bb on this basis.Related Issues
Reported privately by an external researcher; no public issue.
Sibling sweep
Swept: git grep -nE 'create_subprocess_exec|subprocess.run' for every git fetch in the update seam, and git grep for the first-value-wins
remote.origin.uploadpackpinSibling: src/kiro_crew/slack/gateway_runtime/update_apply.py -- changed here -- its fetch now uses the shared
fetch_and_pin_upstream, closing the same raceSibling: src/kiro_crew/dashboard/handlers/updates_check.py -- changed here -- its fetch now uses the shared
fetch_and_pin_upstreamSibling: src/kiro_crew/apps/builtins/md_notebook/git_ops.py -- tracked in #24845 -- a different surface (notebook git ops) with the same first-value-wins
remote.origin.uploadpackpin, out of this PR's update-seam goalSibling: src/kiro_crew/apps/builtins/papyrus/backend/gitops.py -- tracked in #24845 -- same, in the papyrus git ops
Pattern harvest
Rule candidate: semgrep
Pattern:
asyncio.create_subprocess_exec("git", ...)orsubprocess.run(["git", ...])in update/gateway code withoutenv=git_command_env()and atrusted_git_bin()binary.Checklist