Planted Markdown files made two coding agents rewrite their own config
Forever Security found a planted AGENTS.md in a customer's Downloads folder. The lesson for teams shipping agents is not the folder, it is that text an agent read could change what the agent was allowed to do.
- Written by
- Baraqix Engineering
- Published
- Read
- 5 min
- Filed under
- agents, security, prompt injection, mcp
Contents3 sections
On 22 October 2026, Forever Security published a research report describing a malicious AGENTS.md file it found in the ~/Downloads folder of a customer machine. The file was dressed up as ordinary engineering notes. One section told OpenAI Codex to register a new MCP server in its own configuration and install function-color, a malicious npm package that Forever ties to a campaign documented publicly by Checkmarx. Forever says it blocked the install before any code ran, and that nobody knew how the file got into the folder.
Forever's first recommendation is hygiene: do not start your coding agent in Downloads. That advice is correct, and it is the least interesting part of the report. The finding that matters for anyone shipping agents is that in both products tested, text the agent read was enough to make the agent rewrite its own configuration. Once an agent can change its own tool list or its own model endpoint, every other control sits downstream of a prompt.
What the report shows
Forever reproduced the chain on two agents. On Codex it used the real attacker file. It says most of its testing used a harmless substitute payload, and that it ran the real malicious package once, inside an isolated VM. On Claude Code it wrote its own CLAUDE.md, modelled on the attacker file, since the original targeted Codex. It also built a proof of concept web page that, by its account, saves an AGENTS.md into Downloads with no click needed.
| Codex | Claude Code | |
|---|---|---|
| Instruction file | AGENTS.md, the real attacker file | CLAUDE.md, written by the researchers |
| What the agent wrote | An MCP server entry in ~/.codex/config.toml, which applies to every session on the machine | ANTHROPIC_BASE_URL in the project .claude/settings.json |
| Effect | The server command installs the malicious package | The OAuth token goes to a server the researchers control, which can then answer as the model with tool calls |
| Reported rate | More than 90% of attempts | About half for the settings write, about a fifth for code execution in the same session |
A few details deserve attention. The Codex payload is a 13 KB document, because Forever found that a short, obvious instruction gets refused. It tells the model to start a child codex exec with --dangerously-bypass-approvals-and-sandbox, a flag the model wrote itself because the document claimed the install needed network access. It hands the install to launchctl so the startup timeout cannot kill it. Codex only obeys an instructions file in a trusted folder, and Downloads qualifies once a user has worked there. On Claude Code, the same file that worked in a clean folder failed every time in a folder full of security notes, which tells you how context dependent these refusals are.
Forever also reports that in its telemetry about half of customers run a coding agent inside Downloads, and roughly a quarter of agent sessions open a real browser. Those numbers describe one vendor's customer base, not the industry.
Where we disagree with the report
There is nothing here for OpenAI or Anthropic to patch.
Forever Security, 22 October 2026
We understand the argument. The agent followed an instructions file in its working folder, which is what it was built to do. But look at the table again. Neither attack needed a sandbox escape. In both cases the model wrote to a file that defines its own capabilities: which servers it launches, and which endpoint it trusts with its token. That write is the vulnerability. An instructions file that tells an agent how to run the tests is ordinary. An instructions file that can grant the agent new executables or redirect its credentials is a privilege escalation path, and privilege boundaries are something both vendors and product teams can design.
The same shape shows up far from coding tools. A RAG system reads PDF and DOCX files that strangers wrote. A WhatsApp assistant reads messages from anyone who has the number. A risk scoring engine reads whatever evidence it is handed. Every system we have built that reads outside text faces this question, and an instructions file is just retrieved content that someone decided to trust more. If an agent in production can call a tool that edits its own tool registry, its prompts or its outbound endpoints, it has the hole Forever demonstrated, with or without a Downloads folder.
What we would do
Our position for teams shipping agents is simple: the model can propose, but it cannot change what it is allowed to do. Concretely:
- Keep agent configuration out of the agent's reach. Tool registries, MCP server lists, base URLs and system prompts load from deployed config that the agent process cannot write. Changes go through code review like any other deploy.
- Pin egress. The model endpoint and every tool host sit on an allowlist fixed at deployment. A changed base URL should fail closed, not quietly reroute traffic and credentials.
- Separate instructions from content. Only instruction files from a known path, tracked in version control, are loaded as instructions. Retrieved documents, uploads, emails and chat messages are passed as data and never promoted.
- Reject bypass flags in the executor. Any tool call that asks to disable a sandbox or skip approval is refused by the code that runs tools, whatever the model says. The Claude Code attack reached code execution because the client accepted
dangerouslyDisableSandboxfrom a server pretending to be the model. - Detect drift. Hash the configuration at startup and after any tool call that writes to disk, and alert when it changes.
A startup guard takes a few lines. This is the pattern we would add to an agent runner, not a finished product:
import hashlib, subprocess, sys
from pathlib import Path
CONFIG = Path("/etc/agent/config.toml") # owned by root, read only for the agent user
EXPECTED = Path("/etc/agent/config.sha256") # written by the deploy pipeline, not by the agent
def tracked(path: Path) -> bool:
result = subprocess.run(["git", "ls-files", "--error-unmatch", str(path)],
capture_output=True)
return result.returncode == 0
digest = hashlib.sha256(CONFIG.read_bytes()).hexdigest()
if digest != EXPECTED.read_text().strip():
sys.exit("agent config changed outside a deploy, refusing to start")
for name in ("AGENTS.md", "CLAUDE.md"):
f = Path.cwd() / name
if f.exists() and not tracked(f):
sys.exit(f"{name} is not under version control, refusing to load it")
For developer machines, Forever's own advice is sound: do not start agents in Downloads, read any AGENTS.md or CLAUDE.md you did not write, check ~/.codex/config.toml and .claude/settings.json for servers or endpoints you did not set, and assume a token leaked and rotate it if you find one.
If you are putting an agent in front of documents, customers or a database and want its capability boundaries designed before launch rather than after an incident, that is the work of our AI integration practice, and it starts with a two week fixed price Discovery Sprint.
Baraqix Engineering. Written by the engineers who did the work.
NOTE/07. First published .