AI Security AI安全 21h ago Updated 15h ago 更新于 15小时前 55

Malicious .git Configs Can Make Claude, Codex, Cursor, and Other AI Agents Run Attacker Code 恶意 .git 配置文件可使 Claude、Codex、Cursor 等 AI 代理运行攻击者代码

Manifold Security disclosed eight vulnerabilities across seven AI coding agents (Claude Code, Codex, Cursor, goose, Hermes Agent, Qwen Code, Grok Build) where malicious .git configurations can execute attacker-controlled commands on a developer's machine The attack exploits Git's `core.fsmonitor` setting, which runs a user-specified command to detect file changes; AI agents invoke Git operations in the background without sanitizing repository-supplied configs Exploitation requires the repository Manifold Security披露了七个命令行AI编码代理(Claude Code、Codex、Cursor、goose、Hermes Agent、Qwen Code、Grok Build)中的八个安全漏洞,攻击者可通过恶意.git配置文件在开发者机器上执行任意代码 漏洞利用无需用户交互、无需模型调用、无需工具审批,恶意代码在AI代理的沙箱外以用户权限执行,可在信任提示出现前触发 漏洞根源在于Git的core.fsmonitor配置项,AI代理启动时会执行该配置指定的命令来检测文件变更和分支信息 截至9月1日重新测试,goose、Claude Code和Cursor已修复,但Hermes

82
Hot 热度
72
Quality 质量
78
Impact 影响力

Analysis 深度分析

TL;DR

  • Manifold Security disclosed eight vulnerabilities across seven AI coding agents (Claude Code, Codex, Cursor, goose, Hermes Agent, Qwen Code, Grok Build) where malicious .git configurations can execute attacker-controlled commands on a developer's machine
  • The attack exploits Git's core.fsmonitor setting, which runs a user-specified command to detect file changes; AI agents invoke Git operations in the background without sanitizing repository-supplied configs
  • Exploitation requires the repository to arrive with its .git directory intact (via archive, USB, shared drive), bypassing normal git clone protections, and executes before trust prompts, authentication, or model calls
  • Four of seven agents remained unpatched at publication (Hermes Agent, Qwen Code, Grok Build, and a second Claude Code path via claude ultrareview), with some vendors ignoring or closing reports as duplicates
  • The vulnerability is rated CVSS 7.0 and represents a systemic class issue affecting the "ordinary plumbing" of AI agent startup sequences, with prior analogous flaws in VS Code and JetBrains IDEs

Why It Matters

This vulnerability exposes a critical trust boundary failure in AI coding agents: malicious code can execute with full user privileges before any security prompt, authentication, or model interaction occurs, making it a pre-authentication, pre-trust attack vector. For AI practitioners and security teams, it underscores that agent security depends not just on model-level safeguards but on the entire subprocess and configuration pipeline, and that supply-chain-style attacks via seemingly benign repositories are a realistic threat.

Technical Details

  • Attack vector: Git's core.fsmonitor configuration key allows a repository to specify a command that Git executes to identify changed files; AI agents call Git operations (e.g., git status, git diff) during session startup to determine branches and modified files, inadvertently executing attacker-controlled commands from .git/config
  • Execution context: The malicious command runs as the legitimate user, outside the agent's sandbox, without any approval prompt, workspace-trust dialog, or model call—on some agents it fires before authentication (Qwen Code) or even the first keystroke (Grok Build)
  • Delivery mechanism: Exploitation requires the repository to be delivered with its .git directory preserved (shared archive, USB stick, sync folder, or network drive), since a standard git clone strips the .git directory and prevents the attack
  • Affected agents and patch status: goose (fixed in 1.44.0), Codex CLI/Desktop (fixed in 0.131.0 / 26.519.x), Claude Code (partially fixed—core.fsmonitor path patched in 2.1.196 but claude ultrareview path still live on 2.1.258); Hermes Agent, Qwen Code, and Grok Build remain unpatched as of September 2026
  • Historical context: Sonar identified the same vulnerability class in April; Anthropic previously mitigated a related issue in Claude Code v2.0.34 (November 2025) only for the regression to reappear in v2.1.193 (June 2026); analogous trust-dialog bypasses were found in VS Code before 1.63.1 and JetBrains IDEs before 2021.3.1

