← Back to BlogSecurity

A Planted AGENTS.md in Downloads Can Steer Your Coding Agent

October 2026 research: a file in ~/Downloads steered Codex and Claude Code. What agents read before acting, and a checklist to close the habit.

Yes, a file you did not write can control your coding agent, if the agent starts in a folder that holds it. In October 2026, security researchers described a malicious AGENTS.md sitting in a customer's ~/Downloads folder that told an agent to install a rogue npm package, and the fix on your side is mostly about where you launch the agent and what you let it read.

Sources: BleepingComputer: AI coding agents hijacked using AGENTS.md file in Downloads folder (Oct 25, 2026)

Agents read instruction files such as AGENTS.md and CLAUDE.md automatically, before you type a prompt. That makes those files input the agent acts on, which is closer to executable input than to documentation. This post covers what the researchers found, what Claude Code loads and from where, and a checklist you can apply in an afternoon.

Insight

Disclosure: we build TLM Forge, a plugin for Claude Code, so weigh the product section near the end accordingly. TLM Forge is not a sandbox.

What the researchers found

BleepingComputer reported on October 25, 2026 that Forever Security, a company that monitors risks from AI agents, found a malicious AGENTS.md file in a customer's ~/Downloads folder. The file caused a coding agent to try to install a rogue npm package named "function-color". The agent loaded it because ~/Downloads was the agent's working directory, and agents automatically load applicable instruction files from their working directory.

Sources: BleepingComputer

The researchers then reproduced the idea against two tools, and the two write-ups measure different things. Per BleepingComputer, with OpenAI Codex a harmless payload that opened the calculator app worked in 90 percent of tests, and with Claude Code a malicious CLAUDE.md redirected the agent's API traffic to a server the researchers controlled. That exposed the agent's OAuth token, and the server could impersonate the model and return tool calls that ran code in roughly 50 percent of tests. Forever's own write-up words it differently. It says Codex ran the malware in more than 90 percent of attempts, but its method note says most testing used a harmless calculator stand-in and the real malicious package was run once, inside an isolated VM. For Claude, it says the model followed through about 50 percent of the time, and separately that getting the planted file written into .claude/settings.json succeeds about half the time, a write it says Claude needs a human to approve and often refuses. It reports code execution inside the first session about a fifth of the time, when Claude spawned a subagent to validate the rerouted config. It also says Codex obeys an AGENTS.md only in a project it trusts, which it says happens once you have worked in Downloads. Forever's write-up gives no agent versions, so treat these numbers as results from one team's setup, not as a rate you should expect on your machine.

Sources: BleepingComputer, Forever Security: Hijacking AI agents via the Downloads folder (Oct 22, 2026)

Scale matters here. According to the article, the researcher Gal Weizman said hundreds of customers run agents such as Claude Code, Codex and Cursor CLI from ~/Downloads, and Claude Code alone launched more than 1,300 sessions from that location. The Downloads folder is where browsers drop whatever you click, so it is a place where files you never inspected pile up.

Sources: BleepingComputer

What is not known

The observed malicious file was found on one customer's machine, and BleepingComputer says how it reached the Downloads folder was not determined. Forever's own write-up states that a web page can download a file named AGENTS.md into your Downloads folder silently, and BleepingComputer reports the researchers suggested a malicious page could drop such a payload without user interaction. Treat that as the researchers' claim about what is possible, not as a confirmed cause in the customer case. BleepingComputer notes that Chrome, Edge and Firefox save to ~/Downloads by default but show a download notification, and that in its own tests Brave asked for approval before downloading.

Sources: BleepingComputer, Forever Security: Hijacking AI agents via the Downloads folder (Oct 22, 2026)

One more detail shapes the advice. The researchers wrote, "There is nothing here for OpenAI or Anthropic to patch," arguing that the agents followed the instruction file in the folder they ran in, as designed. The article reports no specific statement from either vendor, and says that OpenAI and Anthropic recommend running their coding agents from the project directory they are intended to work on. Responsibility lands on the person choosing the launch folder.

Sources: BleepingComputer

What is my agent reading before it acts?

For Claude Code, the Anthropic docs answer this precisely. It loads CLAUDE.md and CLAUDE.local.md from your current working directory and every directory above it. Run it in foo/bar/ and it loads foo/bar/CLAUDE.md, foo/CLAUDE.md, and any CLAUDE.local.md files alongside them. All discovered files are concatenated into context, ordered from the filesystem root down to the working directory.

Sources: Claude Code docs: How Claude remembers your project

Three consequences follow. First, a file in a parent folder counts. A stray CLAUDE.md in your home directory or in a broad folder such as ~/projects rides along into every session started below it. Second, subdirectory files load on demand: Claude Code loads a CLAUDE.md from a subdirectory once Claude reads, writes or edits another file there. Third, CLAUDE.md files can import other files with @path syntax, up to four hops deep, with absolute paths allowed.

