insecure by designRSS
high

Indirect Prompt Injection and Python Module Hijacking Bypass Claude Code Auto Mode

Security researcher Johann Rehberger has demonstrated a technique to bypass security checks in Anthropic's Claude Code coding assistant when running with Auto Mode enabled. Auto Mode operates as a convenience setting designed to execute low-risk local actions without prompting the user for manual confirmation each time. To test the boundary, the researcher created a website mimicking an archive of notebook records and asked Claude Code to generate a summary. During processing, Claude downloaded a zip archive containing encoded data and an included decoder binary. While Claude initially refused to run the bundled decoder, it opted to write and execute a custom Python script to decode the records autonomously. The researcher exploited standard Python module resolution order by placing a malicious file named `struct.py` alongside the target data in the downloads folder. Because Claude executed its custom script directly inside the downloads directory, Python prioritized and imported the rogue `struct.py` over the standard library module. The payload silently maintained execution flow, allowing Claude's generated script to finish without raising alarms, while the malicious code performed unauthorized background actions. In advanced variations, the hijacked process was able to spawn an entirely separate, nested Claude Code agent with independent tool execution privileges. The exploit bypassed automated checks in an estimated 60% to 80% of test iterations, depending on the working directory chosen by the model and environmental factors. Curiously, in instances where Claude detected anomalous behavior post-execution and attempted to kill the rogue process, Auto Mode occasionally blocked the remediation command itself. Anthropic reportedly marked the vulnerability report as informative, stating that Auto Mode is an assistive classifier rather than an ironclad security perimeter.

Commentary

This attack chain highlights a classic systems security failure mode re-emerging within autonomous AI agents: search path hijacking mixed with indirect prompt injection. When an agent is permitted to write and invoke interpreters like Python within untrusted working directories, `sys.path[0]` defaults to the current folder, creating trivial opportunities for DLL/module planting attacks (`struct.py`, `os.py`, `json.py`). Relying on an LLM to dynamically determine whether a generated execution pipeline is 'safe' fails when the operating system's standard execution semantics undermine the runtime. Organizations and developers using Claude Code, particularly on Pro, Max, or Team plans where Auto Mode is enabled by default, should treat the agent as an untrusted execution environment. Running agentic tools with broad local permissions or default internet access exposes machines to direct Command-and-Control (C2) beaconing and local credential theft whenever third-party web content or unverified archives are ingested. To mitigate these risks, teams must enforce strict sandboxing, either via isolated containerized environments (Docker, rootless Podman) or strict OS-level process restrictions, preventing AI tools from running directly on bare-metal host workstations. Additionally, egress network filtering should be strictly enforced to prevent secondary payload staging or reverse shells if an agentic execution path is subverted.

The Quote to Remember

“The payload does not just run code. It creates another agent. The nested Claude gets its own tool access and context.”

← all articles