Back to Intelligence

Malicious .git Configs Hijack Claude Code, Codex, Cursor AI Agents — Detection and Hardening Guide

SA
Security Arsenal Team
September 2, 2026
11 min read

Manifold Security has disclosed a cluster of eight vulnerabilities spanning seven command-line AI coding agents — including Anthropic's Claude Code, OpenAI's Codex CLI, and Cursor's CLI — that allow a malicious Git repository to execute arbitrary commands on a developer's machine. The mechanism is deceptively simple: the repository's own .git/config file names a command, the agent invokes a Git operation that honors that configuration directive, and the attacker's payload runs. Four of the eight flaws were still unpatched at the time of publication.

What makes this class of bug dangerous is where it lands in the trust model. The command executes as the developer user, outside the agent's sandbox, and without an approval prompt — bypassing the very guardrails vendors built to keep agentic tooling safe. The exploitation prerequisite is trivially met in real workflows: an engineer clones or opens an attacker-controlled repository, or pulls a branch/submodule containing a poisoned config, and asks the agent to do something routine. Every organization that has greenlit AI coding assistants — and in 2026, that is most engineering organizations — now has developer workstations as a first-class initial access vector.

This is a supply-chain-shaped problem aimed at your most privileged endpoints. Developer machines hold cloud credentials, SSH keys, signing material, source code, and CI/CD tokens. Treat this with the same urgency you would a workstation-targeted zero-click.

Technical Analysis

Affected products

Per the Manifold Security disclosure, eight distinct flaws affect seven command-line AI coding agents, including Claude Code, Codex CLI, and Cursor's agent. The common thread is not a single shared library — it is a shared design assumption: the agent shells out to git in a repository whose configuration it has not validated, and Git's config surface includes directives that name executable commands.

How the attack works

Git has long shipped configuration keys that point at external programs. When any process — human or agent — invokes the relevant Git operation inside a repository, the configured command runs with that process's privileges. The dangerous keys most relevant here include:

  • core.sshCommand — executed when Git performs SSH-based fetch/pull/push or submodule operations
  • core.fsmonitor — executed when Git checks working-tree status (an agent running git status or diff operations is enough)
  • core.pager / core.editor — executed when output is paged or an editor is spawned
  • gpg.program / signing-related hooks — executed during commit or tag verification flows

The attack chain from a defender's perspective:

  1. Delivery — Attacker publishes or contributes to a repository containing a .git/config with a weaponized directive (or tricks a developer into fetching a branch, submodule, or fork where the config is staged). Note that .git/config is not tracked by Git itself, but attackers stage it via tarballs, template repositories, malicious submodules, or git config invocations embedded in repo content the agent is asked to process.
  2. Trigger — The AI agent, doing ordinary agentic work (status checks, fetching context, submodule init, diffing), invokes the Git operation that honors the poisoned key.
  3. Execution — The attacker command runs as the developer user. Because the agent itself initiated the Git call, the execution inherits the agent's ambient authority — no sandbox boundary is crossed because the sandbox was never between Git and the OS, and no human approval prompt fires because the agent considers a git invocation routine.
  4. Post-exploitation — On a developer endpoint, the natural follow-on is credential theft (.ssh, .aws, .kube, .azure, git credential helpers), persistence, and lateral movement into CI/CD.

Exploitation status

The disclosure is a coordinated research release by Manifold Security. Four of the eight issues were patched by vendors; four remained unpatched at publication, meaning functional attack surface persists across widely deployed agentic tools right now. No CVE identifiers were assigned in the source reporting, and there is no confirmed in-the-wild exploitation at time of writing — but the technique requires no exotic primitives, and every red teamer reading this recognizes how easily a poisoned repo lands in a developer's workflow. Assume weaponization is a matter of when, not if.

Detection & Response

The highest-fidelity detection opportunities are (1) writes of command-bearing keys into .git/config, (2) Git spawning child processes it should never spawn, and (3) AI agent processes producing unexpected descendants. All three are observable with standard EDR/Sysmon telemetry.

Sigma Rules

YAML
---
title: Git Spawning Shell or Script Interpreter as Child Process
id: 3f8a2c71-9b4d-4e6a-a1c2-5d7e9f0b8a34
status: experimental
description: Detects git.exe spawning shells, script interpreters, or common LOLBins — consistent with command execution via malicious .git/config directives (core.sshCommand, core.fsmonitor, core.pager) abused to hijack AI coding agents.
references:
  - https://thehackernews.com/2026/09/malicious-git-configs-can-make-claude.html
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/09/15
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_parent:
    ParentImage|endswith:
      - '\git.exe'
      - '\git-remote-https.exe'
      - '\git-remote-ssh.exe'
  selection_child:
    Image|endswith:
      - '\cmd.exe'
      - '\powershell.exe'
      - '\pwsh.exe'
      - '\wscript.exe'
      - '\cscript.exe'
      - '\mshta.exe'
      - '\rundll32.exe'
      - '\certutil.exe'
      - '\curl.exe'
      - '\bash.exe'
      - '\sh.exe'
  condition: selection_parent and selection_child
