A malicious plain-text file placed in the Downloads folder can turn an AI coding agent into a tool for installing malware or handing over account access, according to new security research. The file is named AGENTS.md, a document that coding agents are designed to read and trust when it appears in a project folder. Because a website can save a file to Downloads without a click or permission prompt, and because agents often treat that folder as a workspace, the two behaviors combine into a new attack path. One sample found on a customer machine tried to make OpenAI's Codex install a malicious npm package. The package, called function-color, belonged to a supply-chain campaign that went unnoticed for roughly two years before it was documented and removed. The episode shows that the line between an ordinary text file and executable instructions has become dangerously thin.
Key facts
- A website can write AGENTS.md or CLAUDE.md into Downloads without user approval.
- AI coding agents may read those files as trusted project instructions.
- Codex installed the named npm package in more than 90% of tests.
- Claude Code sent login tokens to an attacker-controlled server in about half of tests.
- The attack abuses legitimate agent behavior, so users must change their own workflows.
How a text file becomes an execution path
AI coding agents are built to work inside a project. They read local files, inspect repositories, run commands, install dependencies, and adjust their own settings. Instruction files such as AGENTS.md and CLAUDE.md are plain Markdown documents that tell an agent how a project should be handled. The convention is useful: it lets a team record build steps, coding standards, and operational rules in a place the agent will find. It also creates a trust relationship. When an agent sees one of these files in a folder it considers trusted, it is expected to follow the instructions inside. Researchers described the pattern as Markdown becoming a new executable surface, because the file does not need to be a program to influence what the agent runs.
The Downloads folder is unusually exposed. Browsers routinely write files there, and many downloads complete with little or no interaction. Operating systems apply warnings and approval checks to executable programs downloaded from the internet, but those controls do not apply to a plain text file. A Markdown document can arrive without a malware signature, without an installer, and without a system prompt. If a developer later opens a coding agent in Downloads, or if the agent browses to a page that drops the file, the document can be read as if it were part of the project. The attack does not require a vulnerability in the agent's code. It requires the agent to do what it was designed to do: trust the instructions in its workspace.
Codex test and persistence
In the Codex case, the planted document was about 13 KB. It was disguised as an ordinary set of engineering guidelines, and its length and mundane tone helped it pass scrutiny. A short request to install a package is likely to be refused, but a long document that mixes setup advice with dependency instructions can look like normal project documentation. Codex follows an AGENTS.md only in a folder it trusts, and Downloads qualifies once the user has worked there. When Codex was opened in that folder and given any task, it first changed its own settings and then installed the package named in the file. In testing, Codex ran the malware in more than 90% of attempts. Most of the tests used a harmless stand-in that only opened a calculator, and the actual malicious package was run once inside an isolated virtual machine.
The settings change is the most damaging part. The modified configuration applied to the whole computer, so every later Codex session ran the attacker's command, whichever project the user opened. That turns a single poisoned folder into a persistent compromise. It also shows why package blocking alone is insufficient. A known bad package can be removed from a registry, but the instruction that told the agent to install it can remain in place. The agent may try again with another package, another command, or another configuration change. The trust problem is not limited to the package name. It is the source of the order.
From package install to account takeover
To test whether the problem went beyond one product, the researchers created their own CLAUDE.md, the equivalent instruction file for Anthropic's Claude Code. The file was inspired by the attacker's document, but the successful attack looked different. Claude Code was harder to fool. The researchers' file asked the agent to save a small settings change, presented as a company's internal gateway, that would send requests to a server the attacker controlled. Claude Code normally asks a person to approve a change like this and often refuses ones that look wrong. In testing, Claude followed through on the change about 50% of the time.
That setting matters because each Claude Code request carries the user's login token, a digital key that keeps the user signed in. When the researchers replayed a captured token against Anthropic's service, they were treated as the victim and took over the account without running any code. The next time Claude Code started in that folder, the attacker's server could pose as the AI model and tell the agent to run commands with its sandbox turned off. The file also tried to get Claude Code to start a helper agent, which connected through the attacker's server right away, and that let the researchers run code within the same session in about a fifth of tests. The result is a chain: a text file changes a setting, the setting redirects traffic, the traffic exposes a token, and the token opens the account.
Agents as targets and weapons
Many coding-agent sessions now include autonomous browsing. An agent can be sent to research a library, read documentation, or open a link, and it may visit the page that drops the file. That makes the agent both the target and the weapon in the same operation. Data cited in the research suggests that about half of customers run a coding agent inside the Downloads folder, and about a quarter of agent sessions open a browser. Those two habits are enough to create a practical delivery path. A person does not need to download the file manually. The agent can fetch it, save it, and later read it as part of its own workspace.
Copied repositories are another route. A developer may clone or download a project from an untrusted source and open it with an agent. If the repository contains an AGENTS.md or CLAUDE.md file that the developer did not write, the agent may treat it as project guidance. The same risk applies to shared archives, test fixtures, and documentation bundles. The attack uses legitimate mechanisms: Markdown files, npm packages, settings files, and token-based authentication. None of those components is malicious by itself. The danger comes from the trust placed in the instruction file and the speed with which an agent can act on it.
Why patching is difficult
The researchers argue that there is nothing here for OpenAI or Anthropic to patch. An agent that obeys the instructions file in its folder is doing its job, the same way a browser that shows a phishing page is working as designed. The gap is in the trust model. Agents cannot reliably distinguish legitimate project instructions from attacker-supplied instructions if both appear in a folder the agent has been told to trust. Blocking a known bad package is routine, but it does not address where the order came from. Operating-system protections are also aimed at executable programs, not plain text. That leaves the problem with users and with the tools that watch agent behavior.
Defenders need to treat an agent's folder as part of its attack surface. Provenance matters: who wrote the instruction file, how it arrived, and whether it changed recently. Allowlists for package installs and network destinations can reduce the impact of a malicious instruction. Monitoring can catch the settings changes, child processes, and outbound connections that follow. Most importantly, security teams should watch the agent, not only the user. An agent can browse, download, install, and reconfigure without a person clicking anything. If monitoring only covers human actions, the critical steps in this attack will be invisible.
Defence checklist
- Do not start a coding agent in the Downloads folder.
- Read any AGENTS.md or CLAUDE.md file you did not write before letting an agent near it, including in a repository you have just copied.
- Check agent settings files for servers or web addresses you did not add.
- Keep approval prompts and sandboxes switched on.
- Treat any instruction that tells an agent to get around a safety control as suspicious.
- If you find a planted file, assume your login token has leaked and replace it.
- Treat a computer where function-color was installed as compromised.
- Use separate low-privilege accounts or isolated virtual machines for agent work where possible.
- Monitor package installs, process creation, settings changes, and outbound connections from coding agents.
- Restrict automatic downloads and review browser download locations used by agent sessions.
What to watch next
The specific file names in this campaign are less important than the pattern. Any trusted instruction channel can become an entry point if untrusted content can reach it. Any folder an agent treats as a workspace can become a launchpad. Any credential that travels with an agent request can become a target. The researchers noted that the next attack will not look like this one, and anyone still watching only the user will miss it. The practical lesson is that a plain text file can carry as much operational risk as a binary, and an agent's workspace must be defended with the same care as its code.
Source: Help Net Security News