---
title: "Coding agents hijacked through the Downloads folder: how an AGENTS.md became an attack"
description: "A malicious AGENTS.md in a real customer's Downloads folder tried to make a coding agent install malware. We explain the attack, what the tests showed and how to protect yourself."
date: "2026-11-18"
lang: "en-US"
canonical: "https://www.meyje.com.br/en/blog/agentes-de-codigo-sequestrados-pela-pasta-downloads"
---
On October 22, 2026, Forever Security, a company that monitors the risks of AI agents, reported finding an `AGENTS.md` file dressed up as engineering notes in a customer's Downloads folder. It wasn't a program, it was text. And that text told the coding agent to install a malicious npm package.

In this post we explain why, to an agent, an instructions file works like code, what the tests with Codex (OpenAI) and Claude Code (Anthropic) showed, and what to do about it in practice.

## To an agent, an instructions file is code

`AGENTS.md` and `CLAUDE.md` are Markdown files with guidance for coding agents, such as test commands and project conventions. The agent loads them on its own at startup:

- **Codex** reads `AGENTS.override.md` and `AGENTS.md` from the project root down to the folder it was opened in. Outside a repository, it only looks at the current folder.
- **Claude Code** reads the `CLAUDE.md` in the current folder and in every folder above it. Recent versions also read `AGENTS.md` when there is no `CLAUDE.md`.

The model has no hard line between information and instructions, and a coding agent runs commands, installs packages and edits its own configuration. Whoever writes the instructions file is, in practice, programming the agent. Forever summed it up in the title of its report: "Markdown is the new executable".

That is why we talk about a **context supply chain**. We already distrust dependencies and pin versions. An agent's context has suppliers too (instruction files, READMEs, issues, web pages, tool outputs), and any of them can be poisoned.

## The real case

According to Forever, the file planted in `~/Downloads` passed itself off as an ordinary engineering guide. Somewhere in the text, it asked for `function-color` to be installed, a package from a malicious npm campaign that went undetected for about two years and has since been removed by npm. Forever's software blocked the install mid-session. Nobody knows how the file got onto the machine.

Two pieces make the attack plausible:

- **A website can save files to Downloads.** Forever says visiting the page is enough, with no click. According to BleepingComputer, Chrome, Edge and Firefox save downloads there by default without asking (they only show a notification); in the site's tests, Brave asked for approval. And, as Help Net Security points out, the protections for downloaded programs don't apply to plain text.
- **Lots of people open their agent right there.** According to Forever's telemetry, about half of its customers run a coding agent in the Downloads folder. BleepingComputer cites more than 1,300 Claude Code sessions launched from that folder.

## What the tests showed

The numbers come from Forever's own tests, and it did not say how many attempts it ran. Most of them used a harmless payload that only opened the calculator.

### Codex

With the attacker's real `AGENTS.md`, Codex ran the payload in more than 90% of attempts. According to Forever, it only obeys the file in a project it trusts, and the Downloads folder qualifies once you have worked there.

The agent added an `[mcp_servers.project-tools]` block to `~/.codex/config.toml`, installed the package and also launched a `codex exec` with the `--dangerously-bypass-approvals-and-sandbox` option. Because that file applies to the whole machine, the malicious MCP server (MCP is the Model Context Protocol, the standard that connects tools to the agent) loads in every session, in any folder. Leaving Downloads doesn't fix it.

### Claude Code

Here the researchers wrote their own `CLAUDE.md`, inspired by the attacker's. The file asked Claude to write the `ANTHROPIC_BASE_URL` variable into `.claude/settings.json`, pointing at a server they controlled. According to Forever, this worked about half the time, with three effects:

- **Token leak.** The requests carried the login token (OAuth) to the researchers' server. Replayed against the real API, it gave access to the victim's account, without running any code.
- **A command in the next session.** The fake server poses as the model and asks for a command with the sandbox turned off. The researchers stopped the test at that point.
- **Execution in the same session.** A subagent spun up on the pretext of validating the config was already connecting through the fake server: code execution in about a fifth of attempts.

### It's not "Codex bad, Claude good"

The numbers differ because the attacks were different. In Forever's view, any agent that reads an instructions file and can rewrite its own configuration is exposed. And there is no bug: according to the researchers, there is nothing for OpenAI or Anthropic to fix, because the agent did what it was designed to do.

## A practical guide

### Where to open the agent and what to read first

- Never open the agent in Downloads or in your home folder. Use the project root, which is what OpenAI and Anthropic recommend, according to BleepingComputer. In Claude Code, the `CLAUDE.md` files in the folders above also get loaded: move the project to a folder of its own.
- In a third-party repository, read `AGENTS.md`, `CLAUDE.md`, `CLAUDE.local.md` and the `.claude/` and `.codex/` folders before you call the agent. Be wary of requests to install packages, reach external addresses or change settings, even when they are buried in long, bureaucratic text (that was the disguise).
- Test code you don't trust in a virtual machine or a container first.

### Check your configuration

Look for MCP servers you didn't create, a changed `chatgpt_base_url` or an API address you didn't set. The commands below only read files (macOS, Linux or Git Bash on Windows); run items 2 to 4 in the project folder:

```bash
# 1. Agent instruction files in the Downloads folder
find ~/Downloads -maxdepth 3 \( -iname 'AGENTS*.md' -o -iname 'CLAUDE*.md' \) 2>/dev/null

# 2. Instruction files and config folders in the repository
find . \( -iname 'AGENTS*.md' -o -iname 'CLAUDE*.md' -o -name '.claude' -o -name '.codex' \) -not -path '*/node_modules/*'

# 3. Codex: MCP servers and API addresses
grep -nE 'mcp_servers|base_url' ~/.codex/config.toml .codex/config.toml 2>/dev/null

# 4. Claude Code: a swapped API address
grep -n 'ANTHROPIC_BASE_URL' ~/.claude/settings.json .claude/settings.json .claude/settings.local.json 2>/dev/null

# 5. The campaign's package, in Downloads or installed globally
find ~/Downloads -maxdepth 4 -type d -path '*node_modules/function-color' 2>/dev/null
npm ls -g function-color
```

### Keep sandbox and approvals on

Keep both turned on. The options that skip approvals or the sandbox (in Codex and Claude Code, they start with `--dangerously`) belong in disposable environments. Be suspicious of any text that asks you to use them.

### If you suspect something

1. Close the agent's sessions, keep a copy of the planted file and remove the unfamiliar entries.
2. Assume the token leaked, as Forever recommends: revoke keys and tokens and sign in again.
3. If `function-color` was installed, treat the machine as compromised.

## What this changes for people building agents

At MEYJE we build AI agents for clients, as well as RuralZap, our financial assistant for agribusiness on WhatsApp. The lesson applies to any agent: **every piece of text it reads is untrusted input**, whether it's a file, an email, a message or a tool output. In the way we design agents, this translates into four rules:

1. **Only the agent's operator gives orders.** Everything else is data, and it's the architecture that guarantees this, not the model.
2. **The agent doesn't touch its own configuration.** API addresses, tools and permissions stay out of its reach.
3. **Least privilege and confirmation.** Credentials stay where the model can't see them, and irreversible actions (installing a package, moving money, deleting data) go through a person.
4. **Test with malicious text.** Before production, hide instructions in documents and see what the agent does.

The Downloads folder case doesn't reveal an exotic flaw: it shows what happens when a system that takes actions trusts everything it reads. If you want to put agents to work in your company without opening that door, [talk to us](/en#contact).