falsepositives:
  - Rare; legitimate Git hooks configured by developers may spawn interpreters — baseline per-repo hook usage before tuning
level: high
---
title: Command-Bearing Git Config Key Written via git config
id: 7c1e9d42-2a5f-4b8c-b3d6-8e0a4f1c6b29
status: experimental
description: Detects git config invocations that set executable-naming directives (core.sshCommand, core.fsmonitor, core.pager, gpg.program) — the mechanism used to poison a repository's .git/config and hijack AI coding agents.
references:
  - https://thehackernews.com/2026/09/malicious-git-configs-can-make-claude.html
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/09/15
tags:
  - attack.execution
  - attack.t1059
  - attack.defense_evasion
logsource:
  category: process_creation
  product: windows
detection:
  selection_img:
    Image|endswith: '\git.exe'
  selection_cmd:
    CommandLine|contains:
      - 'config'
  selection_keys:
    CommandLine|contains:
      - 'core.sshCommand'
      - 'core.sshcommand'
      - 'core.fsmonitor'
      - 'core.pager'
      - 'core.editor'
      - 'gpg.program'
      - 'credential.helper'
  condition: selection_img and selection_cmd and selection_keys
falsepositives:
  - Developers legitimately configuring core.sshCommand for custom SSH or core.pager for diff tools — investigate non-standard paths and newly onboarded repositories
level: medium
---
title: AI Coding Agent Process Spawning Suspicious Descendants
id: 9d4b6f18-3c7e-4a1d-92b5-6f8c0e2a7d51
status: experimental
description: Detects CLI AI coding agents (Claude Code, Codex, Cursor) spawning shell interpreters or download cradles — consistent with out-of-sandbox command execution triggered by malicious repository configuration.
references:
  - https://thehackernews.com/2026/09/malicious-git-configs-can-make-claude.html
  - https://attack.mitre.org/techniques/T1059/
author: Security Arsenal
date: 2026/09/15
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: windows
detection:
  selection_parent:
    ParentImage|endswith:
      - '\claude.exe'
      - '\codex.exe'
      - '\cursor-agent.exe'
      - '\cursor.exe'
    ParentCommandLine|contains:
      - 'claude'
      - 'codex'
      - 'cursor-agent'
  selection_child:
    Image|endswith:
      - '\powershell.exe'
      - '\pwsh.exe'
      - '\cmd.exe'
      - '\curl.exe'
      - '\certutil.exe'
      - '\bitsadmin.exe'
      - '\mshta.exe'
  selection_suspicious:
    CommandLine|contains:
      - 'http://'
      - 'https://'
      - '-enc'
      - 'FromBase64String'
      - 'IEX'
      - 'DownloadString'
      - 'Invoke-WebRequest'
  condition: selection_parent and selection_child and selection_suspicious
falsepositives:
  - Agent workflows legitimately fetching remote content — correlate with repository provenance and whether the fetched host is an approved internal or vendor domain
level: high

KQL — Microsoft Sentinel / Defender

The following hunts the full kill chain: Git config poisoning, Git spawning interpreters, and agent processes producing anomalous descendants. It runs against Defender for Endpoint telemetry; for Linux developer workstations, ship Syslog/auditd execve events into Sentinel and adapt the process names.

