Breaking
AI & MLDeveloping Story

Claude Code Hijack via Website Summary

Researchers show Anthropic's Claude Code can be tricked into running malicious code by summarizing a website.

··2 hours ago·3 min read
A person in silhouette against multiple computer monitors displaying lines of code
Photo by Kevin Horvat on Unsplash

Anthropic's coding agent, Claude Code, running Opus 5 in Auto Mode, can be hijacked to execute attacker-controlled code just by asking it to summarize a website, according to security researcher Johann Rehberger. The attack, which he says works up to 80 percent of the time, exploits the agent's own safety measures to achieve remote code execution.

The Setup: A Malicious Website Summary

Rehberger, also known as wunderwuzzi, detailed the attack in a blog post and video demo. It begins with a simple request: ask the agent to summarize a website that pretends to be an archive of notebook records. The trick is to get Claude to use the Bash tool with curl instead of its WebFetch tool, without ever directly instructing it to do so.

The WebFetch request fails, returning a 415 Unsupported Media Type response, so the model decides to access the website directly by issuing a Bash tool call with curl. This is a key step in the attack chain, as it deviates from the agent's typical tool usage.

From Download to Execution

The website responds with a 303 redirect, pointing Claude to a malicious ZIP archive, which the model downloads. This archive contains seemingly harmless files: catalog metadata, a README file, seven Base85/zlib-encoded JSON notebook records, a macOS decoder-darwin binary, and a poisoned Python file named struct.py.

Claude, adhering to its safety guardrails, refuses to run the decoder, which Rehberger notes is exactly what the attacker wants. Instead of using the supplied binary, the AI decides to write its own decoder. "Ironically, that safety decision is the exploit path," Rehberger wrote, adding a purple devil emoji to the text.

Module Shadowing: The Core Trick

The new decoder imports base64, and from here the attack relies on Python module shadowing to trick the model into running the malicious struct.py code. Module shadowing occurs when a local file shares the same name as a Python standard-library module, causing Python to load the local file instead.

In this case, the standard-library base64 module imports the legitimate struct module, and the malicious ZIP contains a file with the same name. Rehberger says he used ChatGPT to obfuscate the malicious code to bypass Claude's safety controls.

Successful Payload Delivery

The obfuscated code successfully launches a separate Python process to download and execute a remote payload. In the demo, it was a command-and-control callback, which in turn opened Calculator. Rehberger notes that real attackers would likely execute something more nefarious.

In another attack scenario, the malicious struct.py launches a second, headless Claude Code via claude -p. This means the prompt injection can be used not just to remotely execute code, but also to create a whole new agent.

The nested Claude gets its own tool access and context. In these runs the child performed basic recon (whoami, uname, id), opened Calculator and wrote to local files in the home folder.

— Johann Rehberger in his blog post

Success Rates and Anthropic's Response

Across three variants tested five times each, Rehberger reported success rates between 60 percent and 80 percent. He acknowledged these were small samples but said, "I would say that these results are representative for a motivated attack, but not comprehensive."

Anthropic did not respond to The Register's request for comment, but reportedly told Rehberger that the model's "behavior is working as designed." Rehberger paraphrased Anthropic's response: "Auto Mode is a convenience feature backed by a best-effort classifier, not a security guarantee."

Why It Matters: Sandboxing Is Key

According to Rehberger, the classifier isn't built to stop determined prompt-injection chains made up of individually benign-looking steps. The real boundary is OS isolation and network egress control. The key takeaway, he says, is to run this and other coding agents in a sandbox.

"The solution is something we talked about for many years," Rehberger wrote. "Do not trust the model output."

This attack highlights the growing risk of agentic AI systems that have access to tools and the internet. As these models become more autonomous, the potential for such exploits increases. For businesses using coding agents, this is a stark reminder that they must be isolated from sensitive systems and that their outputs should never be trusted without verification.

#prompt-injection#claude-code#ai-security#anthropic#research

Sources

Iliyas

Founder & Editor, Xploitwire

This article was compiled from the sources listed above and checked against them for accuracy, under editorial policies set by Iliyas. Read our Editorial Policy →

← Back to all stories