Malicious AGENTS.md Files Hijack AI Coding Agents Via Downloads Folder
Researchers at Forever Security discover that AI coding agents can be hijacked through a malicious AGENTS.md file placed in a user's Downloads folder. The file, containing hidden instructions, tricks an agent into installing a rogue npm package called function-color. The researchers reproduce the attack against OpenAI Codex and demonstrate a related technique against Claude Code that leaks OAuth tokens and allows account takeover.
AGENTS.md files are plain-text markdown documents that provide project-specific instructions to AI coding agents, guiding how they run tests, use tools, and follow coding conventions. Agents automatically load these files from their working directory, meaning malicious instructions can direct them to run commands, install packages, or change settings using the tools and permissions already available to them. The researchers note there is nothing for OpenAI or Anthropic to patch, since an agent following instructions in its folder is doing exactly what it was built to do.
The researchers explain that the Downloads folder is especially dangerous because it is the one location a web page can write to on its own. A malicious website can silently download a file named AGENTS.md into the folder without any user interaction. While the team cannot determine how the original file landed on the customer's machine, they build a proof-of-concept showing how such an attack lands the malicious file undetected, and BleepingComputer verifies the technique.