KQL — Microsoft Sentinel / Defender
// Hunt 1: git config setting executable-naming keys + git spawning shells
let DangerousGitKeys = dynamic(["core.sshcommand", "core.fsmonitor", "core.pager", "core.editor", "gpg.program"]);
let ShellChildren = dynamic(["cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "certutil.exe", "curl.exe", "bash", "sh", "python", "python3", "node"]);
let ConfigPoisoning =
    DeviceProcessEvents
    | where TimeGenerated > ago(14d)
    | where FileName =~ "git.exe" or FileName =~ "git"
    | where ProcessCommandLine has "config"
    | where ProcessCommandLine has_any (DangerousGitKeys)
    | project TimeGenerated, DeviceName, AccountName, ProcessCommandLine, FolderPath, InitiatingProcessFileName, InitiatingProcessCommandLine;
let GitSpawningShells =
    DeviceProcessEvents
    | where TimeGenerated > ago(14d)
    | where InitiatingProcessFileName has "git"
    | where FileName has_any (ShellChildren)
    | project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, SHA256;
union ConfigPoisoning, GitSpawningShells
| summarize FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), Events = count() by DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName
| order by LastSeen desc
;
// Hunt 2: AI coding agent descendants reaching the network or encoding payloads
let AgentParents = dynamic(["claude", "codex", "cursor", "cursor-agent"]);
DeviceProcessEvents
| where TimeGenerated > ago(14d)
| where InitiatingProcessFileName has_any (AgentParents) or InitiatingProcessCommandLine has_any (AgentParents)
| where ProcessCommandLine has_any ("FromBase64String", "DownloadString", "Invoke-WebRequest", "IEX", " -enc", "certutil -decode", "curl http", "wget http")
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine
| order by TimeGenerated desc

Velociraptor VQL

Use this artifact to sweep your developer fleet for .git/config files containing command-bearing directives — the actual tripwire artifact this attack depends on. Run it as a hunt scoped to engineering endpoints.

VQL — Velociraptor
-- Hunt for command-bearing directives in repository .git/config files
-- across user profile directories (Windows developer workstations)
LET configs = SELECT FullPath, Mtime
FROM glob(
  globs='C:/Users/*/**/.git/config',
  accessor='ntfs'
)

SELECT FullPath,
       Mtime AS ConfigLastModified,
       read_file(filename=FullPath, length=65536) AS ConfigContent,
       array(
         "core.sshCommand", "core.fsmonitor", "core.pager",
         "core.editor", "gpg.program", "credential.helper"
       ) AS SearchedKeys
FROM configs
WHERE ConfigContent =~ '(?i)(core\.sshcommand|core\.fsmonitor|core\.pager|core\.editor|gpg\.program|credential\.helper)\s*='

Any hit is not automatically malicious — core.sshCommand is legitimately used for custom SSH ports — but every hit deserves triage: confirm the configured value points at an expected binary, and check the config's modification timestamp against when the repository was cloned.

Remediation / Hardening Script

The following Bash script audits a developer workstation (or runs fleet-wide via your management plane) for poisoned Git configs and optionally strips the dangerous keys. It also verifies Git is at a version that warns on suspicious core.fsmonitor behavior.

Bash / Shell
#!/usr/bin/env bash
# Security Arsenal - Git config poisoning audit & remediation
# Scans all .git/config files under the given root for command-bearing keys.
set -euo pipefail

SCAN_ROOT="${1:-$HOME}"
REPORT="$HOME/git-config-audit-$(date +%Y%m%d-%H%M%S).txt"
DANGEROUS_KEYS="core.sshCommand|core.fsmonitor|core.pager|core.editor|gpg.program|credential.helper|include.path|includeIf"

echo "[+] Scanning $SCAN_ROOT for .git/config files with command-bearing directives..."
echo "Scan root: $SCAN_ROOT | $(date)" > "$REPORT"

find "$SCAN_ROOT" -type f -path "*/.git/config" 2>/dev/null | while read -r cfg; do
  if grep -Eiq "^\s*(${DANGEROUS_KEYS})\s*=" "$cfg"; then
    echo "[!] SUSPICIOUS: $cfg" | tee -a "$REPORT"
    grep -Ein "^\s*(${DANGEROUS_KEYS})\s*=" "$cfg" | tee -a "$REPORT"
    echo "---" >> "$REPORT"
  fi
done

if grep -q "SUSPICIOUS" "$REPORT"; then
  echo "[!] Findings written to $REPORT — review each key's value before removing."
  echo "    To strip a key from a repo:  git -C /path/to/repo config --unset core.fsmonitor"
else
  echo "[OK] No command-bearing Git config directives found under $SCAN_ROOT"
fi

# Baseline hardening: disable fsmonitor hooks globally unless explicitly needed
echo "[+] Applying global hardening..."
git config --global core.fsmonitor false 2>/dev/null || true
git config --global --unset-all core.sshCommand 2>/dev/null || true

echo "[+] Git version check (upgrade to the latest 2.4x/2.5x release):"
git --version

Remediation

1. Inventory and patch the agents. Enumerate every AI coding agent deployed in your engineering org — Claude Code, Codex CLI, Cursor CLI, and the other four named in Manifold's disclosure — and apply the vendor updates that address the four patched flaws. For the four unpatched issues, there is no fix; compensating controls are the only defense until vendors ship updates. Subscribe to Manifold Security's disclosure thread and each vendor's security release channel.

2. Enforce repository provenance. The precondition for this attack is a poisoned repository reaching a developer's disk. Restrict agent usage to repositories cloned from vetted internal remotes or explicitly allowlisted upstreams. Ban git clone of arbitrary third-party repos into agent working directories, and treat tarballs, template repos, and submodules from unvetted sources as hostile input.

3. Strip command-bearing config keys by policy. Deploy the audit script above (or its VQL equivalent) across the fleet on a schedule. Where a directive like core.fsmonitor or core.sshCommand has no documented business need, unset it globally and per-repo.

4. Constrain agent blast radius. Run AI coding agents under a dedicated, non-privileged OS account without access to cloud credential stores, SSH private keys, or signing material. Where supported, force the agent's sandbox/approval mode to its strictest setting and require human approval for any shell-out — recognizing that this bug class bypasses those controls, which is why config hygiene matters more.

5. Rotate on suspicion. If detection fires on a real poisoned config, assume the developer's ambient credentials are compromised: rotate SSH keys, cloud tokens, git credentials, and CI/CD secrets, and hunt for persistence on that endpoint.

6. Update your threat model. Add "agent-mediated command execution via repository content" to your IR playbooks and your next purple-team scope. This will not be the last vulnerability class where the AI agent is the confused deputy.

Related Resources

Security Arsenal Penetration Testing Services AlertMonitor Platform Book a SOC Assessment vulnerability-management Intel Hub

Is your security operations ready?

Get a free SOC assessment or see how AlertMonitor cuts through alert noise with automated triage.