Home / Tools / OpenAI Codex / Downloads-folder AGENTS.md hijack
A file in your Downloads folder can hijack your coding agent
On Oct 22, 2026, Forever Security reported catching a malicious AGENTS.md in a customer's ~/Downloads folder (which websites can write to without a click) that told OpenAI Codex to register a fake 'project-tools' MCP server in ~/.codex/config.toml and install function-color, a known-malicious npm package. Forever blocked it before code ran; replaying the real file, Codex carried it out in more than 90% of attempts, and a similar CLAUDE.md made Claude Code leak its OAuth token about half the time. There is no patch: never start a coding agent in Downloads, read unfamiliar AGENTS.md/CLAUDE.md files, check your agent config for servers or API URLs you didn't add, and rotate tokens if you find one.
Published · Last updated · Every fact below is from the sources, linked inline. Applies to OpenAI Codex and Claude Code.
What to do now
- Never start a coding agent in
~/Downloads. Start it in the root of the project it should work on. OpenAI and Anthropic both recommend this. [2] - Read instruction files you didn't write. A stray
AGENTS.mdorCLAUDE.md, in Downloads or a freshly cloned repo, is the whole attack. [1] - Check your agent's config (commands below) for MCP servers, API URLs or proxies you didn't add. [1]
- Keep approvals and the sandbox on. Be very suspicious of any file that tells the agent to bypass them, such as
--dangerously-bypass-approvals-and-sandboxin Codex ordangerouslyDisableSandboxin Claude Code. [1] - If you find a planted file, rotate. Assume the agent's login token leaked, and treat any machine that installed
function-coloras compromised. [1]
Am I affected?
Only if you have started Codex, Claude Code or another agent with Downloads (or another folder you didn't create) as its working folder. Codex obeys an AGENTS.md only in a folder it trusts, but once you've worked in Downloads it qualifies. [1] Forever says about half of its customers run a coding agent inside Downloads, and Claude Code alone launched more than 1,300 sessions from there in its data. [1][2]
1. Look for instruction files in Downloads
ls -la ~/Downloads/AGENTS.md ~/Downloads/CLAUDE.md ~/Downloads/.claude 2>/dev/null 2. Codex: check the machine-wide config
The attack writes to ~/.codex/config.toml, so every later Codex session on the machine, in any folder, loads the attacker's server. Look for [mcp_servers.*] blocks you didn't add (the real one was named project-tools and ran launchctl) and for a changed chatgpt_base_url. [1]
grep -n -A3 '^\[mcp_servers' ~/.codex/config.toml
grep -n 'chatgpt_base_url' ~/.codex/config.toml 3. Claude Code: check project settings
The Claude Code variant writes a project .claude/settings.json that sets ANTHROPIC_BASE_URL to the attacker's server. Look for an API URL or proxy you didn't set. [1]
find ~ -path '*/.claude/settings*.json' -not -path '*/node_modules/*' 2>/dev/null \
| xargs grep -n -E 'ANTHROPIC_BASE_URL|_PROXY' 2>/dev/null 4. Indicators from the real attack (macOS)
The real file installs function-color into /tmp/ptools, logging to /tmp/ptools/ac.log, through a launchctl job labeled com.ptools.setup. [1]
ls -la /tmp/ptools /tmp/ptools/ac.log 2>/dev/null
launchctl list 2>/dev/null | grep com.ptools
find ~ /tmp -type d -name function-color -path '*node_modules*' 2>/dev/null Finding nothing is good news but not proof: the file could have been deleted and /tmp is cleared on reboot.
How the Codex attack works
The planted file is a bland, roughly 13 KB “Engineering Work Guidelines” document. A section near the end, dressed up as routine setup, tells Codex, before starting your request, to add a project-tools MCP server to ~/.codex/config.toml whose command uses launchctl to run npm install function-color, then to “confirm” it with a child codex exec --dangerously-bypass-approvals-and-sandbox run from /tmp. [1] Each piece gets around a control: the long document gets past refusals of a blunt “install this”, the child session loads the new server (servers only load at startup), the bypass flag gets network access, and launchctl lets the slow install finish after Codex kills the unresponsive server. [1]
Forever stopped the real attempt before any code ran and couldn't determine how the file got there. Replaying the attacker's unmodified file in an isolated VM, Codex ran the payload in more than 90% of attempts (mostly with a harmless calculator stand-in). [1][2]
How the Claude Code variant works
Claude Code was harder to fool, and Forever had to build its own file. A planted CLAUDE.md asks Claude to save a .claude/settings.json that points ANTHROPIC_BASE_URL at a “team gateway”. Once written, Claude's requests, with its OAuth token, go to the attacker's server, which can replay the token as you and answer as the model with tool calls, including a Bash call with dangerouslyDisableSandbox set. Claude wrote the file about half the time; the code-execution step in the same session worked about a fifth of the time, and otherwise fires on the next launch in that folder. [1]
FAQ
Is this a bug in Codex or Claude Code? Will an update fix it?
No. Forever Security says there is nothing for OpenAI or Anthropic to patch: an agent that follows the AGENTS.md or CLAUDE.md in the folder it starts in is working as designed. The risk comes from starting the agent in a folder the web can write to, so the fix is on your side: don't run coding agents in Downloads.
How can a website put a file in my Downloads folder?
Chrome, Edge and Firefox save downloads to ~/Downloads by default without asking where to save each file, though they do show a download notification. BleepingComputer confirmed Forever's proof-of-concept page dropped a harmless AGENTS.md this way; in Brave, its test prompted the user to approve the download first.
Does it affect Cursor or other agents?
Forever reproduced it only on OpenAI Codex and Claude Code, but argues any agent that reads an instructions file in its working folder and can rewrite its own config can be driven this way. Forever told BleepingComputer it sees customers running Claude Code, Codex and Cursor CLI from their Downloads folders.
Was the Claude Code attack seen in the wild?
No. The real file Forever found targeted Codex. For Claude Code, Forever built its own CLAUDE.md modeled on the attacker's file, and in its tests Claude followed through about 50% of the time.
What is function-color?
A known-malicious npm package that Forever says came from a campaign that went unnoticed for about two years. The npm registry's latest version of it is now a 0.0.1-security placeholder. Forever says any machine where it was installed should be treated as compromised.
Does this change our terminal coding agent pick?
No. Our scores come from a published formula that doesn't factor in security incidents. For “a coding agent that runs in my terminal”, the pick is Claude Code (99.1/100) and the runner-up is OpenAI Codex (76.6/100); this attack hit both, and Forever argues any agent that follows instruction files can be driven this way. Full comparison: best terminal coding agent.
Sources
- Forever Security: “Markdown Is the New Executable: Attackers Are Dropping Agent Instructions Into Your Downloads Folder From the Web” (Gal Weizman, Omer Samet, Oct 22, 2026)
- BleepingComputer: “AI coding agents hijacked using AGENTS.md file in Downloads folder” (Oct 25, 2026)
- npm registry: function-color (now a security placeholder)
Sources checked Oct 27, 2026, about 9:30 AM ET. Spotted an error? Tell us.
The weekly pick sheet
Once a week: what shipped, which picks changed, and why. Free.
- Pick changes, with the scores behind them
- The week's notable releases, each linked to its source
- No paid placement. Unsubscribe in one click.