
Breaking Claude Code Opus 5 Auto Mode · Embrace The Red
Embrace The Red (Johann Rehberger) demonstrates an indirect prompt injection attack chain that achieves 60-80% success rates hijacking Claude Code Opus 5 Auto Mode into remote code execution, contrasting with a vendor-run benchmark that reported 0.00% attack success. The chain nudges Claude from WebFetch to curl, delivers a malicious ZIP archive, and exploits Python module shadowing (a poisoned struct.py) when Claude writes its own decoder script, ultimately downloading and executing a payload that establishes C2 and even spawns a nested headless Claude Code instance. Anthropic closed the report as "Informative, working as designed," framing Auto Mode as a best-effort classifier rather than a security boundary, reinforcing that sandboxing and egress control remain necessary mitigations.
What it is
A working indirect prompt injection attack chain by Embrace The Red against Claude Code Opus 5 in Auto Mode (the default starting mode since mid-August), reaching 60–80% attack success on a small sample. The point that carries beyond the summary: this directly contradicts a Trajectory Labs evaluation Anthropic commissioned (72 scenarios ×10 runs, no published benchmark name) that reported 0.00% injection success — and the author's argument that Auto Mode's safety classifier is not a substitute for sandboxing.
How it works
The chain turns on the agent's own safety decision becoming the exploit:
- User asks Claude to summarize a URL. The server returns 415 Unsupported Media Type, which nudges Claude off the WebFetch tool (which self-summarizes) and onto Bash
curl— without ever instructing it to. An HTTP 303 redirectscurlto a ZIP archive. - The ZIP unpacks into a scratch dir containing Base85/zlib/JSON records, a
decoder-darwinbinary, and a file namedstruct.py. - Claude correctly refuses to run the untrusted binary — and instead writes its own Python decoder that
import base64. - Because Python puts the extracted dir on the module search path, and
base64importsstruct, the attacker'sstruct.pyshadows the stdlib module. It re-exports the real_structAPI so decoding succeeds normally, while an obfuscated module-level expression runs on import → code execution.
flowchart TD
A[Summarize URL] --> B[WebFetch]
B -->|server: 415| C[Claude switches to curl]
C --> D[303 -> download ZIP]
D --> E{decoder-darwin binary}
E -->|refuses to run it| F[Claude writes own decoder]
F -->|python3 in extracted dir| G[import base64 -> import struct]
G --> H[attacker struct.py shadows stdlib]
H --> BOOM[code execution]Preconditions / Affected
Claude Code Opus 5 in Auto Mode. The attack requires the agent to fetch attacker-controlled web content and then run a decoder script inside the extracted archive directory (so . is on sys.path). The technique is probabilistic, not deterministic.
What to do
The page's operative recommendation: do not treat Auto Mode's classifier as a substitute for running the agent in an isolated environment with monitoring. The concrete technical lesson for tool authors — never execute scripts with the untrusted extraction directory on the module search path — is implied by the shadowing mechanism.
Caveats
Author-stated limits: "small sample size" underlies the 60–80% figure; the curl redirect step is not always needed (Claude sometimes starts with curl directly); and the binary-refusal step is only "typical" behavior. The 0.00% figure the author disputes is Anthropic's vendor result, not reproduced here. The malicious domain is redacted and IP-allowlisted, so the exact payload is not directly testable from the post.
Organisations named here
- Boris Cherny
- Johann Rehberger
- module shadowing
- veganmosfet
Technologies named here
- WebFetch
- Claude Code
- Claude Opus 5
- Bash tool
- curl
- Python
- Python3 / python3 -I isolated mode
- macOS
- claude -p
- GPT-5.6
- Trajectory Labs
- Codex
- Anthropic
- Opus 5
Techniques named here
- Indirect prompt injection via malicious website content
- Tool redirection / forcing fallback to shell
- HTTP redirect to malicious payload
- Decoy malicious binary to induce self-written insecure code
- Python module shadowing
- Code obfuscation to evade static inspection
- Staged remote payload download and execution
- Isolated child process to avoid recursive self-infection
- C2 callback establishment
- Agent-spawning-agent / subagent escalation
- Auto Mode safety classifier bypass
- Indirect prompt injection
Related in AI Security
