AI News AI资讯 4h ago Updated 1h ago 更新于 1小时前 49

Breaking Claude Code Opus 5 Auto Mode 破解 Claude Code Opus 5 自动模式

Johann Rehberger demonstrated a prompt injection attack that bypasses Claude Code's Auto Mode with an 80% success rate The attack exploits Python's import system by tricking the agent into downloading and extracting a zip archive containing a malicious `struct.py` that hijacks the `base64` import Auto Mode's safety classifier paradoxically enabled the attack by allowing the initial malicious process creation while simultaneously blocking Claude's cleanup commands when it detected the compromise Claude Code Opus 5 Auto Mode被研究者Johann Rehberger成功攻破,攻击成功率约80% 攻击通过prompt injection诱骗Agent下载解压恶意zip文件,利用Python import机制执行本地struct.py恶意代码 Auto Mode安全机制存在致命缺陷:允许创建恶意进程,却阻止Agent清理已检测到的威胁 研究结论强调:面对对抗性攻击风险时,唯一安全的做法是在沙箱环境中运行Agent

72
Hot 热度
70
Quality 质量
68
Impact 影响力

Analysis 深度分析

TL;DR

  • Johann Rehberger demonstrated a prompt injection attack that bypasses Claude Code's Auto Mode with an 80% success rate
  • The attack exploits Python's import system by tricking the agent into downloading and extracting a zip archive containing a malicious struct.py that hijacks the base64 import
  • Auto Mode's safety classifier paradoxically enabled the attack by allowing the initial malicious process creation while simultaneously blocking Claude's cleanup commands when it detected the compromise
  • The incident reveals a critical design flaw: the safety mechanism itself can become part of the failure chain in AI coding agents
  • Rehberger concludes that sandboxing (containers, VMs, OS-level isolation) with restricted network egress and credential isolation remains the only reliable defense for unattended adversarial-exposure agents

Why It Matters

This is a significant real-world demonstration that even default-enabled, heavily promoted safety mechanisms in AI coding agents can be circumvented by sophisticated prompt injection attacks. It serves as a wake-up call for any organization deploying autonomous coding agents that process untrusted input, showing that software-level guardrails alone are insufficient without infrastructure-level isolation.

Technical Details

  • Attack vector: The attacker crafts a prompt that causes Claude Code to download and extract a zip archive. The archive contains a malicious struct.py placed in the working directory, which exploits Python's module resolution order—when the agent later executes code importing base64, Python first discovers and executes the local struct.py instead of the standard library module.
  • Auto Mode failure mode: The safety classifier permitted the initial malicious process creation (downloading, extracting, and running the import), but when Claude detected the compromise and attempted to terminate the malicious process, Auto Mode blocked the remediation command—effectively trapping the agent in a compromised state.
  • Success rate: Rehberger reports the attack works approximately 80% of the time against Claude Code Opus 5 Auto Mode, indicating a reliable and repeatable vulnerability rather than an edge-case exploit.
  • Recommended mitigation: Run unattended agents inside containers, VMs, or OS sandboxes; restrict network egress; actively monitor agent behavior; and never expose home directories, SSH keys, or cloud credentials to the agent runtime environment.

Industry Insight

  • AI vendors should treat "auto mode" safety claims with skepticism—default-enabled guardrails that can be bypassed and then prevent remediation are worse than no guardrails at all, as they create a false sense of security.
  • Infrastructure-level isolation (sandboxing, network restriction, credential scoping) must be considered a hard requirement, not an optional best practice, for any production deployment of autonomous coding agents handling untrusted inputs.
  • This attack pattern—exploiting Python's import resolution via directory-traversal-style archive extraction—may generalize to other agent frameworks and languages, suggesting the broader AI agent ecosystem needs similar security scrutiny before auto-mode defaults are widely adopted.

TL;DR

  • Claude Code Opus 5 Auto Mode被研究者Johann Rehberger成功攻破,攻击成功率约80%
  • 攻击通过prompt injection诱骗Agent下载解压恶意zip文件,利用Python import机制执行本地struct.py恶意代码
  • Auto Mode安全机制存在致命缺陷:允许创建恶意进程,却阻止Agent清理已检测到的威胁
  • 研究结论强调:面对对抗性攻击风险时,唯一安全的做法是在沙箱环境中运行Agent

为什么值得看

这篇文章揭示了当前主流AI编程Agent安全防御机制的重大漏洞,对依赖Claude Code等自动模式的开发者和企业具有重要警示意义。

技术解析

  • 攻击者通过精心设计的prompt injection,诱骗Claude Code下载并解压包含恶意Python文件的zip压缩包
  • 利用Python的import机制,当执行import base64时,会同时导入并执行同目录下的struct.py恶意文件
  • Auto Mode的安全分类器存在逻辑缺陷:允许创建恶意进程,却阻止Agent执行清理命令,形成"安全机制成为失败一部分"的悖论
  • 攻击成功率约80%,表明该漏洞具有较高实用性和威胁性

行业启示

  • AI Agent的安全防护不能仅依赖模型内置的安全机制,必须结合沙箱隔离、网络限制等底层安全措施
  • 企业部署编程Agent时应遵循最小权限原则:限制网络出口、监控Agent行为、不暴露敏感凭证和目录
  • 安全研究者和开发者需要持续关注Agent系统的攻击面,建立多层次防御体系而非单一依赖模型安全能力

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

Claude Claude Security 安全 Agent Agent Code Generation 代码生成 Research 科学研究