A security firm has found that placing a disguised instruction file inside a user's Downloads folder is enough to manipulate AI coding agents into installing malware, with one leading tool executing a known-malicious package in more than nine out of ten test runs.
The finding comes from Forever Security, which said one of its customers had an `AGENTS.md` file sitting in their Downloads folder. The file was designed to look like routine engineering notes, but its actual purpose was to instruct any coding agent that opened the folder to install `function-color`, a package tied to the MALFEX npm supply chain campaign. Forever stopped the agent before the installation completed. The firm could not determine how the file got there.
How the Malware Chain Works
`function-color` is a wrapper package. It carries no payload of its own but silently installs `function-flag` as a dependency. That package runs a postinstall script that downloads a Windows executable from a remote host, saves it as `node.exe` inside `%APPDATA%`, and executes it in the background. The download routine sits inside an empty catch block, so a failed attempt produces no error and leaves no trace in the install log. As of early October, both packages remained installable on npm with no advisory flagging either one.
The reason the attack targets the Downloads folder specifically is not arbitrary. Browsers can save files to that directory without asking the user for permission or even requiring a click. Forever built a proof-of-concept web page that silently dropped a crafted `AGENTS.md` into Downloads during a normal browsing session. The firm did not establish that an attacker used this exact method against its customer, but the capability is real and requires no special access.
Test Results Across Two Major Agents
To measure how reliably the technique works, Forever ran controlled tests against OpenAI's Codex and Anthropic's Claude Code.
For Codex, the planted file instructed the agent to register a new server entry in `~/.codex/config.toml` and install the malicious package. Because that config file applies to every session on the machine, a successful write would persist across projects. Codex followed through in more than 90 percent of the test attempts inside an isolated virtual machine.
Claude Code required a different approach. The planted `CLAUDE.md` was written to resemble internal gateway setup documentation, and its goal was to write a custom API endpoint into the project's `.claude/settings.json` file. If an attacker controls that endpoint, every API call from the agent passes through their infrastructure, along with the session token. The token can then be used to take over the account. Claude Code normally prompts the user to approve writes of that kind, and it frequently rejected requests that looked suspicious. The extended engineering-document framing, however, got the write approved roughly half the time.
Neither Vendor Has a Patch
Forever stated plainly that there is nothing for OpenAI or Anthropic to fix. Each agent was doing what it was built to do: read instruction files in the working directory and carry out the steps listed in them. The firm compared the situation to a browser rendering a phishing page. The browser is not broken; the page is malicious.
That framing shifts the responsibility to users and organizations. Forever's own telemetry adds urgency to that point. About half of its customers run a coding agent from their Downloads folder, and roughly a quarter of agent sessions involve an open browser. In many of those cases, no person is actively watching the session when a new file arrives in the directory.
What to Do
The most direct fix is to stop running coding agents from the Downloads folder entirely. Beyond that, Forever recommends reading any `AGENTS.md` or `CLAUDE.md` file you did not write yourself before running a session, including files that arrive in freshly cloned repositories.
For anyone who suspects a file may have already been processed, the firm advises checking `~/.codex/config.toml` for unrecognized server blocks and reviewing `.claude/settings.json` for API endpoints that were not intentionally set. On Windows machines, the presence of `node.exe` inside `%APPDATA%` is a strong indicator that the function-flag payload ran successfully. If a planted file is confirmed, the session's login token should be treated as compromised and rotated immediately.
Keeping approval prompts enabled and running agents inside sandboxes reduces the attack surface, though the Claude Code test results show that approval prompts alone are not a reliable barrier when the malicious instruction is written to look like legitimate documentation.
Read the original article:
AI Coding Agents Can Be Hijacked by a Single Malicious File in Your Downloads Folder
