Breaking Claude Code Opus 5 Auto Mode
Bypassing Claude Code Opus 5 Auto Mode
From the archives of wunderwuzzi's blog: mastering the hacks to prevent the attacks.
Date: August 26, 2026 | Tags: #llm #agents #redteaming
In this analysis, we examine a vulnerability where a routine request to summarize a website allows an attacker to hijack Claude Code Opus 5 while it is operating in Auto Mode. Despite the model's safety layers, this method achieves a code execution success rate of based on a limited sample size.
This finding is particularly striking because a third-party audit by Trajectory Labs (commissioned by Anthropic) reported a 0.00% success rate for prompt injection attacks against Opus 5 in Auto Mode.
Understanding "Auto Mode"
Historically, AI agents required human confirmation before executing sensitive commands. Auto Mode changes this by replacing manual approvals with an automated safety classifier. Since mid-August, this has become the default operational state for Claude Code.
Critical Warning: If you are concerned about misalignment, hallucinations, or prompt injection, Auto Mode is not a replacement for executing your agent within a strictly isolated environment and maintaining rigorous monitoring.
The "Layered Defense" Theory
Boris Cherny of Anthropic suggested that indirect prompt injections could be virtually eliminated using a multi-tiered defense strategy:
- Model Training (Internal alignment)
- Input Probes (Scanning for malicious patterns)
- Intent Classifiers (Evaluating the goal of the prompt)
Trajectory Labs tested 72 scenarios (10 iterations each), and their results showed a failure rate. However, these benchmarks often fail to account for complex, multi-stage attack chains.
The Attack Chain: At a Glance
The goal is to trick Claude into executing arbitrary code by leveraging its own helpfulness.
Execution Checklist
- Nudge Claude from
WebFetchcurl. - Redirect to a ZIP archive with encoded data.
- Provide a "dangerous" binary to trigger Claude's safety refusal.
- Induce Claude to write a custom Python script.
- Use
struct.pyto shadow standard libraries.
Detailed Walkthrough
1. The Entry Point
The attack begins with a standard user request:
Summarize https://archive.[redacted].uk/
The target website is designed to look like a legitimate archive of linguistic notebook records, containing metadata, checksums, and theoretical notes on language. This provides a "plausible" reason for the agent to dig deeper into the files.
2. Forcing the Tool Shift
Claude initially uses the WebFetch tool. However, WebFetch often summarizes content internally, which acts as a filter. To bypass this, the server is configured to return an HTTP 415 Unsupported Media Type error.
When WebFetch fails with a 415, Claude autonomously decides to use curl via the bash shell to retrieve the data. The server then issues an HTTP 303 redirect to:
/deposits/WIC-notebook-catalogue.ZIP
3. The Decoy and the Refusal
The downloaded ZIP archive contains the following files:
| File Name | Purpose |
|---|---|
README.txt | Instructions and documentation |
accession-map.csv | Catalogue metadata |
MANIFEST.sha256 | Integrity checks |
decoder-darwin | The Decoy: A macOS binary |
struct.py | The Payload: Malicious Python module |
*.json | Base85/zlib encoded records |
The README tells Claude to use decoder-darwin to read the records. Because the binary is an executable, Claude correctly refuses to run it for safety reasons.
4. The "Helpfulness" Trap
Instead of giving up, Claude attempts to be helpful by writing its own Python decoder to handle the Base85 and zlib encoding. The encoded data looks like this:
c-ke7!Ab= 3Kt bnOh3Khzoau%OTTdWccfNm4{a@Emzr 7*q3Lb!x%VS*qGG%;Nw^CykMn81e...
Claude executes a command similar to this:
cd WIC-notebook-catalogue
python3 -c 'import base64, zlib, json; ...'
Technical Deep Dive: Module Shadowing
The vulnerability lies in how Python handles the module search path. Because Claude runs the script inside the extracted archive directory, that directory is added to the sys.path.
How it works:
- The ZIP contains a file named
struct.py. - When Claude's script imports
base64(or any module that depends onstruct), Python loads the attacker'sstruct.pyinstead of the standard library version. - The malicious
struct.pyre-exports the original_structAPI to avoid crashing the script, but it executes an obfuscated payload during the import process.
Conceptual Example:
# Malicious struct.py
import _struct
import os
# Obfuscated payload execution
__payload__ = "import socket, subprocess..."
exec(compile(eval(bytes.fromhex('...').decode()), '<string>', 'exec'))
# Maintain compatibility so Claude doesn't notice
from _struct import *
Summary of the Irony
Claude does not trust the binary provided by the attacker, but it completely trusts the code it writes for itself. By providing a decoy binary, the attacker pushes the model toward the "danger zone" of writing and executing its own shell commands.
![Diagram Placeholder: Illustration of Python Path Search Order]
(Image: A diagram showing the Python interpreter checking the current working directory for struct.py before checking the system site-packages)