Cloning a Repo Is Now Code Execution: Inside the Coding-Agent Git Flaw
The consent dialog everyone treats as a security boundary renders after the attacker's command has already run, which is why environment hardening beats approval prompts.
The delivery path decides the threat model
A plain git clone over the wire does not carry .git/config. That is the one piece of good news, and it is why this is not worm-grade. Everything else an engineer touches in a normal day does carry it. Archives and zips that ship a .git directory. Submodules. Vendored monorepo subtrees. CI caches. Docker build contexts. Untrusted PR branches carrying a .gitattributes that references a filter driver. The attacker's work reduces to pointing an agent at a tree they control, and "clone this repo and figure out what it does" is a daily habit now, not an exotic request.
Git config is dangerous because it is a command-naming surface, not a settings blob. core.pager, core.editor, core.sshCommand, core.fsmonitor, diff.external, filter.*.clean/smudge, credential.helper and alias.* all resolve to something a shell will execute. Agents call git constantly to build context: status, diff, log, blame, all inside a directory the user handed them. If the agent never neutralizes config precedence for that directory, the repository is the caller and the agent is its shell.
Mitigation posture, honestly compared
| Approach | Blocks repo-config exec | Contains credential theft | Effort |
|---|---|---|---|
| Host-native agent, auto-approve tools | No | No | Status quo |
| Approval prompt on every shell call | Partial — dies to alert fatigue | No | Hours |
| Hardened git env + repo-config pre-flight scan | Mostly | No | Hours |
| Ephemeral devcontainer, no host creds, egress allowlist | Yes (contained) | Yes | Days |
Risky.Biz supplies the detail that kills the middle row: the repo's commands run before the trust prompt renders. Approval UX also stops working once an engineer has clicked "allow" forty times in one session. Hardened environment variables first. Containers as the follow-on.
The credential half is already automated
Two adjacent findings decide how bad a successful run gets. GitGuardian reports a Shai-Hulud infostealer variant that scans 469 credential locations across developer environments and CI/CD systems. Worm authors have shifted from propagation metrics to credential-yield optimization, and that list doubles as a free audit checklist for wherever the secrets actually sit. Symantec separately published research on attackers abusing the legitimate Node.js runtime to deploy payloads in targeted attacks. Node now sits beside PowerShell, mshta and rundll32 as a signed, expected, un-blockable execution vector on every engineering workstation and build runner. The remaining lever is behavioral: NODE_OPTIONS carrying --require or --import, node -e invocations, node binaries resolving from temp or roaming-profile paths, and node processes spawning shells.
If an AI agent can run git, the repository it just cloned can run code. The prompt asking whether you trust the project renders too late to matter.
One honest caveat on scoping the work: the reporting carries no CVE IDs, no affected version ranges and no patch status. Pull the Manifold Security advisory before assigning remediation tickets, because version ranges are what decide whether a given team's Cursor and Codex builds are in scope at all.
Then audit the tooling nobody will patch for you. Any internal script, monorepo task runner or pre-commit orchestrator that reads repo-local config and invokes a named binary has the identical bug. No vendor advisory is coming for that one.
What to do
Ship a hardened git profile for agent contexts this week: GIT_CONFIG_NOSYSTEM=1, GIT_PAGER=cat, forced --no-pager, explicit safe.directory handling, and a pre-flight scan that rejects any tree shipping its own .git/config, filter drivers, or core.fsmonitor.
Move agent sessions on external repos into an ephemeral devcontainer or micro-VM this sprint, with no SSH agent forwarding, no mounted ~/.aws or ~/.npmrc, and egress limited to your model endpoint and package registry.
Migrate CI publish and cloud access to OIDC workload identity federation and rotate every static token that touched a runner in the last 90 days.