Repository navigation
fix(git): apply repo-exec neutralization to remaining host-side git callers - #24822
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Each host-side git caller gets the project's existing Notes
[DESIGN-REVIEWED] b35f3f0 Description read[DESCRIPTION-READ] a4c753646b9ef2f6c7cf6a0498bb2cdf4d016ade816e919d8021927b979ab510 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 Every item closes one root cause, host git running a program named by agent-writable repo config, across sibling callers. The shared mechanisms are reused rather than respelled. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: stop the dashboard,
[FIRST-PRINCIPLES-REVIEWED] b35f3f0 Description read[DESCRIPTION-READ] 94bf2b8b9f563c148d7c1ba0a98dbb2f890e803249dfa95110612a20a7d8c9bf That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- src/kiro_crew/cloud/source.py:621 -- Preserve global export-ignore exclusions when packaging source
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 — Harm: LOW. The archive path at
When that happens, the file is uploaded to the operator's own S3 bucket and EC2 instance ( The real fix costs more than that harm. It needs a second probe that reads the global attributes file, which the isolation design deliberately treats as agent-writable and refuses to read ( False positive or not applicable? A repository writer can comment: |
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: |
966e701 to
9e3e529
Compare
31a7cac to
18e11a0
Compare
18e11a0 to
79e6f63
Compare
c35277d to
35d3c75
Compare
8a252e0 to
403b8d4
Compare
c5b3254 to
ba153bb
Compare
ba153bb to
999de43
Compare
999de43 to
6800d5f
Compare
6800d5f to
c7351a0
Compare
…allers Host-side git calls over agent-writable trees ran programs named by the repo's own config: core.fsmonitor and hooks (dashboard update apply, kirocrew update, code fingerprint, build-source stamp, cloud source tarball, dashboard file diff, auto-improvement git apply), repo-named filter drivers (same callers), nested-repo filters (every probe), merge drivers and gpg.program (auto-improvement). Pins every fixed-name key through git_command_env, refuses repo-named drivers (own and nested) before the call, and re-probes before the destructive update step.
Problem / Motivation
Goal: No host-side git call over a tree an agent can write runs a program that the repository's own config or attributes name.
An external report showed
updates_check.py::_check_git_checkoutrunning host git in an agent-writable checkout without the repo-exec neutralizers (update_governance.git_command_env,repo_exec_config_reason). A sibling PR fixes that file. This PR sweeps every OTHER host-side git caller. Several had the same hole: an agent that writes.git/config(core.fsmonitor,filter.<n>.clean),.git/hooks/*or a.gitattributescould get the dashboard,kirocrew update, the gateway's startup fingerprint or the auto-improvement app to run its program outside the sandbox, with the operator's privileges.Why it matters
These calls run in the gateway/dashboard/CLI process, unsandboxed. A planted program there is a sandbox escape: it runs as the operator, with their credentials, on paths the agent cannot otherwise reach. The dashboard file diff and the startup fingerprint need no click at all beyond opening a file or starting the gateway.
Not a goal
dashboard/handlers/updates_check.py(sibling PR).gitoffPATHat the sites that still spawn a bare"git"(a planted shim onPATHis a different vector from repo config; the update and fingerprint paths that already usetrusted_git_binkeep it).sandboxed_spawn_argv/wrap_argv): a program they reach runs inside the sandbox.What changed (motivation → approach → change)
Measured on git 2.47.3 which subcommands run a planted program, then fixed every host-side caller whose command does (full table below). Two shared mechanisms, both already the project's own:
core.fsmonitor,core.hooksPath,diff.external,core.pager, ...):git_command_env()pins them throughGIT_CONFIG_*.filter.<n>.*,diff.<n>.textconv/command,hook.<n>.command): no key to pin, so the caller refuses first. Update paths use the existingrepo_exec_config_reason. Read-only callers use a new narrowerrepo_exec_driver_reason(same probe without the fetch-only URL-rewrite / transport-trust / work-tree refusals, so a plain diff in a repo withurl.<base>.insteadOfstill works). It still refuses the transport keys (credential.<url>.helper,remote.<n>.vcs,core.gitProxy) andremote.<n>.uploadpack/receivepack: in a partial clone, a read-onlyarchive/diff/showlazy-fetches missing blobs over the transport (tested end to end: ablob:noneclone'sgit showin the file diff).core.excludesFilefrom git's effective view (--includes, global/system scope only), so a value set through a global include still ignores its files.<redacted>(before truncation), so a credentialedurl.https://user:token@host/.insteadOfnever reaches the gateway log or the 409 body.status/diff/addstart a child git there that runs the nested repo's own filter. This also closes that gap on the existing gateway auto-apply path.Per site:
dashboard/handlers/updates_apply.py: refuse (409repo_exec_config) before the first git call and again right beforemerge --ff-only;git_command_envon every spawn and on the floor read.cli_server_update.py: same refusal beforefetchand again right beforereset --hard; one env on every spawn, the branch lookup and both divergence counts included (count_divergence[_sync]takeenv=), so an inheritedGIT_DIRcannot make the guards judge a different repository than the reset.code_fingerprint.hardened_git_env: now carries thegit_neutralizer_envpins (it only silenced global/system config);_git_fingerprintfalls back to the mtime rule on a driver.frontend._write_build_source_fingerprint: env + driver refusal → no stamp (rebuild direction).cloud/source.py: env onarchive/ls-files/status; a driver sends packaging to the tracked-file tar path;archivewrites plain tar (Python compresses it) because--format=tar.gzruns the repo'star.tar.gz.command. A tree whose tracked files carry anyfilterattribute (LFS) packages the working files (minusexport-ignorepaths), since the isolated archive would ship raw blobs. Each ancestor directory is asked aboutexport-ignoreboth bare and with a trailing/, so a directory-only pattern (docs/ export-ignore) is left out asgit archiveleaves it out.gpg.ssh.programandgpg.x509.programare pinned besidegpg.program(anexport-subst%G?inarchiveverifies an SSH-signed HEAD).remote.origin.uploadpack/receivepackpins are now the bare names (an absolute path is sent to an ssh server as the remote command and rejected). Git takes the firstuploadpackit reads, the repository's, sorepo_exec_config_reasonnow refusesremote.*.uploadpack/receivepackand both human-run fetches pass--upload-pack=git-upload-pack. For the FETCH of those two paths only,git_command_env(human_transport=True)keeps the operator's global config (as main's fetch already did, beside fix(git): keep agent-writable global git config out of host-side git #24824's isolation for every other call) and leavescredential.helperandcore.sshCommandunpinned, so git reads the operator's own config natively (includes,includeIf, per-URL helpers, resets), andrepo_exec_config_reason(..., human_transport=True)refuses the repository's own value of those two keys instead. Both probes takegit=so they run the same binary as the caller (a host whose git is outside the trusted dirs is checked, not refused as unreadable).dashboard/file_api/editor.py(api_file_diff): its-cflags left hooks and filters open; nowgit_command_env+ driver refusal →status: "error". The listener, routes and auth are unchanged.git applycalls carried a bare argv; they now userequire_pinned+GIT_SAFE_CONFIG+hook_off_argslike every sibling.git_safetyadditionally pinscommit.gpgSign=false/tag.gpgSign=false,log.showSignature=false,merge.verifySignatures=falseand every signer program (gpg.program,gpg.ssh.program,gpg.x509.program) to a path that cannot exec, extends the attributes pin to* -filter diff merge(built-in merge driver, which is also the default for an unspecified path) with inert[attr]diff/[attr]mergemacros defined first, so a repository macro of either name cannot expand back intofilter=<n>, andrequire_pinnedrefuses a nested repo whose effective config (hasconfig:includes resolved) declares a driver, or whose own attributes bind a global/system driver by name (an unbound globalfilter.lfsor per-URL credential helper does not refuse; a nested repo that cannot be fully probed, including one whose.git/configwas deleted, and any probe timeout, refuses instead of being skipped) (its spawn-free index check reads only a plain, single-link, size-capped file; a FIFO or device goes to the timed git probe).The full audit table (file:line, cwd source, verdict) is under Sibling sweep.
Backwards compatibility
Breaking:
POST /api/updateandkirocrew updatenow refuse a checkout whose own.git/config(or a nested repo's) declares a repo-named driver, a URL rewrite, a transport-trust override or aremote.*.uploadpack/receivepack; the dashboard file diff answersstatus: "error"and the fingerprint/stamp/cloud paths fall back when it declares a driver. Because the shared probe now walks nested repos, the existing readers ofrepo_exec_config_reasonalso refuse a checkout whose SUBMODULE declares a driver (e.g.git lfs install --localinside a submodule): the gateway auto-apply (slack/gateway_runtime/update_apply.py) and the auto-route capability (platform/update_capability.py:553). The auto-improvement app refuses host git in a tree with a driver-declaring nested repo, and no longer signs commits (trade-off: an operator whose globalcommit.gpgSign=truegets unsigned auto-improvement commits, because the signer program is exactly what a repo-localgpg.programwould replace). Writer sweep on origin/main @ a62012b: these refusals have no writers to update; the only callers of the changed functions are the routes/CLI themselves and the tests updated here.git lfs installwritesfilter.lfs.*to GLOBAL config, which none of the probes read, so a normal LFS checkout is unaffected.Compatible for transport: the human-run update paths read the operator's credential helper and
core.sshCommandexactly as before this PR (unpinned); a checkout whose OWN.git/configsets either is refused with a named reason. ssh fetches work again on the gateway auto-apply path, which pinned an absolute upload-pack on main.Removes nothing: no route, key, field or function is removed or renamed;
repo_exec_config_reasonkeeps its signature and verdicts for a repo without nested gitlinks.Tests
test/test_host_git_repo_exec_neutralization.py: real repos with marker programs in repo-local config; each test first proves an unpinned git runs the marker, then drives the fixed caller and asserts it did not (fingerprint, build stamp, cloud tarball, file diff, dashboard apply end to end through status/fetch/count, CLI update end to end through fetch/status/reset, refusals, both re-probes, nested repos).test/test_auto_improvement_host_git_apply_pins.py:materialize_queued_diff,_apply_argv(plain and--3way),_stage_winner, a signed commit, amerge.<n>.driver, a nested-repo filter.subprocess.runstub the new probe (it cannot answer a fake);test_launch_engine_refnow asserts the pins are present.Config keys tested:
core.fsmonitor,core.pager,diff.external,.git/hooks/{post-index-change,reference-transaction,post-merge,post-checkout,pre-commit},filter.pwn.clean,filter.pwn.smudge,diff.pwn.textconv(also planted during the CLI fetch, reaching theHEAD..targetdiff, now--no-textconv --no-ext-diff),merge.pwn.driver,commit.gpgSign+gpg.program,tar.tar.gz.command,remote.upstream.uploadpack,remote.origin.uploadpack, a nested repo'sfilter.*.clean(also behind acore.worktreeredirect and with no trusted git),url.<base>.insteadOf, repo-localcredential.helper/core.sshCommand(refused on human-run paths), and globalcredential.helper/credential.<url>.helper/core.sshCommandread natively (includes,includeIf, empty resets), plus probes on a host with no trusted git.Run against origin/main's code, 39 of the 41 new tests fail. The two that pass on main: the
_stage_winnerwiring test, and the[attr]mergemacro case (main's pin never setsmerge; the case guards this PR's own pin).Proof: PROVEN src/kiro_crew/apps/builtins/auto_improvement/tests/test_dogfood_learnings_commit.py::TestQueuedDiffTransport::test_patch_stdin_preserves_line_endings_and_non_utf8_bytes[\n], src/kiro_crew/apps/builtins/auto_improvement/tests/test_dogfood_learnings_commit.py::TestQueuedDiffTransport::test_patch_stdin_preserves_line_endings_and_non_utf8_bytes[\r\n], test/test_auto_improvement_host_git_apply_pins.py::test_materialize_queued_diff_apply_runs_no_planted_program, test/test_auto_improvement_host_git_apply_pins.py::test_commit_runs_no_repo_gpg_program, test/test_auto_improvement_host_git_apply_pins.py::test_nested_repo_driver_is_refused (head b35f3f0)
Manual verification
N/A — every fixed site is exercised by a test that runs real git against a poisoned repo; the measured command table was produced by standalone probe scripts on git 2.47.3.
Related Issues
Refs the external report on
updates_check.py::_check_git_checkout(sibling PR fixes that file).Sibling sweep
Swept:
git grep -nE '"git"|trusted_git_bin|git_bin' -- src/kiro_crewplus an AST scan of everysubprocess.run/Popen/check_output/create_subprocess_exec/create_subprocess_limitedwhose argv mentions git, then a fresh reviewer pass over the audit + diff.Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- changed here
Sibling: src/kiro_crew/cli_server_update.py -- changed here
Sibling: src/kiro_crew/code_fingerprint.py -- changed here
Sibling: src/kiro_crew/frontend.py -- changed here
Sibling: src/kiro_crew/cloud/source.py -- changed here
Sibling: src/kiro_crew/dashboard/file_api/editor.py -- changed here
Sibling: src/kiro_crew/apps/builtins/auto_improvement/backend/commit.py -- changed here
Sibling: src/kiro_crew/apps/builtins/auto_improvement/spine/driver_commit.py -- changed here
Sibling: src/kiro_crew/apps/builtins/auto_improvement/spine/git_safety.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/update_apply.py -- not affected -- already pinned and refused; nested-repo gap closed by the shared probe
Sibling: src/kiro_crew/dashboard/handlers/updates_check.py -- not affected -- fixed by the sibling PR for the original report
Full audit table (file:line, cwd source, verdict)
Host-side git audit
Scope: every place a HOST process (gateway, dashboard, CLI, update/apply, app backends, cron, hooks) spawns
gitwithcwd/-Cin a tree an agent can write. Base:origin/main@aeb5c02c4b.dashboard/handlers/updates_check.pyis excluded (a sibling PR fixes it).Which subcommand runs a program named by repo-local config or attributes was MEASURED on git 2.47.3. Planted:
core.fsmonitor,.git/hooks/*,filter.pwn.clean/smudge+.gitattributes,diff.pwn.textconv,diff.external,core.pager,merge.pwn.driver,commit.gpgSign+gpg.program, and a nested repo (gitlink) with its ownfilter.*:git_command_envpinsstatus, worktreediffreset --hard,merge --ff-onlyls-files,fetch,applyadd -Aarchivetar.<fmt>.commandfor a compressed formatfetchfrom a non-originremoteremote.<name>.uploadpack--upload-pack)show <commit>--no-textconv)apply --3way,rebasemerge.<n>.drivermerge)commit,rebasewithcommit.gpgSigngpg.programcommit.gpgSign=false)rev-parse,rev-list,log --format,for-each-ref,symbolic-ref,config --get,ls-remote --get-url,worktree list,merge-base,show <rev>:<path>, tree-to-treediff --quiet/--stat/--name-status,cat-file,var,remoteFixed-name keys are closed by
update_governance.git_command_env()(GIT_CONFIG_*pins). Repo-NAMED drivers cannot be pinned, so callers refuse first: update paths withrepo_exec_config_reason, read-only callers with the new narrowerrepo_exec_driver_reason. Every repo-chosen name in these refusals (and inworktree._FILTER_KEY_RE) now matches an EMPTY name too: git runs[filter ""]bound byfilter=(reproduced on git 2.47), and the old.+letfilter..cleanthrough. Both now also walk every initialized nested repo the index records as a gitlink, joined onto git's effective work tree (core.worktreehonoured).nested_repo_exec_driver_reasonis the nested-only formgit_safetyuses; it probes with the same baregitthe app runs, so a host without a trusted git is still checked.dashboard/handlers/updates_apply.py:460,504,574,661status,fetch,rev-parse,merge --ff-onlyKIROCREW_PROJECT_DIRrepo_exec_config_reasonrefusal (409repo_exec_config) before the first git call AND again right before the merge (the fetch is a window), +git_command_envon every spawn and the floor read. The barefetchfollows the TRACKED remote, whoseremote.<name>.uploadpackno env pin names, so it passes--upload-pack=git-upload-packcli_server_update.py:187,345,400fetch,status,reset --hardKIROCREW_PROJECT_DIRstatus, and again right before the reset (the fetch and the prompt are windows), + env on every spawn after the first probecli_server_update.py:153,215,236rev-parse, tree-to-treediff --quietKIROCREW_PROJECT_DIRcode_fingerprint.py:103(_git_fingerprint)diff HEADhardened_git_envsilenced global/system config only; repo fsmonitor/hooks ran. Now carries thegit_neutralizer_envpins; driver refusal -> mtime fallbackfrontend.py:664(_write_build_source_fingerprint)status -- websitecloud/source.py:615,711,736archive,ls-files,statusrepo_root()checkoutls-files);archive --format=tar.gzran the repo'star.tar.gz.command, so git now writes plain tar and Python compresses itdashboard/file_api/editor.py:527,539,552,563(api_file_diff)show,diff HEAD,status,diff --no-index-cflags pinned fsmonitor/textconv, not hooks (post-index-changeran) or filters. Nowgit_command_env+ driver refusal ->status: errorapps/builtins/auto_improvement/backend/commit.py:169apply --index -require_pinned+GIT_SAFE_CONFIG+hook_off_argslike every siblingapps/builtins/auto_improvement/spine/driver_commit.py:149,418apply,apply --3way_apply_argvapps/builtins/auto_improvement/spine/git_safety.py(all its callers:gate,driver_git,driver_publish,proposer, ...)add -A,status,commit,rebase,apply --3wayrequire_pinnednow refuses),merge.<n>.driver(attributes pin* -filter diff merge),gpg.program(commit.gpgSign=false,tag.gpgSign=false). Before this only the post-agent_repository_is_safesnapshot caught the last twoslack/gateway_runtime/update_apply.pygit fetchKIROCREW_PROJECT_DIRslack/gateway_runtime/update_apply.py(other calls)KIROCREW_PROJECT_DIRdashboard/stale_bundle_guard.py:113,cloud/ec2.py:638rev-parse;ls-remotein trusted git dirhardened_git_envplatform/update_governance.py:128,platform/update_capability.py:163dep_sync.py:498show <rev>:<path>git_divergence.py:123,165rev-list --countenv.py:838,dashboard/handlers/debug.py:685,pod/runtime.py:368,cli_doctor_parts/host_probes.py:104,auto_improvement/spine/scope.py:56rev-parse,log -1 --format,worktree list, tree-to-treediff --name-onlyapps/builtins/md_notebook/git_ops.py:494remote_session/workspace_tools.py::_git_statusstatusapps/builtins/dev_fleet/repository.py:32rev-parsedashboard/handlers/worktree.py::_run_git,dashboard/file_api/git_panel.py::_run_git_bounded,project_tree.py:746,756,dashboard/handlers/themes.py:295,git_coord.py:834,873,dashboard/terminal_commands.py,file_explorer/server.py,design_critique/backend/routes.py,spec_builder/backend/repository_git.py,dev_fleet/runtime.py::_run_cmd(+worktree_ops*,fleet_state,npm_preflightsync step),ops_mission_control/backend/ledger_sync.py,papyrus/backend/gitops.py,registry_pipeline/*(incl.install_rollback.py),apps/routes_art.pysandboxed_spawn_argv/wrap_argv), so not host-sidebuiltin_skills/*/scripts/*(prepare-pr, pipeline-conductor, security-conductor)apps/registry_pipeline/checkout.py:553init.git/commondirredirect (allrepo_exec_config_reasoncallers)Shared-helper corrections the human-run update paths needed:
remote.origin.uploadpack/receivepackwere pinned to an ABSOLUTE path, which over ssh is sent to the server as the remote command; GitHub/GitLab reject anything but the bare name, so every ssh fetch failed (already true of the gateway auto-apply on main). They are now pinned to the bare names; for a local transport git resolves those from its own exec-path first.uploadpackit reads, the repository's.repo_exec_config_reasonnow refusesremote.<any>.uploadpack/receivepack(covers all three update paths), and the dashboard and CLI fetches also pass--upload-pack=git-upload-pack, which does win.git_command_env(human_transport=True)(the dashboard and CLI FETCH only; every other call keeps fix(git): keep agent-writable global git config out of host-side git #24824's home-config isolation) reads the operator's global config and leavescredential.helperandcore.sshCommandunpinned, because the emptycredential.helperpin clears git's whole helper list (per-URL entries included) and a human-run update to a private remote must keep the operator's own setup. The repository's own value of those two keys is refused instead (repo_exec_config_reason(..., human_transport=True)). The unattended gateway path keeps the pins.git=and run the caller's own binary, so a host whose git is outside the trusted dirs gets a real answer instead of "unreadable git config".Known limit (not new): every probe is check-then-use. An agent writing config between the probe and the call it guards can still win. The update paths re-probe right before the destructive step, as the gateway path already did.
Nested-repo probe (git_safety callers): reads git's scope-tagged effective view under a global-visible env and also counts a global/system
filter.<n>/diff.<n>driver when the nested repo's own attributes bind<n>(check-attr, no driver run), because those host calls read agent-writable global config. An unbound globalfilter.lfs.*or credential helper does not refuse.Pattern harvest
Rule candidate: review-prompt
Pattern: a host-side
subprocessgit call in an agent-writable tree withoutgit_command_env()(orgit_safety.git_argv) and a repo-named-driver refusal.Checklist