A stranger's AGENTS.md in Downloads hijacked Codex: the malware ran in 90% of attempts
If you launch Codex in the Downloads folder, the agent reads a stranger's AGENTS.md sitting there as project instructions and executes its commands. In Forever Security's lab, the malicious package function-color ran in more than 90% of attempts. The Markdown file runs nothing on its own: the agent executes the commands, and it already has a terminal at hand. So open the agent in a separate, clean folder.
AI-processed from Habr AI; edited by Hamidun News
Picture this: you download an archive of logs, open a terminal right in the Downloads folder, and start Codex there to help you make sense of it. Next to the logs sits a random AGENTS.md file. People usually create these for convenience: you write down once how to run tests in a repository, and you don't repeat it in every session. The agent reads such a note on its own and doesn't ask who wrote it. Researchers at Forever Security showed how this ends: in their Codex experiment, the malicious code ran in more than 90% of attempts. In other words, almost every time the agent received a stranger's instruction, it carried the malicious installation through to the end.
How the agent went after the malicious package on its own
Forever Security's report starts with an October incident at one of the company's clients. An unfamiliar npm package, function-color, appeared in a project. The natural first step in such a situation is to open package-lock.json and find which dependency pulled it in. But the cause turned out to be different: the AI agent itself tried to install the package, following an instruction it read in the file ~/Downloads/AGENTS.md.
Alongside function-color, the dependency function-flag was installed. According to Checkmarx, on Windows its version 1.7.3 could download an executable from a third-party server during installation and run it in a hidden window. What that file actually did could not be determined, because the server no longer responded by the time of analysis. The client's security software managed to stop the installation. How the file ended up in Downloads also remains unknown.
Why does this work? Markdown by itself executes nothing: the hash marks and backticks remain plain text. A person who opens such a file in an editor decides for themselves whether to follow what it says. Codex, however, reads project instructions automatically, has a terminal at its disposal, and executes what is written. That is why the comparison with an .exe applies to the moment the agent runs, not to the file itself.
Why Downloads is a bad place for an agent
According to Forever, about half of the company's clients had someone launch the agent directly from Downloads. Everything ends up in that folder: PDFs from email, archives from tickets, screenshots. And the folder has no history. In Git you can see who added a build command, when, and in which pull request it was discussed. With a file from Downloads, it is nearly impossible to figure out a month later where it came from.
There is a second factor: in roughly a quarter of sessions, the agent opened a browser itself. So even if the folder was clean at the start of the work, that guarantees nothing.
What survives the cleanup
The most unpleasant part: traces remain not only in the file itself. In the Codex experiment, an entry about a new MCP server (the way external tools are connected to the agent) appeared in ~/.codex/config.toml. On the researchers' virtual machine, the installation of function-color ran under the guise of one of these tools. If a developer notices a stranger's AGENTS.md and wipes out Downloads, the next day they open Codex in a different repository, and the agent again reads the settings from the home directory, including this entry.
For Claude Code, the researchers ran a separate experiment that did not involve npm at all. A client's API address was changed, and the next request to the model was accepted by Forever's server. The OAuth token went to that server along with the request.
From there, the researchers could respond to the client on behalf of the model, while the client had tools for executing commands on the developer's machine. In about half of the attempts, Claude Code wrote the new address into the project settings, and code execution in the same session happened in roughly one attempt out of five. The token, however, could have left with the very first request, before any command appeared in the terminal.
What to do in practice
The author of the analysis suggests several simple steps:
- Don't launch the agent from Downloads. For received logs, create a separate directory and open the agent with the default sandbox and confirmation prompts.
- If a colleague sends you a repository, first read its AGENTS.md yourself in an editor.
- After working in Downloads, check ~/.codex/config.toml (the list of MCP servers should match the ones you actually use) and .claude/settings.json (the gateway address should be the expected one).
- If a node_modules/function-color directory is found, save the logs before cleanup and establish whether the code managed to run. If execution is confirmed, isolate the machine and determine which keys were accessible to the process.
To help find traces, the author attached a small Bash script. It searches the home folder and Downloads for AGENTS.md, CLAUDE.md, and .cursorrules, checks the Codex and Claude Code settings, and looks for a function-color directory in the project. The script only shows paths, so a finding does not by itself prove an infection: config.toml will also appear for a person who simply uses a regular corporate MCP server.
The article also covers similar cases. In Aonan Guan's Comment and Control research, the Claude Code Security Review bot published an API key directly in a code comment after an instruction in a pull request title. Gemini CLI Action left a key in an issue discussion, and Copilot Agent left one in a commit. The lesson is the same: check which secrets a review job can see, and grant write access to pull requests only to a separate publishing step.
The story has limits too: what the executable did could not be established, and the figures for Codex and Claude Code come from the researchers' testbed, not from live client machines. But the conclusion stands: the agent trusts the text next to it, and the place where it runs is now part of the threat model.
- Dec 1, 2026vue-chat gets a "Connect Notion" button: the MCP client weighs 9 KB instead of 120 KB
- Dec 1, 2026Open models trail closed ones by 2–5 months but cost a third as much for coding
- Dec 1, 2026MopsStealer Password-Stealing Trojan Hidden in 487 Repositories with Claude Code Skills
- Dec 1, 2026Every $1 of Claude Pro Subscription Yields Up to $99 in API Tokens, ChatGPT Plus Only $16
Key Questions Answered
How the agent went after the malicious package on its own?
Forever Security's report starts with an October incident at one of the company's clients. An unfamiliar npm package, function-color, appeared in a project. The natural first step in such a situation is to open package-lock.json and find which dependency pulled it in. But the cause turned out to be different: the AI agent itself tried to install the package, following an instruction it read in the file ~/Downloads/AGENTS.md. Alongside function-color, the dependency function-flag was installed.
Why Downloads is a bad place for an agent?
According to Forever, about half of the company's clients had someone launch the agent directly from Downloads. Everything ends up in that folder: PDFs from email, archives from tickets, screenshots. And the folder has no history. In Git you can see who added a build command, when, and in which pull request it was discussed. With a file from Downloads, it is nearly impossible to figure out a month later where it came from.
What survives the cleanup?
The most unpleasant part: traces remain not only in the file itself. In the Codex experiment, an entry about a new MCP server (the way external tools are connected to the agent) appeared in ~/.codex/config.toml. On the researchers' virtual machine, the installation of function-color ran under the guise of one of these tools.
Free 2-Day Vibecoding & AI Agents Intensive
Day 1: the autonomous Hermes + DeepSeek AI agent — vibecoding and development on par with Claude Code / Codex / Gemini. Led by Jemal Hamidun, Head of AI at Alpina Digital and academic supervisor at MIPT. Right after you register with our bot Nika: the recording + 11 materials from the previous intensive.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
