A robot reviews an AGENTS.md file downloaded to a project folder, with a warning icon beside it.
Your Downloads folder is the one place a web page can write files without asking. Forever Security says that makes it a good spot for an attacker to plant instructions for your AI coding agent.

Forever Security researchers found a coding agent trying to install a malicious npm package called "function-color" on a customer's computer. They traced the attempt to an AGENTS.md file in the customer's ~/Downloads folder, which was also the agent's working directory. The company's own write-up says it stopped the attempt before any code ran. Nobody could say how the file got there.

The file isn't malware in the usual sense. It's plain text, and the agent is what turns it into an attack.

A robot reviews an AGENTS.md file downloaded to a project folder, with a warning icon beside it. Why a text file can hurt you​

Agents automatically load applicable files from their working directory and use the instructions in them. The files aren't executables. But malicious instructions in them can lead an agent to run commands, install packages or change settings, using whatever tools and permissions it has.

OpenAI's Codex documentation describes the discovery rules. It reads a global AGENTS.md from its home directory, then starts at the project root, usually the Git root, and walks down to the current working directory. If it can't find a project root, it checks only the current directory. In an ordinary folder like Downloads, the current directory is all there is.

Claude Code has also widened its reach. Version 2.1.277 shipped on September 18. If a folder has no CLAUDE.md, Claude now checks for AGENTS.md and uses it. That context comes from DevOps.com's coverage. It doesn't change the researchers' Claude finding, which used a CLAUDE.md. It does mean a planted AGENTS.md may now be read by more tools than before.

The researchers' framing is blunt: "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." That's their analysis, not a vendor statement. Critics could argue that vendors can still add friction, such as warning before an agent trusts instruction files in untrusted folders. The evidence doesn't show that mitigations are impossible.

The Codex chain​

Forever Security says it ran the real AGENTS.md from the customer machine inside an isolated virtual machine. Several details stand out.

  • Disguise. The file was a long, mundane "Engineering Work Guidelines" document. The malicious part was one section near the end, presented as routine local setup. The researchers say a short, blunt "install this package" instruction got refused, while the long document got through.
  • Persistence. The instructions told Codex to append an MCP server entry to ~/.codex/config.toml. That is a machine-wide config, not a per-folder one. The report says every later Codex session on the machine would then load the attacker's server, in any folder.
  • Getting around controls. Codex only obeys an AGENTS.md in a project it trusts. Servers load only at session start. The network sandbox blocked the package fetch. So the file told Codex to launch a child process with the flag --dangerously-bypass-approvals-and-sandbox. The researchers also describe handing the install to launchctl, which runs it outside Codex's control, so the slow install wouldn't be killed for failing to answer in time.
  • Success rate. The company reports the malware ran in more than 90% of attempts. BleepingComputer describes the reconstructed test as a harmless payload that opened the calculator, with a 90% success rate.

The launchctl and /bin/zsh details in the real file suggest it targeted macOS. The Downloads-folder trust problem isn't Windows-specific, but the exact payload may not run unchanged on Windows.

The researchers used a harmless stand-in payload for most testing. They ran the real package once, inside an isolated VM. These numbers describe lab tests, not real-world infection rates.

The Claude Code variant​

Claude was harder to fool, and the working attack looks different. The researchers planted a CLAUDE.md telling Claude to write a .claude/settings.json file. That file set ANTHROPIC_BASE_URL to a server the researchers controlled, presented as an internal "model gateway."

According to Forever Security, this does two things.

  • Token leak. Claude sends its OAuth token to that server on every request. The researchers say they replayed a captured token against the real API and were served as the victim. That is account takeover with no code run.
  • Code execution. The server can answer as the model and return tool calls. The researchers returned a Bash call with the sandbox-disable option set to true.

Claude followed through about half the time. The write is the hard part, because Claude needs human approval for it and often refuses. The report says the token leaks immediately once the file is written. Code execution came on the next launch in that folder. A same-session route, using a subagent to "validate" the config, worked about a fifth of the time.

BleepingComputer summarizes this as code-executing tool calls in roughly 50% of tests. Forever Security's own report separates the roughly 50% write success from the lower same-session execution rate. The report itself calls the overall result a proof of concept, not a reported customer account takeover.

How does the file get there?​

Forever Security's claim is that "a web page can download a file named AGENTS.md into your Downloads folder, silently." When BleepingComputer tested the proof-of-concept page, it downloaded an AGENTS.md with harmless content: "sensitive data here" and "line 2."

That confirms the test page's behavior. It doesn't prove how the customer's file arrived. BleepingComputer's browser notes:

  • Chrome, Edge and Firefox generally save downloads to Downloads without asking for a location each time.
  • They still show download notifications by default.
  • Brave prompted for approval in BleepingComputer's test.

The attack also needs a second step. Someone has to launch an agent in that directory. The researchers' telemetry suggests that's common. They say hundreds of customers run Claude Code, Codex or Cursor CLI from Downloads, and Claude Code alone launched more than 1,300 sessions from there, per Gal Weizman. These are company-supplied figures, not independently audited.

What to do​

  1. Don't run agents from Downloads. Also avoid your home directory or a broad parent folder. Start the agent in the specific project root, which is the recommendation BleepingComputer attributes to OpenAI and Anthropic.
  2. Read unfamiliar instruction files first. That means any AGENTS.md or CLAUDE.md you didn't write, including in a repo you just cloned.
  3. Check agent config for tampering.
    • For Codex, look in ~/.codex/config.toml for an unexpected [mcp_servers.*] block or a changed chatgpt_base_url.
    • For Claude Code, look in a project's .claude/settings.json for an unexpected ANTHROPIC_BASE_URL, proxy or other endpoint you didn't set.
  4. Keep approvals and sandboxing on. Treat any instruction telling the agent to bypass them as a red flag.
  5. Rotate tokens if you suspect exposure. The researchers advise assuming a leaked token is a live session.
  6. Look for function-color. If it appears in a machine's installs, treat that machine as compromised. The report says npm has since removed the package.

Forever Security is a vendor selling agent monitoring, so read its "this will never be fixed" framing with that in mind. The practical advice holds regardless. It costs nothing to follow: start agents in the project folder, not the one directory the web can write to.

 

References

  1. AI coding agents hijacked using AGENTS.md file in Downloads folder BleepingComputer 2026-10-25T11:49:38-04:00
  2. Markdown Is the New Executable: Attackers Are Dropping Agent Instructions Into Your Downloads Folder From the Web · Forever Security forever.security
  3. Claude Code Adds AGENTS.md Fallback, Cutting Instruction File Sprawl devops.com