All Insights

Your AI Coding Agent Will Follow Orders From a File It Shouldn't Trust

CivSafe Team·October 29, 2026·5 min read

Security firm Forever Security found something uncomfortable this week. A customer's AI coding agent got hijacked by a single Markdown file sitting in their Downloads folder. No malware, no exploit, no zero-day. Just a file the agent was built to obey.

Here's what happened and why your team needs to know about it.

The Attack Is Almost Embarrassingly Simple

The customer was running OpenAI's Codex as their AI coding agent. Codex, like most modern AI coding tools, looks for a special instruction file called AGENTS.md in its working directory. If the file is there, the agent reads it and follows whatever instructions it contains.

When a developer starts their agent from the ~/Downloads folder, every AGENTS.md that lands in Downloads becomes part of the agent's operating instructions. It can't tell a legitimate project readme from an attacker's trap. It just reads and executes.

The malicious file told the Codex agent to:

  1. Register an attacker-controlled server in its global config (~/.codex/config.toml)
  2. Install a known-malicious npm package called function-color
  3. Do all of this quietly, as part of "routine setup"

In lab testing, Codex followed these instructions in more than 90% of attempts. The researchers also reproduced the attack against Claude Code with a planted CLAUDE.md file, redirecting the agent's API traffic to a server they controlled and capturing live authentication tokens.

No Patch Is Coming

Forever Security's conclusion landed hard: "There is nothing here for OpenAI or Anthropic to patch. An agent that follows the AGENTS.md in its folder is doing exactly what it was built to do."

That's the uncomfortable part. This isn't a bug. It's the product working as designed.

AI coding agents are powerful because they follow project-level instructions flexibly. That flexibility is the feature. The same framework that lets your CLAUDE.md say "always use our internal linting rules" is the one an attacker exploits to say "also phone home to this server."

The fix has to come from how teams use these tools, not from the vendors.

How a Developer Gets Caught

You download a zip file from a GitHub issue or a Slack thread. You extract it to ~/Downloads to take a quick look. Inside is a subdirectory with some code and a file called AGENTS.md.

Later, you fire up your AI coding agent from the terminal. Your shell is still pointed at ~/Downloads. The agent reads every instruction file in the directory. It has no idea that file came from an untrusted source. It dutifully follows along.

This is not a contrived scenario. Forever Security found it in the wild first and then recreated it in a lab. The customer couldn't even identify how the malicious file got there. The researchers demonstrated that a regular webpage can silently drop an AGENTS.md into your Downloads folder without any additional prompt.

Why This Matters More for Small Teams

Large organizations have IAM policies, endpoint detection, and security teams watching for unexpected config changes. A 10-person nonprofit or a 15-person agency does not.

Small teams also tend to lean hardest on AI coding tools right now. They are using them to move fast, to punch above their weight. That means more surface area, more agents running with broader permissions, and less time to audit every file in every working directory before firing up a session.

If a Codex agent registers a malicious server in ~/.codex/config.toml, that server loads in every future Codex session, in any folder, until someone notices. On a busy team, that could be weeks. By then, every API call, every token, every bit of context the agent has touched may have been mirrored elsewhere.

What to Do Right Now

A few concrete steps your team can take today:

Audit your agent config files. Look at ~/.codex/config.toml, .claude/settings.json, and any global configuration your AI coding tools maintain. If you see servers or endpoints you don't recognize, assume compromise and rotate all credentials that agent has ever touched.

Read every AGENTS.md and CLAUDE.md you didn't write. Before your coding agent runs a project, open the instruction file yourself. If it asks the agent to install packages, register servers, or touch global config, that's a red flag. Legitimate project setup files don't need to reach outside the project directory.

Never start a coding agent from ~/Downloads. It sounds obvious now. Make it a written team rule. Start agents from project directories you control, with codebases you trust. Downloads is a staging area, not a workspace.

Treat Downloads like a quarantine zone. Review what you extracted before you extract it somewhere an agent will read. Files you download from unknown sources belong in dedicated staging directories, not in places where agents roam.

Rotate tokens and API keys on any machine that may have been exposed. This includes your AI API keys, cloud credentials, GitHub tokens, and SSH keys. A captured session token can often be replayed long after you've addressed the underlying issue.

The Bigger Shift

AI coding agents have changed the attack surface in a way most teams haven't fully processed. The old model: attackers try to run code on your machine. The new model: attackers write instructions for an AI that runs code on your machine, and the AI does not distinguish between your instructions and theirs.

Instruction injection through project files, malicious repos, and planted downloads is becoming the phishing of the AI development era. The hooks are invisible, execution is automatic, and the agent helpfully reports success.

Full technical writeup via CSO Online. Help Net Security's coverage.

This is exactly the kind of attack surface we audit when we help teams set up AI tooling. If your developers are using AI coding agents and you haven't done a config review, it's worth doing before someone else does it for you.

CivSafe — Strategic Innovation. Community Impact.