Industry Insight

  • AI agent vendors must treat repository-supplied configuration as untrusted input and implement strict allowlisting or sanitization of all Git configuration keys during agent startup, rather than relying on sandboxing or post-hoc approval prompts that can be bypassed
  • The repeated recurrence of this vulnerability class across multiple vendors and over time suggests a systemic gap in secure-by-design principles for AI coding tools; industry-wide standards or shared security baselines for agent startup sequences could prevent regression
  • Security teams and developers should audit their AI agent environments for exposure to untrusted repositories, treat shared drives and archived code as potential attack vectors, and prioritize patching for agents still running unpatched versions—especially Hermes Agent, Qwen Code, and Grok Build, where vendor responsiveness has been poor or absent

TL;DR

  • Manifold Security披露了七个命令行AI编码代理(Claude Code、Codex、Cursor、goose、Hermes Agent、Qwen Code、Grok Build)中的八个安全漏洞,攻击者可通过恶意.git配置文件在开发者机器上执行任意代码
  • 漏洞利用无需用户交互、无需模型调用、无需工具审批,恶意代码在AI代理的沙箱外以用户权限执行,可在信任提示出现前触发
  • 漏洞根源在于Git的core.fsmonitor配置项,AI代理启动时会执行该配置指定的命令来检测文件变更和分支信息
  • 截至9月1日重新测试,goose、Claude Code和Cursor已修复,但Hermes Agent、Qwen Code、Grok Build及Claude Code的第二个路径仍存在漏洞
  • OpenAI同日发布三个CVE覆盖Codex相同类型漏洞,GitHub分配CVE-2026-72718,CVSS基础评分7.0

为什么值得看

这篇文章揭示了AI编码代理领域一个系统性安全缺陷,影响多个主流产品,且部分漏洞至今未修复。对AI从业者和企业用户而言,这提醒了AI代理在集成底层工具链时的安全风险,需要立即评估和更新。

技术解析

  • 漏洞机制:Git的core.fsmonitor配置项允许仓库指定一个命令,Git在执行git statusgit diff等操作时会调用该命令。AI代理在启动时调用这些Git命令来检测文件变更和分支信息,从而执行了仓库配置中的恶意命令。
  • 利用条件:攻击者需要以文件形式提供包含完整.git目录的仓库(通过共享归档、网络驱动器、同步文件夹或USB存储),普通克隆操作不会保留.git目录。
  • 执行时机:恶意代码在用户信任提示之前执行(Claude Code和Hermes Agent在workspace-trust提示前,Qwen Code在认证前,Grok Build在第一次按键时),完全绕过安全审批机制。
  • 影响范围:涉及goose(<1.44.0)、Codex CLI(0.102.0-0.130.0)、Codex Desktop(macOS和Windows多个版本)、Claude Code(2.1.193确认,2.1.196修复部分路径)、Hermes Agent(0.18.2和0.21.0)、Qwen Code(0.19.6和0.22.3)、Grok Build(0.2.93和1.0.13)。
  • 历史背景:Sonar在4月已报告相同漏洞类型,Anthropic曾在2.0.34版本(2025年11月)修复过类似问题,但2.1.193版本(2026年6月)再次出现相同启动行为。

行业启示

  • AI代理安全设计需重构:当前AI编码代理在启动时执行用户仓库配置命令的模式存在根本性安全缺陷,厂商需要重新设计初始化流程,确保所有命令执行都在沙箱内且经过用户明确审批。
  • 供应链攻击风险升级:攻击者可通过分发恶意代码库(如通过npm包、GitHub仓库、共享存储)实现无交互代码执行,企业需建立代码库来源验证机制,对第三方仓库进行安全扫描。
  • 漏洞响应透明度不足:部分厂商(如Nous Research的Hermes Agent)对安全报告响应迟缓,多个漏洞至今未修复且未发布官方安全公告,行业需要建立更严格的安全披露和响应标准。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Security 安全 Agent Agent Code Generation 代码生成 Claude Claude LLM 大模型