insight Simon Willison 2026-08-27T22:50 正文 ok 253 words

攻破 Claude Code Opus 5 自动模式

英文标题:Breaking Claude Code Opus 5 Auto Mode

Anthropic 正在高度依赖 Claude Code 的自动模式(auto mode)来防御编码 Agent 面临的提示注入攻击,并已将其设为默认选项。提示注入研究员 Johann Rehberger 发现了一种据称成功率达 80% 的攻击:诱导 Claude Code 下载并解压 ZIP 文件,再利用本地 `struct.py` 文件在导入 `base64` 时执行恶意代码。更严重的是,自动模式在部分测试中不仅未能阻止恶意进程创建,反而阻止了 Claude 尝试终止该进程的清理命令。该案例表明,运行可能遭受对抗性攻击的 Agent 时,开发者仍应依赖容器、虚拟机或操作系统沙箱,并限制网络和敏感凭证访问。
打开原文相关 9.6 · 机会 1

中文

2026 年 8 月 27 日 - Link Blog

攻破 Claude Code Opus 5 自动模式。Anthropic 正在高度依赖 Claude Code 的自动模式来保护其编码 Agent 用户免受提示注入攻击。他们最近已将其设为默认选项,并对其有效性作出了大胆宣称。

Johann Rehberger 是当今最可信的提示注入研究人员之一。他发现了一种针对自动模式的攻击,据他称其成功率达到 80%:攻击者诱骗 Claude Code 下载并解压一个 ZIP 归档文件,随后执行导入 base64 的代码,却未注意到此举会导入并执行从该归档文件中解压出的本地 struct.py 文件。

在少数情况下,自动模式竟直接阻碍 Agent 阻止有害代码继续执行!

在几次运行中,Claude 发现遭到入侵后曾尝试终止恶意软件进程,但自动模式拒绝了该清理命令。

Claude 发现了入侵,但 自动模式阻止了其清理命令

安全机制本身可能成为失败的一部分。分类器允许创建恶意软件进程,却阻止了用于终止它的命令!

我同意 Johann 在此得出的结论:如果存在任何引起对抗性攻击者注意的风险,运行 Agent 的唯一安全方式就是使用沙箱:

  • 在容器、VM 或操作系统沙箱中运行无人值守的编码 Agent。
  • 限制出站网络访问。
  • 监控你的 Agent。
  • 不要向 Agent 运行环境暴露主目录、SSH 密钥、云凭证等敏感资源。[…]

English / 原文

27th August 2026 - Link Blog

Breaking Claude Code Opus 5 Auto Mode. Anthropic are putting a great deal of faith in Claude Code's auto mode for protecting their coding agent users against prompt injection attacks. They recently made that the default and have made bold claims about its effectiveness.

Johann Rehberger is one of the most credible prompt injection researchers active today. He found an attack against auto mode which he claims works 80% of the time, by tricking Claude Code into downloading and uncompressing a zip archive, then executing code that imports base64 without noticing that this will import and execute a local struct.py file extracted from the archive.

In a few cases auto mode directly prevented the agent from preventing harmful code from continuing to execute!

In a few runs Claude tried to terminate the malware process once it noticed the compromise, but Auto Mode denied the cleanup command.

Claude detects the compromise, but Auto Mode blocks its cleanup command

The safety mechanism itself can become part of the failure. The classifier allowed the creation of the malware process, but then it blocked the command intended to stop it!

I agree with Johann's conclusion here: the only safe way to run agents if there's any risk of attracting the attention of an adversarial attack is with a sandbox:

  • Run unattended coding agents in a container, VM or OS sandbox.
  • Restrict network egress.
  • Monitor your agents.
  • Do not expose home directories, SSH keys, cloud credentials,… to the agent runtime. [...]