a builder's codex
codex · operators · Simon Willison · ins_willison-auto-mode-blocks-self-remediation

Auto mode can block an agent's own cleanup after it detects a compromise

By Simon Willison · Creator of Datasette; co-creator of Django; prolific LLM and agentic-engineering blogger · 2026-08-27 · essay · Breaking Claude Code Opus 5 Auto Mode

Tier A · TL;DR
Auto mode can block an agent's own cleanup after it detects a compromise

Claim

A context-based permission classifier that evaluates each tool call against the user's conversation instruction cannot distinguish between a malicious action the agent was tricked into and a remedial action the agent chose to take. It blocks both. Security researcher Johann Rehberger demonstrated this against Claude Code Opus 5 auto mode at an 80% success rate.

Mechanism

Auto mode grants or blocks tool calls by matching each proposed action against the user's stated intent in the current conversation. The mechanism works well when the threat comes from an attacker trying to hijack the agent's tool calls: the user said "do X," the attacker tries to get the agent to "do Y," the classifier blocks Y.

The mechanism breaks when the agent itself detects a compromise mid-session and tries to respond. The user never instructed the agent to "terminate a malicious process if you find one." The classifier sees an unrecognized high-risk operation and denies it, even when that operation is the correct security response. In Rehberger's exploit, a zip archive extracted a malicious struct.py file that executed on any import base64 call. Claude detected the compromise. Auto mode then blocked Claude's attempt to terminate the malicious process.

This is a "confused environment attack": the exploit does not depend on injecting malicious instructions. It depends on shaping the environment such that ordinary, authorized operations have harmful side effects.

"this is more of a confused environment attack where the nature of the environment that the agent is exposed to results in an exploit"

The safety layer and the safety response are in direct conflict, because the safety layer models threat as external instruction, not as environmental state.

Conditions

Holds when: auto mode is active, the agent has real code execution capability, and an attacker can arrange for extracted or fetched content to shadow standard library modules. The attack path requires convincing the agent to download and extract an archive.

Fails when: the agent operates in a fully sandboxed environment with no filesystem write access and no ability to fetch untrusted archives. Sandboxing the agent runtime makes the initial extraction step impossible.

Evidence

Rehberger demonstrated the attack against Claude Code Opus 5 in a live environment, reporting an 80% success rate. The attack extracts a zip, which places a struct.py file in the working directory. Claude Code then runs code that calls import base64. Python's module resolution finds the local struct.py before the standard library version, executing the attacker's code. In several runs, Claude identified the compromise and attempted to terminate the process. Auto mode blocked the termination command.

Anthropic acknowledged the report and the attack's validity.

Signals

Counter-evidence

Auto mode's design goal is to prevent agents from taking unintended actions, which is a real and well-documented problem. Weakening the classifier to allow self-remediation opens a different attack: an attacker could craft a scenario where the agent "detects a threat" and the remediation itself is the malicious action. The core tension is unresolvable with a purely conversation-context classifier. Sandboxing, not classifier adjustment, is the more defensible direction.

Cross-references

Open the interactive view → View original source → Markdown source →