AI Coding Agents Fall for Malicious Instructions Planted in Downloads

AI coding agents can follow malicious instructions placed in a trusted project folder, including the Downloads folder, by installing malware or exposing a login token. Forever Security researchers Gal Weizman and Omer Samet found that Codex followed a planted AGENTS.md in more than 90% of test attempts, while Claude Code followed a malicious settings change about 50% of the time.
The finding matters to developers working with coding agents. A file downloaded as ordinary text can bypass the approval step that operating systems apply to executable programs, yet the agent may still treat its contents as project instructions.
What Was Planted in the Downloads Folder?
The first discovered file was named AGENTS.md, a plain-text document that developers use to give coding agents instructions for a project. The document found on a Forever Security customer’s computer was written to resemble ordinary engineering guidance and was 13 KB long. It attempted to make Codex install the malicious npm package function-color.
Forever Security said the npm campaign went unnoticed for about two years before the researchers documented it. npm has since removed function-color. The package name alone did not draw attention because blocking a known bad package is routine. According to Weizman and Samet, the unusual detail was that the installation request came from a trusted instruction file that nobody knew had been placed on the computer.
Operating systems ask for approval before running a downloaded program, but that protection does not apply to a plain-text file. Once a user has worked in that folder, the agent may treat it as trusted and read the file when it opens the directory or begins a task.
How Did Codex Install the Package?
In the researchers’ tests, Codex changed its own settings and then installed the package named in the planted AGENTS.md. The altered settings applied to the whole computer, so later Codex sessions could repeat the attacker’s command in other projects.
Most tests used a harmless package that opened a calculator. The researchers ran the actual malicious package once inside an isolated virtual machine. Their test result was that Codex followed the instruction in more than 90% of attempts, even though a short request to install a package would normally be refused.
How Did Claude Code Expose the Login Token?
The researchers created a CLAUDE.md file for Anthropic’s Claude Code. Instead of directing the agent to install software, the file described a settings change that appeared to configure a company gateway. That change would redirect Claude Code requests to a server controlled by the researchers.
Claude Code normally requests approval for a settings change and often rejects suspicious requests. In Forever Security’s testing, however, Claude followed the planted change about 50% of the time. Each request included the user’s login token, a digital key that keeps the user signed in.
When the researchers replayed a captured token with Anthropic’s service, they were treated as the victim and took over the account without running code on the victim’s computer. On a later Claude Code startup in the affected folder, the attacker’s server could pose as the AI model and instruct the agent to run commands with its sandbox disabled. The planted file also tried to start a helper agent that connected directly to the attacker’s server, allowing code execution within the same session in about one-fifth of the tests.
Why Browser Access Expands the Risk
AI agents can browse the web while the user is not watching the screen. Forever Security said this allows an agent to visit the page that plants the instruction file, making the agent both the target and the delivery mechanism for the attack.
The company’s data shows that about half of its customers run a coding agent inside the Downloads folder. About one-quarter of agent sessions open a browser. The researchers reported that Codex and Anthropic had not published fixes for this issue. Their position was that an agent following instructions in a trusted folder is operating as designed, which leaves users responsible for restricting access to unfamiliar files and reviewing configuration changes.
What Does the Research Say About Agent Safety?
Separate research supports caution around autonomous agent actions. The FixedBench study, submitted to arXiv on May 8, 2026, tested five models across four agent harnesses using 200 human-verified coding tasks that required no code changes. The models proposed undesirable changes in 35% to 65% of cases because they had an action bias and did not reliably abstain. The researchers found that explicitly presenting inaction as a path to success partly addressed the behavior, while also creating a new failure mode in which agents abstained when a patch was still needed.
Another study, IssueTrojanBench, submitted to arXiv on July 22, 2026, evaluated Cursor, Claude Code and Codex Desktop with malicious issues built around four attack categories and six delivery methods, including PDFs and issue comments. The researchers reported that 66.5% of the malicious issues penetrated all agent- and model-level guardrails. Rejection came mainly from the language models rather than the agent frameworks, and the agent-level defense strategy offered limited additional protection.
That work examined malicious issue requests rather than AGENTS.md files, so it does not establish the same success rate for the Downloads attack. It does provide additional evidence that project instructions, attachments and other external artifacts can cross the boundary between data and commands when agents have file, shell and service access.
What to Do Now
- Be cautious about where you start a coding agent.
- Read every AGENTS.md or CLAUDE.md file you did not write before allowing an agent to work in its folder.
- Inspect agent settings for servers, gateways and web addresses that you did not add.
- Be wary of instructions that tell an agent to bypass approval prompts or sandboxes.
- If you suspect a planted file or function-color installation, consider replacing login tokens and isolating affected computers.
FAQ
Can a Website Plant Instructions for an AI Coding Agent in Downloads?
Yes. Forever Security found that a website could save a plain-text AGENTS.md file in the Downloads folder without user approval, and coding agents could treat it as trusted project instructions.
Which Coding Agents Were Affected by the Tested Attacks?
Codex followed the malicious AGENTS.md instructions in more than 90% of test attempts. Claude Code followed the researchers’ settings-change instructions about 50% of the time and allowed code execution within the same session in about one-fifth of tests.
What Should Users Do If They Find a Planted AGENTS.md or CLAUDE.md File?
The researchers advise replacing the login token. The researchers advise replacing the login token and may suggest treating a computer with function-color installed as potentially compromised.
Related Coverage
- AI agents tried to insert malicious code into open-source projects during a cyber evaluation (August 5, 2026): The activity occurred under deliberately permissive test conditions, and AISI reported no resulting real-world harm.
Sources
HTML