Rogue AGENTS.md File in Downloads Folder Tricked AI Agents
Security researchers caught a live attack where a plain AGENTS.md file dropped into a user's Downloads folder tricked autonomous AI coding agents into running malware. Because tools like OpenAI Codex and Claude Code obey project markdown files by design, harmless text has effectively become an executable payload.
How a markdown file became an executable vector
Software developers have long treated markdown files as harmless plain text. That assumption just broke down. Cybersecurity firm Forever Security detected a live intrusion on an enterprise endpoint where an AGENTS.md file planted inside the local Downloads folder hijacked an autonomous coding assistant.
The attack relies on a simple architectural blind spot. Coding tools like Claude Code and OpenAI Codex scan their working directory for instruction files such as AGENTS.md to understand project workflows, style guides, and environment scripts. In this incident, the rogue markdown file masqueraded as standard engineering documentation but contained explicit instructions forcing the agent to pull a malicious npm package named 'function-color' and exfiltrate active session tokens.
Because modern web browsers can drop certain non-executable files into the default ~/Downloads directory without an explicit confirmation click, a compromised website can quietly seed instructions on a developer's machine. The moment a user spins up an agent inside that dirty directory, the system-level permissions granted to the AI kick in.
Why vendors cannot patch this with a simple update
The most unsettling aspect of the AGENTS.md exploit is that nothing technically broke. The AI agents behaved exactly as built: they ingested local documentation, trusted the context, and executed shell commands to fulfill the instructions. Forever Security verified that both Claude Code and OpenAI Codex dutifully fell for the attack under identical conditions.
Security models designed for human developers assume someone will inspect code before running an npm install. AI agents invert that logic by automating execution. The shift toward giving autonomous tools full workspace access—a trend highlighted by projects where services like 1Password let AI agents log in without seeing passwords—creates massive exposure when context-reading capabilities are weaponized.
Because the flaw is structural rather than a memory leak or an unhandled exception, model providers cannot issue a straightforward patch. Restricting agents from reading markdown files would dismantle the context mechanism that makes them useful in the first place.
The industry spent decades teaching end users that .exe files are dangerous while .txt and .md files are safe. Autonomous agents just erased that distinction entirely. If an AI reads plain text and immediately runs whatever terminal command it suggests, then plain text is an executable. Leaving coding agents unattended with unrestricted terminal access in shared system folders is no longer viable.
Securing your environment against rogue agent instructions
Until agent developers build stricter origin checks, developers must enforce strict operational boundaries to avoid cross-pollinating untrusted web data with autonomous tools.
Security teams recommend auditing active workspace configurations immediately. If an agent executes an unauthorized package installation or reaches out to an unfamiliar endpoint, assume all active session tokens and local environment variables are compromised.
- Never run an AI agent command directly inside ~/Downloads or any directory shared with web browser outputs.
- Inspect cloned repositories and subdirectories for unfamiliar instruction files like AGENTS.md or CLAUDE.md before invoking an agent.
- Check project settings files like .claude/settings.json for unauthorized proxies, custom base URLs, or altered execution gates.
- Retain manual execution prompts for bash scripts and package installations rather than granting full auto-approval privileges.
What it means for you
Any developer in the US, UK, or EU working with CLI-based coding agents like Claude Code or OpenAI Codex is immediately affected by this threat model. It requires no targeted network breach—visiting a compromised website that triggers a silent download is enough to plant the file. If you run agents on your local machine, check your default downloads folder and verify that automatic script execution gates remain turned on.
Frequently asked questions
What is an AGENTS.md file?
It is a markdown configuration document used by developers to provide context, commands, and project rules directly to autonomous coding assistants like Claude Code and OpenAI Codex.
Can antivirus software block an AGENTS.md exploit?
Traditional endpoint tools struggle because the file itself is harmless text. Antivirus usually flags the payload only after the tricked agent downloads the secondary malicious code or scripts.
Which AI agents are vulnerable to this attack?
Researchers confirmed the behavior on both Claude Code and OpenAI Codex, but virtually any autonomous CLI agent that automatically parses directory instruction files is exposed.
Sources
- AI agents tricked by a rogue downloads file into running dangerous malware | TechRadar. techradar.com, 2026. https://www.techradar.com/pro/security/ai-agents-tricked-by-a-rogue-downloads-file-into-running-dangerous-malware