Sources: Claude Code docs: How Claude remembers your project

AGENTS.md is handled differently. Claude Code can read it as project instructions, but by default only when no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md exists in your working directory or above it. When it does load, it covers every AGENTS.md in the working directory and the directories above it, and in an interactive session you see a line such as no CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md. That line is a free audit trail, so read it. Reading AGENTS.md directly requires Claude Code v2.1.277 or later.

Sources: Claude Code docs: AGENTS.md

The docs are also plain about the trust model. Both memory systems are loaded at the start of every conversation, and Claude treats them as context, not enforced configuration. Anything the agent reads as context can shape what it does next, which is why an instruction file from an unknown source deserves the same suspicion as a script from an unknown source.

Sources: Claude Code docs: CLAUDE.md vs auto memory

What the trust prompt does and does not cover

In an interactive session, Claude Code shows a workspace trust dialog when you start it in a folder you have not trusted. That is a useful pause, but the docs do not describe it as an inspection of your instruction files' contents, so do not count on it to catch a hostile CLAUDE.md. One related detail: when you start Claude Code directly in your home directory, trust acceptance is held for that session only and the prompt returns on every launch, and the docs recommend starting from a project subdirectory instead.

Sources: Claude Code docs: Security

Separately, the memory docs describe an approval dialog for external imports in project-level memory files, shown to protect you from files other people commit to a shared project. The docs describe it for imports that resolve outside your working directory.

Sources: Claude Code docs: Import additional files

Why the working-directory habit is the real exposure

The attack needs three things to line up: a file with an instruction-file name, an agent launched in or below its folder, and an agent that acts on what it reads. You cannot control the first. You fully control the second. Launching an agent from Downloads, your desktop, your home directory or a folder that holds many unrelated repositories widens both what it loads and what it can touch.

The same habit makes other safeguards weaker. The Claude Code docs say that in Manual mode the working directory boundary is a permission prompt, so a Bash command you approve can still write anywhere your user account can. And the sandbox, when you turn it on, lets sandboxed commands write to the working directory, a temp directory and directories you add, so a broad working directory means a broad write area.

Sources: Claude Code docs: Security, Claude Code docs: Sandboxing

This is a different problem from a compromised dependency rewriting your agent configuration, which we covered in the Tensorlake npm worm post. There, the config files were changed by malicious code that was already installed. Here, a passive file placed in a folder is enough, with no install step before the agent reads it.

A checklist you can apply today

1. Choose where agents start

  • Start agents from the root of a specific project, never from ~/Downloads, the Desktop, your home directory or a folder of many repos.
  • Make a dedicated folder for anything untrusted, such as a downloaded sample project, and keep that folder separate from your real work.
  • If you use a shell alias or an IDE terminal profile that opens in Downloads or home, change its starting directory.
  • Keep the agent working area narrow and add extra directories only when a task needs them.

2. Inspect instruction files before the first run

Before launching an agent in a folder you did not create, list the instruction files that will load. Check the folder, its parents up to the filesystem root, and any .claude directory. General practice, not from the docs: a one-line check is find . -maxdepth 2 \( -name AGENTS.md -o -name CLAUDE.md -o -name CLAUDE.local.md \), plus ls -la for each parent between the folder and /. The find only looks two levels deep, so it will miss files nested further down. After a git clone, open the instruction files and any .claude/ content before you start, and treat a file that tells the agent to install packages, change settings or contact a server as a red flag. Forever also advises checking the agent config itself: in Codex, an unexpected [mcp_servers.*] block or a changed chatgpt_base_url in ~/.codex/config.toml, and in a project's .claude/settings.json, an ANTHROPIC_BASE_URL, a proxy or any API endpoint you did not set. If you find one, Forever says to assume the token leaked and rotate it.

3. Keep approvals and the sandbox on

The researchers listed this themselves: keep approval prompts and sandbox protections enabled. In Claude Code, Manual mode asks before editing files, running tests or executing commands, and the docs advise reviewing suggested commands before approval. The sandbox is separate and off by default: turn it on with /sandbox. It applies OS-level filesystem and network limits to shell commands, and its network proxy checks each host against allowed domains that start empty.

Sources: BleepingComputer, Claude Code docs: Sandboxing, Claude Code docs: Security

Know the sandbox's limits. The docs say it covers shell commands only: Claude's file tools, MCP servers and hooks run outside it, and the default still allows reading credential files, so protect those explicitly. The sandbox also fails open by default: if it cannot start because a dependency is missing or the platform is unsupported, Claude Code runs commands without it unless you set failIfUnavailable to true. On native Windows, commands run unsandboxed. Forever's Claude Code execution step worked by returning a tool call that set dangerouslyDisableSandbox to true. The docs describe that unsandboxed retry as an escape hatch whose approval depends on your permission mode (no prompt in bypassPermissions, a prompt in Manual mode), and setting allowUnsandboxedCommands to false disables it.

