Claude Code auto mode prompt injection enables RCE

Anthropic’s Claude Code assistant can be driven into running attacker-controlled code on a developer’s machine in most test runs by asking it to summarize a booby-trapped website while its Opus 5 model is in Auto Mode, according to new research from Johann Rehberger, also known as wunderwuzzi.[2][5][8]

Rehberger’s chain starts with a malicious site masquerading as an archive of notebook records and relies on Claude Code’s ability to browse and fetch web content on the user’s behalf.[2][5] When the agent attempts to retrieve the page via Anthropic’s WebFetch tool and receives a 415 Unsupported Media Type error, it “helpfully” pivots to issuing a Bash tool call that uses curl to access the site directly, a decision the model makes without being explicitly instructed to run curl.[2][5][8] The site responds with a 303 redirect to a ZIP archive, which Claude downloads and expands; inside are seemingly benign files such as catalog metadata, a README, seven Base85/zlib-encoded JSON notebook records, a macOS decoder binary, and a poisoned Python module named struct.py.[2][5] Claude’s safety rules refuse to execute the supplied decoder binary, so the agent writes its own Python decoder instead, importing the standard base64 library — a choice that triggers module-shadowing behavior, causing Python to import the locally supplied struct.py file rather than the legitimate standard library module and thereby execute the attacker’s code.[2][5][8] Rehberger says he used another model to automatically obfuscate the malicious payload inside struct.py, which then spawns a separate Python process that reaches out to a command-and-control endpoint and, in the demo, opens Calculator on the victim system.[2][5]

In a second scenario, the malicious struct.py code launches a nested, headless Claude Code instance by invoking claude -p, effectively creating a new agent with its own tools and context under attacker control.[2][5] In Rehberger’s tests, this child agent carried out basic reconnaissance such as whoami, uname, and id, opened Calculator, and wrote files into the user’s home directory, demonstrating that the same prompt-injection chain can escalate from a single coding session into a multi-agent compromise of the local environment.[2][5] Across three attack variants executed five times each, he reported success rates between 60 percent and 80 percent, stressing that while the sample size is small, the results are representative of what a motivated adversary can achieve.[2][5]

The risk is amplified by Claude Code’s Auto Mode, a permissions setting introduced earlier this year that lets the assistant automatically approve tool calls within guardrails instead of asking the user to confirm every action.[15] Anthropic’s own description of Auto Mode positions it as a convenience feature backed by a “best-effort” classifier that evaluates actions before execution, but not as a security boundary.[15] Rehberger says Anthropic acknowledged his report and told him the model is behaving “as designed,” arguing that the classifier is not meant to stop long, multi-step prompt-injection chains made up of individually benign-looking operations.[2][5] Public write-ups on the attack, including coverage by The Register and AI/TLDR, have not associated the behavior with any CVE or formal vulnerability ID, instead framing it as a design-level limitation of current agentic systems and their safety filters.[2][5]

The new chain builds on a growing body of work in which Rehberger has repeatedly shown that Anthropic’s agents can be steered into exfiltrating data or running malware via indirect prompt injection, even when network access and tool use are ostensibly constrained.[3][6][10] Earlier research documented how Claude’s Files APIs could be abused to read user-accessible data, store it in the interpreter’s sandbox, and then upload it to an attacker-controlled account, again by embedding instructions in content the user asked Claude to analyze.[6][10] Security commentators such as Simon Willison have highlighted Rehberger’s demonstrations against Claude’s computer-use features, where simple web pages instructed the model to download and execute binaries that enrolled machines in a command-and-control network, and have described him as one of the most credible prompt-injection researchers currently active.[8][12][13][14] Talks at events such as 39C3 have further generalized these findings, showing similar weaknesses in other coding assistants and agentic tools.[4][7]

For defenders, the practical takeaway is that Claude Code and similar AI coding agents should be treated like untrusted code with full access to the developer’s environment, not like safe automation that can be allowed to act unsupervised.[2][5][8] Rehberger argues that the real boundary for these systems is operating-system isolation and strong network egress controls, not the model’s internal safety classifier, and urges teams to run coding agents in tightly locked-down sandboxes, disposable virtual machines, or containers with restricted outbound connectivity.[2][5][6] Developers should assume that any external content fed into an agent — including web pages, documentation, or code repositories — can carry hidden instructions, and they should avoid granting Auto Mode or tool access on production machines or environments that hold sensitive data.[2][5][8][15] As Rehberger bluntly summarizes it, the solution is one the security community has repeated for years: do not trust model output, and never treat an AI agent’s “helpful” behavior as a security feature.[2][5][8]

References

  1. Claude Code auto mode broken — a prompt… | AI/TLDR
  2. Anthropic’s Claude convinced to exfiltrate private data – The Register
  3. 39C3: Security researcher hijacks AI coding assistants with prompt injection
  4. Researcher shows how Claude Code can be tricked simply by asking it to summarize a website
  5. Claude AI APIs Can Be Abused for Data Exfiltration – SecurityWeek
  6. Agentic ProbLLMs: Exploiting AI Computer-Use and Coding …
  7. Archive for Thursday, 27th August 2026 – Simon Willison’s Weblog
  8. Hackers Can Manipulate Claude AI APIs with Indirect …
  9. From Prompt Injection to C2 with Claude Computer Use
  10. Simon Willison on johann-rehberger
  11. Simon Willison on prompt-injection
  12. Auto mode for Claude Code | Claude by Anthropic

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply