Security

Claude Code: Researcher bypasses auto mode with malicious code

3 min read

TL;DR Too Long; Didn’t read

The security researcher Johann Rehberger has published an attack chain that bypasses Claude Code's auto mode in up to 80 percent of test runs. A tampered ZIP file causes the software to load its own malicious code instead of a standard module unnoticed. Anthropic classifies the finding as informative and refers to sandboxing as the actual layer of protection.

A wooden Trojan horse shaped like a ZIP file silhouette sneaks past a red padlock springing open, next to a terminal window bearing the Anthropic Claude logo as a sticker. Image generated with GPT Image 2

Key takeaways

  • A tampered ZIP file uses Python module shadowing to load its own code instead of the standard library base64.
  • In tests, the complete attack chain with remote access succeeded in three out of five attempts, one variant in four out of five attempts.
  • The auto mode allowed the creation of the malware but blocked Claude's own command to terminate the process.
  • Anthropic assessed the report through its own bug bounty program as informative, not as a security vulnerability.
  • The researcher advises using containers, virtual machines, or operating system sandboxes instead of solely relying on the classifier.
  • Simon Willison independently confirms that an auto mode release alone does not provide a security proof.

The security researcher Johann Rehberger demonstrates in an analysis published on August 26 how the automatic release mode of Claude Code can be bypassed with a prepared archive file. In test runs, the complete attack chain with remote access was successful in three out of five cases, a simpler variant in four out of five cases. Anthropic assesses the finding as informative, not as a security vulnerability.

Prepared ZIP file smuggles in malicious code

The attack begins with a manipulated website: If the server responds with the HTTP status code 415, Claude Code switches from the built-in WebFetch tool to the command line and downloads the file instead via curl. This very switch opens, according to Rehberger, the crucial gap because the software then works with a downloaded ZIP file in the file system.

The archive contains, in addition to seemingly harmless catalog data, a macOS decoder, encrypted JSON records, and a prepared file named struct.py. Claude Code correctly refuses to execute the supplied decoder but instead writes its own Python script for decryption. This seemingly safe decision becomes a trap: If the script imports the standard module base64 from the unpacked directory, Python loads the identically named prepared file from the archive instead of the real system library due to so-called module shadowing.

The hidden code starts an isolated subprocess, loads another program stage, establishes a connection to a control server, and visibly opens the calculator as proof of execution. According to Rehberger, the malicious process continues to run even after the Claude Code session has long been terminated.

Protection mechanism blocks its own emergency stop

In test series with small sample sizes, the complete attack chain including control server connection was successful in three out of five attempts, a reduced variant with file accesses outside the working directory in four out of five cases. Rehberger himself points out that the numbers come from small sample sizes and do not represent an independently verified success rate. Simon Willison independently confirmed the finding and emphasizes that an auto mode release alone is not a security proof for executed code.

A notable detail from the tests is that Claude recognized the compromise in one case, but the auto mode refused the command to terminate the malicious process – while it had previously allowed the creation of the malware. The auto mode has replaced the manual release of individual commands for Pro, Max, and Team accounts since August 14 with a classifier that is supposed to autonomously stop risky actions. The change was primarily intended to compensate for human negligence: According to an in-house study, test subjects overlooked nine out of ten risky commands during manual review, which the automatic classifier reliably stopped.

Anthropic refers to sandboxing as the actual protection

Rehberger reported the finding through the company’s bug bounty program. Anthropic classified the report as informative, not as a security vulnerability, and stated according to company information that the auto mode is “a convenience feature based on a classifier to the best of its ability, not a security guarantee.” The actual layer of protection is operating system isolation and restrictions on network access, not the classifier itself.

The finding stands in contrast to Anthropic’s own metric: The company had advertised an auto mode independent test with 72 withheld attack scenarios and a total of 720 attempts, in which not a single attack was successful. This fixed test series does not cover the technique used by Rehberger – a result of zero percent on a limited scenario catalog does not exclude new, creative attack paths such as module shadowing.

The researcher advises developers to run coding agents in containers, virtual machines, or operating system sandboxes, restrict network access, and keep sensitive data such as SSH keys away from the working environment.

It remains open whether Anthropic will retrain the classifier with this specific technique or will mandate sandboxing in the future. For teams that are already using coding agents productively, the finding shifts the responsibility from the software back to their own system architecture – those who do not operate a sandbox rely solely on a classifier that the manufacturer explicitly does not describe as a security guarantee.

Frequently asked questions

Does the vulnerability affect all Claude Code users?

Only sessions with the auto mode activated are affected, which has been standard for Pro, Max, and Team accounts since August 14. Those using manual release still confirm each command themselves.

What should developers do now specifically?

Rehberger recommends running coding agents in containers, virtual machines, or operating system sandboxes, restricting network access, and keeping credentials and SSH keys away from the working environment.

Has Anthropic already fixed the vulnerability?

According to the researcher, Anthropic classified the report as informative without announcing a correction of the classifier. The company instead refers to sandboxing as an additional layer of protection to be implemented by the user.

How does the finding fit with the advertised result of zero percent success rate?

That result comes from a fixed test with 72 attack scenarios and 720 runs. Rehberger's technique with the tampered Python module was not part of this scenario catalog and was therefore not recorded.

Is Claude Code regularly usable in Germany and the EU?

Yes, the CLI application is available through Pro, Max, and Team subscriptions in Germany and the EU. No regional restrictions for the auto mode are known.

Sources (3)
  1. Breaking Claude Code Opus 5 Auto Mode with Indirect Prompt Injection – Embrace The Red (Johann Rehberger)
  2. Breaking Claude Code Opus 5 auto mode – Simon Willison
  3. How we built Claude Code auto mode – Anthropic

Your AI update for the work week

Once a week, the most important AI news – plus one practical tip to try right away. No spam, unsubscribe anytime.

← Back to the blog