Repository navigation
Keep agent-planted git hooks and drivers out of capture - #2071
Merged
Merged
Conversation
The capture, the re-attach capture and the branch commit ran git inside the agent's clone after its turn, with the network on and no hardening. An agent that wrote its own .git during the run could make those commands run its code: client hooks (a vetoing pre-commit silently lost the produced branch), an agent-set core.hooksPath, a core.fsmonitor program, and textconv or external diff drivers selected through .gitattributes or diff.external. Every git command over the agent clone now goes through one builder, AgentCloneGitCommand: -c core.hooksPath=/dev/null, -c core.fsmonitor= and --no-ext-diff --no-textconv on diffs, with no network and no credential. The fsmonitor value is empty rather than "false" because git before 2.36 reads the key only as a program path and runs a PATH-resolved "false" on every index refresh. The hooks path is /dev/null rather than an empty value, which git resolves to the filesystem root. The -c values also reach the gc --auto a commit can start, so an agent that lowers gc.auto and re-enables the maintenance gc task (off by default since git 2.54) cannot run pre-auto-gc either. A repo filter.<driver>.clean still runs on add -A because git has no command-line switch for it. It runs at the agent's own uid with no secret and, under bubblewrap, with no egress. Global and system config stay in force for git-lfs and operator CA or proxy settings. The sandbox lane's floor counts the bubblewrap case that proves the egress is severed, and the lane requires that case to have passed, because a skipped case reads as green. The authenticated push and its ls-remote readback still run in the agent clone. Moving them to a platform-owned repository is a separate change.
ppXD
changed the base branch from
fix/pass-every-claude-goal-as-a-structured-message
to
main
October 6, 2026 11:04
ppXD
force-pushed
the
fix/keep-agent-git-hooks-out-of-capture
branch
from
October 6, 2026 11:04
8b87a80 to
f68742f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.gitcould therefore run code:pre-commitsilently lost the produced branch)core.hooksPathcore.fsmonitorprogramAgentCloneGitCommand(backend/src/CodeSpace.Core/Services/Agents/Workspace/AgentCloneGitCommand.cs). It adds-c core.hooksPath=/dev/null,-c core.fsmonitor=, and--no-ext-diff --no-textconvon diffs, and runs with no network and no credential.filter.<driver>.cleanstill runs onadd -A, because git has no switch for it. It runs at the agent's uid, with no secret and, under bubblewrap, no egress.Test plan
AgentCloneGitCommandTests; theLocalGitWorkspaceProviderTestsrouting Theory (every post-turn command in the clone is hardened, off the network, credential-free)AgentCloneGitHookIsolationFlowTests: 13 planted vectors stay silent under the hardened capture and commit, and a positive-control Theory shows each one fires when unhardened. Run on git 2.33.0, 2.50.1 and 2.56.0. The pre-auto-gc plant also setsmaintenance.gc.enabled=true: from git 2.54 auto maintenance uses the geometric strategy by default, which skips the gc task, so without that key the positive control never fired on CI's git 2.55.0.GitWorkspaceIsolationE2ETests.A_repo_clean_filter_runs_during_capture_with_its_egress_severedpasses and the lane reports ≥ 97 executed