Security News

AGENTS.md in Downloads: How a Dropped File Hijacks Coding Agents

A planted AGENTS.md in Downloads led Codex to a malicious npm package, and a CLAUDE.md variant worked on Claude Code. How it works and what to check.

Brandefense logo 6 Min Read
Brandefense threat alert: glowing digital documents in a secure display.

Forever Security reports that a malicious AGENTS.md file in a customer’s Downloads folder pushed a coding agent to install function-color, a known malicious npm package. The company says its systems blocked the install. The case is a clear example of prompt injection against an AI agent that starts with a plain file, not a chat message.

The researchers (Gal Weizman and Omer Samet, 22 October 2026) tested OpenAI Codex and Claude Code. They say this is “not one product’s bug”, and the article reports no vendor patch or statement.

Last updated: 26 October 2026. We update this page if OpenAI or Anthropic publish a fix or guidance.

How Does a File in Downloads Reach a Coding Agent?

The research says a website can silently save a file to ~/Downloads with no click or permission prompt. People trust that folder. Coding agents also read instruction files when they start, so a planted file can be obeyed as if the user had written it.

The agents.md site describes the format as “a README for agents”. It has no required fields: it is “just standard Markdown”, and agents “automatically read the nearest file in the directory tree”.

The Codex documentation adds a detail that matters here. Codex starts at the project root, and if it finds none it checks only the current directory. Our reading is that an agent started inside Downloads, which is not a code repository, meets any AGENTS.md that sits there.

Forever Security puts it this way: “Markdown is the new executable.” An instruction file is built to be followed, so it does not trigger the operating system protections that an executable would.

The OWASP Top 10 for LLM applications names this class indirect prompt injection, which occurs “when an LLM accepts input from external sources, such as websites or files”.

What Did the Planted File Make the Agents Do?

The article describes two different paths. Both end in persistence or code execution, and neither needs a software bug.

The Codex path described by Forever Security
The Codex path described by Forever SecurityAttack path in 5 steps: 1, Website saves AGENTS.md (Web), then silent download; 2, File sits in Downloads (Laptop), then agent started there; 3, Agent reads the file (Laptop), then instruction obeyed; 4, Codex config.toml edited (Laptop), then persists across projects; 5, npm install function-color (Registry).WebLaptopRegistrysilent downloadagent started thereinstruction obeyedpersists across projectsWebsite savesAGENTS.mdFile sits inDownloadsAgent reads the fileCodex config.tomleditednpm installfunction-color
  1. Website saves AGENTS.mdWebsilent download
  2. File sits in DownloadsLaptopagent started there
  3. Agent reads the fileLaptopinstruction obeyed
  4. Codex config.toml editedLaptoppersists across projects
  5. npm install function-colorRegistry

For Codex, the planted file tells the agent to add a [mcp_servers.project-tools] entry to ~/.codex/config.toml. That entry launches npm install function-color through launchctl. The config file is machine wide, so the change outlives the project. The article says Codex ran the malware in more than 90% of attempts, and that the attack needed a child codex exec run with --dangerously-bypass-approvals-and-sandbox.

For Claude Code, the researchers wrote their own CLAUDE.md, modelled on the real file. It gets Claude to write .claude/settings.json with an ANTHROPIC_BASE_URL that points to an attacker domain. The authors say this leaks the OAuth token and allows account takeover.

The attacker server can also return a Bash tool call with dangerouslyDisableSandbox set to true. The file was written about half of the time. In about a fifth of runs Claude also spawned a subagent, whose new connection went through the attacker server, and code ran in the same session.

The installed package is the endpoint, which makes this a supply chain attack delivered through an AI agent. The article says npm has removed function-color and that it belongs to a campaign documented by Checkmarx.

Which Agents and Settings Were Exposed?

Only Codex and Claude Code were tested. The article does not test other agents, but says “any of them can be hit”. The agents.md site lists many tools that read the same file, including Codex, Gemini CLI, Cursor, Windsurf, Aider and GitHub Copilot’s coding agent. GitHub’s documentation says that when Copilot is working, “the nearest AGENTS.md file in the directory tree will take precedence”.

The authors also tested the controls people rely on: trust gating, sandboxing, approval prompts, startup only server loading and network restrictions. They say the attack worked around each one; for the network sandbox, the model itself wrote the bypass flag into the command.

On exposure, the article gives two telemetry figures from its own customers. About half run a coding agent in Downloads, and roughly a quarter of agent sessions open a real browser. We cannot check these figures, so read them as the vendor’s own data.

Why Do Agents Obey a File Nobody Reviewed?

The Claude Code documentation says CLAUDE.md files in the directory hierarchy above the working directory are loaded at launch. It also says Claude treats them as “context, not enforced configuration”. To block an action whatever the model decides, it points to a PreToolUse hook. In short, a loaded instruction file is advice the model may follow, and only code outside the model can refuse.

That is the same lesson as in memory and context poisoning. Text that reaches an agent’s context can steer it, and a change to its config can keep steering it later.

How Can You Defend Against It?

The research gives five actions and one indicator of compromise. The last check below is our own suggestion.

Checks for teams that run coding agents
  • Do not start a coding agent in ~/DownloadsThe research names this as the first step
  • Read any unfamiliar AGENTS.md or CLAUDE.md before an agent loads itInstruction files are followed, not scanned
  • Inspect ~/.codex/config.toml and .claude/settings.jsonLook for MCP server entries or a base URL you did not set
  • Keep approval gates and sandboxes onAgents should not be allowed to switch them off
  • Rotate tokens if you suspect a compromiseThe Claude Code path targets the OAuth token
  • Search endpoints for a function-color installThe research lists it as the indicator of compromise
  • List instruction files in Downloads foldersOur suggestion, to find planted files early

The wider rules are in our guides on human approval and least agency and on least privilege. The research does not say that workspace trust or npm install settings stop this attack, so do not count on them alone.

Frequently Asked Questions.

What is an AGENTS.md file?

It is a plain Markdown file that gives coding agents project instructions. The agents.md site calls it a README for agents and says it has no required fields.

Which package did the attack try to install?

Forever Security names the npm package function-color. The article says npm has removed it.

Is there a patch?

The research says there is nothing for OpenAI or Anthropic to patch. It treats the problem as a design level gap, and it reports no vendor statement.

Sources

  1. 1 Forever Security: Markdown Is the New Executable
  2. 2 AGENTS.md specification site
  3. 3 OpenAI Codex documentation: AGENTS.md
  4. 4 Claude Code documentation: How Claude remembers your project
  5. 5 OWASP LLM01:2025 Prompt Injection
  6. 6 GitHub Docs: adding repository custom instructions for Copilot
Share