AI and security briefsSecurity

Can a file in my Downloads folder hijack Codex or Claude Code?

By , founder of Digiton Dynamics

Published Updated Editorial policy

In Forever Security's tests, yes. A web page can save an AGENTS.md or CLAUDE.md into ~/Downloads, and an agent started in that folder reads it as instructions. The researchers say the vendors have nothing to patch, so the control is where your team starts its agents.

Who should act: Anyone who starts Codex or Claude Code in ~/Downloads, or in another folder a web page can write to.

Update log

What happened

Forever Security, which monitors AI agents for its customers, reported on 22 October 2026 that its tooling stopped a coding agent from installing function-color, a known malicious npm package. The order came from an AGENTS.md in the customer's ~/Downloads folder, which was also the agent's working directory. Nobody could say how the file got there (Forever Security, 22 October, covered by BleepingComputer on 25 October).

Forever then rebuilt the chain. Chrome, Edge and Firefox save downloads to that folder without prompting, though they show a notification, so a page can drop the file. BleepingComputer's test in Brave asked for approval first. Codex followed the planted file in more than 90 percent of attempts. Most runs used a harmless stand-in that opens the calculator, and the real package ran once in an isolated VM.

Claude Code needed a different trick. A planted CLAUDE.md told it to write a project settings file that sets ANTHROPIC_BASE_URL to an address the researchers control. That worked about half the time. The server then received Claude's OAuth token and could answer as the model, including with tool calls that run code. Code execution inside the first session worked about a fifth of the time, and the written file makes the next launch in that folder talk to the attacker.

Forever tested Codex and Claude Code only, yet its customer data shows people also run Cursor CLI from Downloads, and about half of its customers run a coding agent in that folder. Claude Code alone started more than 1,300 sessions there (BleepingComputer, 25 October).

Who is affected

Codex only obeys an AGENTS.md in a project it trusts, and Forever notes that working in Downloads once is enough to qualify.

What we checked

Run on on the Mac that builds this site. Each command and its output are copied as they ran.

$ find ~/Downloads -maxdepth 2 \( -iname AGENTS.md -o -iname CLAUDE.md \) 2>/dev/null | wc -l | tr -d ' '
2
$ find ~ -maxdepth 5 -path '*/.claude/settings*.json' -exec grep -l ANTHROPIC_BASE_URL {} + 2>/dev/null | wc -l | tr -d ' '
0

Two instruction files sit in Downloads on this Mac, both from repository archives unpacked on purpose, so nothing needed removing. No Claude Code settings file sets an API address.

What to do now

  1. Look for instruction files you did not write.
    find ~/Downloads -maxdepth 2 \( -iname AGENTS.md -o -iname CLAUDE.md \)
  2. Check Codex for a tool server you did not add or a changed base URL.
    grep -n -E 'mcp_servers|chatgpt_base_url' ~/.codex/config.toml
  3. Check Claude Code project settings for an API address you did not set.
    find ~ -maxdepth 5 -path '*/.claude/settings*.json' -exec grep -l ANTHROPIC_BASE_URL {} + 2>/dev/null
  4. Look for the package and the folder from the reported payload.
    ls /tmp/ptools 2>/dev/null
    find ~ -type d -name function-color -path '*node_modules*' 2>/dev/null
  5. If anything matched, treat the agent login as leaked. Sign out, sign in again and rotate the tokens that machine could reach. Forever says a stolen token is a live session.
  6. Move your agents out of Downloads today and start each one in the root of the project it works on.

What should have been in place

The wider pattern is covered in agentjacking defense.

Questions people ask

Is there a patch for the AGENTS.md Downloads attack?

No, and Forever Security says none is coming. An agent that follows the instructions file in its folder is doing what it was built to do. The defense is where you start agents and what you let them read.

Does it work against Cursor?

Unknown. Forever tested Codex and Claude Code only, and its customer data shows people run Cursor CLI from Downloads too.

Can a website really write to my Downloads folder?

Chrome, Edge and Firefox save downloads there by default and show a notification, BleepingComputer found. Brave asked for approval first. Forever could not say how the file reached its customer's folder.

Digiton's production review turns this into policy you can enforce, and the governance layers are laid out on the Claude Code governance page.

How this brief was made: researched from the sources below, drafted with AI assistance and checked against each source on the dates shown. See the editorial policy.

Sources

  1. BleepingComputer, AI coding agents hijacked using AGENTS.md file in Downloads folder, 25 October 2026, read 26 October 2026. https://www.bleepingcomputer.com/news/security/ai-coding-agents-hijacked-using-agentsmd-file-in-downloads-folder/
  2. Forever Security, Markdown is the new executable, 22 October 2026, read 26 October 2026. https://forever.security/blog/hijacking-ai-agents-via-downloads-folder
  3. Checkmarx, MALFEX npm malware campaign, 5 October 2026, read 26 October 2026. https://checkmarx.com/zero-post/malfex-npm-malware-campaign-three-payloads-and-an-adversary-that-signs-their-work/
  4. Anthropic, Claude Code settings files and precedence, read 26 October 2026. https://code.claude.com/docs/en/settings

More briefs

Did Claude Mythos 5 try to plant malware in a GitHub project, and what did Anthropic say?Was my team affected by the LiteLLM 1.107.0 supply chain attack?Did AI agents really breach more than 100 company websites for $50 each?Should my team test against AWS Emulator instead of a real AWS account?Can a planted /tmp file run code through Claude's document skills on Linux, and is it fixed?Is Claude Code leaking my secrets to GitHub, and how do I check?Did an open-weight Qwen3.8 model try to upload data to Beijing, and what should I lock down?Should I upgrade to Ghostty 1.4, and what breaks when I do?What did Anthropic show about Claude in drug development, and what does it not show?Is the 14-inch MacBook Pro with M6 enough for running LLMs locally?

How these briefs are sourced and corrected. All AI and security briefs

Building something that has to hold up in production?

Start with a free 25-minute scoping call. If it fits, the first paid step is a production review: five working days on your real repository, scored against ten layers, with a costed fix list.

Book a 25-minute scoping call