Researchers at Forever Security, a company that monitors risks from AI agents, discovered the tactic on a customer's computer when a coding agent attempted to install a malicious npm package. The investigation traced the attempt to an AGENTS.md file in the user's ~/Downloads folder, which also served as the agent's working directory.
AI coding agents such as OpenAI Codex and Claude Code automatically load instruction files from their working directory and follow the commands they contain. While AGENTS.md is not an executable, malicious instructions can lead the agent to run commands, install packages, or change settings.
"There is nothing here for OpenAI or Anthropic to patch. An agent that follows the AGENTS.md in its folder is doing exactly what it was built to do," the researchers said.
The researchers created a proof-of-concept showing that simply visiting a malicious web page can silently download an AGENTS.md file into ~/Downloads, as many browsers save files there without prompting. The attack then requires the user to launch the AI agent in that same directory, which Forever's Gal Weizman said is common practice.
In tests, a harmless payload opened the calculator app on OpenAI Codex with a 90% success rate. A separate test against Claude Code used a malicious CLAUDE.md file to redirect API traffic to a server controlled by the researchers, exposing the agent's OAuth token and allowing code execution in roughly 50% of tests.
OpenAI and Anthropic recommend running AI coding agents from the root of the specific project they should work on, keeping the working directory narrow and reviewing unfamiliar instruction files before allowing an agent to follow them. Users should also keep approval prompts and sandbox protections enabled.
