packet-autopsy.com

Case 010 · Incident: Oct 2026

Codex and Claude Code: A text file in Downloads tried to hijack an AI assistant

Forever Security, a firm that monitors AI agents, stopped a coding agent on a real customer's machine from installing the known-malicious npm package function-color. It traced the install attempt to a planted AGENTS.md instruction file in the customer's ~/Downloads folder, which was also the agent's working directory. Nobody has worked out how the file got there.

Watch on YouTube

Who was hit, and how badly

On a real customer's computer, a firm that watches AI agents caught a coding agent trying to install a package already known to be malware. It stopped the agent mid-session, before any code ran.[1][2][3] The package was called function-color. It came from a malware campaign that went unnoticed for roughly two years. Once installed, it pulls in a downloader called function-flag, which fetches and runs a Windows payload.[2][3] The agent had not gone looking for trouble. It was following a file called AGENTS.md, sitting in Downloads, the folder it was working in, dressed up as Engineering Work Guidelines. Nobody could work out how it got there.[1][2][3]

The file itself held no program at all. It was plain text, written to look like ordinary engineering notes. To see why plain text was enough, it helps to know what these files are for.[2] An AGENTS.md is a plain-text file that gives a coding agent project-specific instructions. Things like which tools to use, how to run tests, and which coding conventions to follow.[1] That is the trick. In an agent's hands, such a file behaves like an executable. Its instructions get run, yet none of the guardrails that stop executables apply to it.[2]

Other researchers who documented the wider campaign, named MALFEX, found packages able to deliver remote-access malware and steal browser, Discord, Telegram and cryptocurrency wallet data.[3][4] To see how bad it was, Forever took the exact AGENTS.md from the customer's machine and ran it, unmodified, inside an isolated virtual machine.[2] Forever tested the attack against OpenAI's Codex. It says that in its testing, Codex ran the malware in more than 90% of attempts.[2]

Where it wrote made it worse. In the Codex tests, the file edited Codex's machine-wide configuration, not a setting tied to one folder. Nobody reports a change like that on the customer's machine, where the agent was stopped before any code ran.[2][3] Once written, every Codex session on the machine loads the attacker's server at startup, in any folder, any project. That is persistence.[2] Cyber Security News reports that the instructions also got Codex to start a second session with its approval and sandbox checks switched off. Those are the checks that ask a person first and keep the agent fenced in. To finish the install, the real file handed it to a tool called launchctl, which runs it outside Codex's control.[2][4]

Then Forever built a second test. Inspired by the attacker's file, they crafted a CLAUDE.md for Anthropic's Claude Code. This one was not found in the wild.[2] The planted file got Claude to point its own network traffic at a server the researchers controlled, on a domain they owned, with a valid certificate.[2] That leaked Claude's OAuth login token. Account takeover on its own, with no code run. Claude followed through about half the time.[2]

When the researchers replayed a captured token against the real service, it served them as the victim.[2] There is a brake built in, though. Claude Code needs a person to approve a write like that, and it often refuses ones that look wrong.[3] Even so, about a fifth of the time a spawned subagent gave them code execution inside the session as well.[2]

How did they get in

Which leaves the question Forever could not answer. How did the file get into that folder at all.[2] An attack like this needs two things. The file has to land in the folder, and the agent has to act on it. For the second part, length was the weapon: the real file was a 13 kilobyte document, not a one-liner.[1][2] The dull framing was deliberate. It helped the file slip past the refusals that short, obvious instructions trigger. Forever saw the same effect with its Claude test file: it worked in a clean folder but failed every time in a folder full of security notes.[2]

Codex only obeys an AGENTS.md in a project it trusts. But once someone has worked in the Downloads folder even once, the folder qualifies as trusted.[2] And Downloads is special. Forever calls it the one folder the web can write to on its own. A web page can save a file to your machine with no click and no approval, choosing both its name and its contents.[2] The researchers did not prove this is how the file arrived. To test whether the path was even possible, they built a proof-of-concept web page.[3]

When BleepingComputer tested it, the page downloaded an AGENTS.md containing only harmless placeholder text.[1] By default, Chrome, Edge and Firefox save downloads straight to the Downloads folder, without asking where to put each file.[1] It is not completely invisible. Brave asked for approval in those tests, and Chrome, Edge and Firefox still show a download notification when a file is saved.[1]

And the attack is not automatic. The victim still has to launch their agent inside Downloads, or otherwise let it process the file. Only then does the agent load the instructions and act on them.[1][2][3][4] That turns out to be common. Forever's own statistics show hundreds of customers running agents from Downloads, with Claude Code alone launching more than 1,300 sessions there.[1] People use agents to tidy that folder or act on a fresh download. About half of Forever's customers run a coding agent inside Downloads.[1][2]

What is still unknown

So what is still unknown. The honest answer is a longer list than the answers.[2][3] Whether a real attacker used that web route against this customer is not established. The proof-of-concept only shows the path is possible.[3] Who wrote the malicious file is unknown, and whether it was the operators of the MALFEX campaign or someone reusing their package.[3]

Forever has not named the customer, and it is not known whether other users were hit by similar files.[2] Forever reports more than 90% for Codex with the attacker's real file. BleepingComputer reports 90% with a harmless calculator payload, which Forever says it used for most of its testing.[1][2] No source gives a date for when the file was planted or caught. Only that Forever described it in a report the week before The Hacker News wrote it up on October 26, 2026.[3]

None of the sources include a statement from OpenAI or Anthropic on this incident, so whether either company has responded is still an open question. Separately, Forever says there is nothing for OpenAI or Anthropic to patch.[2] An agent that follows the AGENTS.md in its folder is doing exactly what it was built to do. So the defence falls to the people running it.[2]

The defence is yours

npm has since removed function-color. If it turns up in a machine's installs, treat that machine as compromised. The file is only text, but in an agent's hands text can run itself.[2]

What to do

  • Treat the Downloads folder as hostile ground for agents. Do not start a coding agent there. Run it from the directory of the project it is meant to work on.
  • Any instruction file you did not write deserves a read first. A stray AGENTS.md or CLAUDE.md, in Downloads or in a repository you just cloned, is the whole attack.
  • Check your agent's configuration for things you did not add. An unexpected server block, a changed base address, or any proxy or endpoint you never set.
  • Keep the brakes on. Leave approval gates and sandboxes enabled, and be very suspicious of anything that tells an agent to bypass them.
  • If you find a planted instruction file, assume your login token has leaked. Rotate it, and do it from a clean device. A stolen token is a live session, not just one caught request.

Open questions

  • How did the malicious AGENTS.md get into the customer's ~/Downloads folder? Forever could not determine this.
  • Did a real attacker use a silent web-page download to deliver the file, or did it arrive some other way? Forever's proof-of-concept only shows this is possible.
  • Who created the malicious AGENTS.md, and is it run by the operators of the MALFEX npm campaign or someone reusing the package?
  • Who is the affected customer, and were other Forever customers or other users targeted with similar files?
  • Success rates differ across sources: Forever reports more than 90% for Codex with the real file, while BleepingComputer reports 90% with a calculator payload.
  • Have OpenAI or Anthropic responded publicly? None of the sources include a vendor statement on this incident.
  • When was the file planted and detected? The sources give no detection date beyond the October 2026 publication.
  • When did npm remove function-color? Forever says it was removed but gives no date.

Sources

  1. [1]BleepingComputer — AI coding agents hijacked using AGENTS.md file in Downloads folder
  2. [2]Forever Security
  3. [3]The Hacker News — Malicious File in Downloads Folder Tries to Trick AI Coding Agent Into Installing Malware
  4. [4]Cyber Security News