Malicious Downloads file tricked AI coding agents in 90% of tests
A malicious AGENTS.md file in a customer's Downloads folder tricked AI coding agents into installing a rogue package, succeeding in over 90% of Codex tests, Forever Security reported on 25 October 2026.
Photo: BleepingComputerKey points
A malicious instruction file planted in a Downloads folder tricked AI coding agents into executing code or exposing tokens, succeeding in over 90% of Codex tests.
A malicious instruction file planted in a customer's Downloads folder tricked an AI coding agent into installing a rogue npm package called function-color, Forever Security reported. The researchers reproduced the attack against OpenAI's Codex, which followed the malicious instructions in more than 90% of tests, and demonstrated a related technique against Anthropic's Claude Code that exposed authentication tokens.
The findings matter because AI coding agents automatically load instruction files such as AGENTS.md from their working directory and act on them, without the files containing any executable code. A plain-text file can therefore redirect an agent's behaviour. The Downloads folder is a common working directory: Forever Security researcher Gal Weizman said hundreds of customers run agents there, including more than 1,300 Claude Code sessions.
What the researchers found
Forever Security, a company that monitors risks introduced by AI agents, discovered the tactic on a customer's computer, where a coding agent attempted to install the malicious package function-color. The investigation traced the attempt to an AGENTS.md file in the customer's ~/Downloads folder, which also served as the agent's working directory. The installation was blocked before any malware executed.
The researchers could not determine how the original file reached the customer's machine. They demonstrated that a malicious website could trigger a similar download without a separate approval prompt. Forever Security's report states that ~/Downloads is the one folder the web can write to on its own, and that a web page can download a file named AGENTS.md into it silently.
The attack works because agents treat instructions in their working directory as legitimate and carry them out with their existing permissions. For Codex, the directory must also be trusted. In tests using the file recovered from the customer's machine, Codex modified its machine-wide MCP server configuration and launched another session with approval and sandbox restrictions bypassed.
How the attack works
Because the malicious server was registered in Codex's machine-wide configuration, it could be loaded in subsequent sessions even after the developer moved to another directory. In a separate test, a malicious CLAUDE.md file redirected Claude Code's API traffic to a researcher-controlled server, exposing OAuth tokens and letting the server supply commands that executed code in roughly 50% of tests. The researchers also replayed a captured OAuth token against the legitimate API.
Chrome, Edge and Firefox save web downloads to the Downloads folder by default without prompting for a save location, though they display download notifications. Brave prompted the user to approve the download in tests. After the file lands, the attack requires the target to launch their AI agent in that directory, which Weizman said is common practice for organising folders or acting on new files.
Sakshi Grover, senior research manager at IDC, called the research a credible early warning rather than evidence of widespread exploitation, noting that success rates varied between agents and had not been independently validated. Akshat Tyagi of HFS Research said the tools treat following an instruction and granting a privilege as the same act, and argued vendors must separate the two.
What vendors and analysts say
OpenAI and Anthropic recommend starting an AI coding agent in the root of the specific project it should work on, rather than a home directory or broad parent directory, keeping the working area as narrow as practical. Jonathan Ong of Omdia recommended disabling flags such as --dangerously-bypass-approvals-and-sandbox to limit an agent's authorisation to run high-risk actions.
An Omdia Cybersecurity Decision-Maker survey found that 40% of respondents were only somewhat confident or not confident in their organisations' ability to secure AI agents. Amit Kumar Jena of Kanerika recommended treating instruction files like source code, with designated owners reviewing changes, and said an instruction file must never change what the agent is allowed to do.
Frequently asked questions
How does a Downloads folder file trick an AI coding agent?
Agents automatically load instruction files such as AGENTS.md from their working directory and follow them with their existing permissions. The files contain no executable code; the agent interprets the instructions and carries them out, such as installing a package or changing settings.
How successful was the attack in tests?
Codex followed the malicious instructions in more than 90% of tests, most using a harmless substitute for the malware. A separate technique against Claude Code, redirecting its API traffic, succeeded in approximately half of the tests.
How can users protect against this attack?
Avoid setting the Downloads folder as an agent's working directory, start agents in the specific project root, review unfamiliar AGENTS.md and CLAUDE.md files, keep approval prompts and sandbox protections enabled, and disable flags that bypass approvals and sandboxing.


