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.
Read more about Indirect Prompt Injection and Python Module Hijacking Bypass Claude Code Auto Mode