Sources: Claude Code docs: Sandboxing

4. Review every package install the agent proposes

The observed payload was a package install. When an agent proposes npm install, pip install or a similar command you did not ask for, stop and ask why. Look up the package name, its publisher and its age before approving. Network-fetching commands such as curl and wget are not auto-approved by default in Claude Code, so a prompt for one is a prompt worth reading. Our post on what deny rules miss explains where command-text rules fall short and why the sandbox network boundary matters.

Sources: Claude Code docs: Security

5. Pin and verify dependencies

This is general practice, not Claude Code guidance. Commit a lockfile, install from it (npm ci rather than npm install), and review lockfile changes in every diff. A new name appearing in the lockfile that nobody on the team asked for is the signal to look for. This does not stop a hostile instruction, but it turns a silent package swap into a visible diff line.

Instruction file sourceRiskWhat to do
File you wrote in your own repoLow, but it can drift or be edited by a bad mergeKeep it under review like code, and diff it in pull requests
File in a repo you cloned from someone elseMedium to high: the author controls what your agent reads on first runOpen it and any .claude/ content before launching, and look for install or network instructions
File in ~/Downloads or another dumping groundHigh: unknown origin, and browsers can place files there with little frictionDo not launch agents there. Move anything you need into a reviewed project folder
File in a parent or home directoryMedium: loads into every session started below it, easy to forgetList parents before launch, delete stray files, and start from a project subfolder
File fetched or imported by another fileMedium: imports chain up to four hops, so the real source can be deepRead what each @path import resolves to, and decline external imports you do not recognize
File from a dependency or templateMedium: arrives with an install, as in the worm caseReview lockfile diffs and watch for new instruction files after installs

How this differs from ordinary prompt injection

Our earlier post on prompt injection in AI-generated code covers hostile text that arrives inside content an agent processes, such as a README, an issue or a web page. An instruction file is a more privileged route. It is loaded on purpose, at the start, as standing guidance, so the agent has no reason to treat it as data. That is why the fixes are about provenance and launch location, not about teaching the model to be more suspicious.

Pro Tip

If an agent behaves strangely in a fresh folder, the first question is which instruction files loaded. In Claude Code, check which instruction files sit in the working directory and its parents, and read the startup line that names a loaded AGENTS.md.

When an agent ignores or distorts instructions you gave it mid-session, that is a separate failure covered in Claude Code Ignores Plan Mode? What Enforces It. And a hijacked agent often shows up as changes you did not ask for, which the unrelated-edits post helps you spot in a diff.

Where TLM Forge fits

TLM Forge is not a sandbox, it does not detect prompt injection, and it does not scan instruction files. On Medium and Deep tasks, the design is shown for your OK before building. After the build, a final review wave of independent reviewer agents runs, and on Deep tasks it includes the red-team-reviewer.

The limits are real. The reviewers are language-model agents and can miss things, and Light tasks get no review agents. Treat them as extra eyes on the work, not protection against a hostile instruction file, and keep the launch-folder habits above as your first line.

Frequently asked questions

01Can a file I did not write control my coding agent?

Yes, if the agent loads it as an instruction file. Agents read files such as AGENTS.md and CLAUDE.md from the working directory automatically, so a hostile file in the launch folder can issue instructions. Researchers demonstrated this against Codex and Claude Code in October 2026.

02Is it safe to run Claude Code from my Downloads folder?

No. Downloads collects files of unknown origin, and the agent loads instruction files from its working directory and the directories above it. Start from the root of a specific project instead, and move anything you need out of Downloads after reviewing it.

03Which files does Claude Code read before I type anything?

It loads CLAUDE.md and CLAUDE.local.md from the working directory and every directory above it. AGENTS.md is read by default only when no CLAUDE.md exists in that chain. Files in subdirectories load later, when Claude reads or edits something there.

04Will the sandbox stop a poisoned instruction file?

It limits damage but does not stop the file from being read. The sandbox restricts shell commands at the filesystem and network level, yet it is off by default and does not cover file tools, MCP servers or hooks. Use it together with approvals and a narrow working directory.

05How do I check a repo for malicious instruction files?

List AGENTS.md, CLAUDE.md and CLAUDE.local.md in the folder and every parent directory, then read them and any .claude folder before launching. Treat any instruction to install packages, change settings or contact a server as suspicious, and decline unfamiliar imports.

Ship AI-written code you can trust

TLM Forge is the missing process layer for Claude Code: a spec audit, independent multi-agent review, enforced TDD, and an adversarial red-team gate.

Get TLM Forge