AGENTS.md Malware Threats AI Coding Agents

A malicious AGENTS.md file is a new threat vector for AI coding agents. Learn how attackers exploit local trust models and how to secure your development e

A developer typing on a laptop in a quiet home office with coffee cup nearby

Intro

A malicious AGENTS.md file sitting in a developer’s Downloads folder is now a genuine threat vector for AI coding agents. This local markdown malware technique targets the specific trust model built into tools like OpenAI Codex and Claude Code. When an agent initializes in a directory, it reads plain-text instruction files to configure its environment. Attackers are exploiting this behavior by planting files that look like ordinary engineering notes but contain commands to install malicious packages. Forever Security recently documented this attack against a real customer’s machine. They stopped the agent before the payload executed. The core issue is that web pages can silently download files into the Downloads directory without user interaction. If a developer runs an AI agent directly out of that folder, the agent treats the malicious file as legitimate project instructions.

This is not a typical malware infection where a binary executes from a suspicious source. Instead, the attack bypasses traditional software checks by using the agent’s core design against itself. The agent is built to obey the instructions in the folder it opens. A malicious web page can drop a file named AGENTS.md into the Downloads folder. When a developer starts their coding agent there, the agent reads the file and follows the embedded commands. In the case documented by Forever Security, the file instructed the agent to add a specific server to its configuration and install a malicious npm package called function-color. This package is part of the MALFEX campaign, which pulls in a downloader and fetches a Windows payload. The entire chain relies on the agent automatically trusting the local file and the user accidentally starting the agent in an untrusted location.

I run VPS hosting services and manage server environments for clients. I have seen enough social engineering attacks to know that “users will make mistakes” is a fundamental security assumption. But the automation of that mistake by AI agents changes the risk profile significantly. A human might hesitate to run an unknown executable. An agent, however, is programmed to parse and execute instructions found in the current working directory. This creates a direct path for silent browser drive-bys. You click a link on a phishing page, a file downloads silently, and later when you open your AI coding assistant in that directory, it follows the hidden orders. There is no pop-up warning that a security context has shifted. The agent simply starts working, reading the config, and installing the package. The attack is elegant precisely because it uses the developer’s own tooling to execute the malicious code.

Forever Security noted that they could not determine exactly how the file got into the customer’s folder in the specific incident. However, they proved the vector was feasible by building a proof-of-concept web page that auto-downloads the malicious AGENTS.md file. The company emphasized that this is not a bug to be patched by OpenAI or Anthropic. The agent is doing what it was designed to do. It is following the local instructions. The vulnerability lies in the user’s workflow, specifically running agents in directories that the web can write to without permission prompts. The report highlights that this threat is currently emerging and will likely evolve as attackers find more ways to exploit the gap between automated code generation and human oversight. Understanding this attack vector is critical for any developer who uses local AI assistants daily.

For more details on the technical breakdown of the MALFEX campaign, see the original report from The Hacker News (opens in new tab).

Background on AI Coding Agents

To understand why a plain-text markdown file can become a vector for code execution, you have to look at how modern AI coding assistants actually start their work session. Tools like OpenAI’s Codex and Anthropic’s Claude Code do not arrive at a project with a blank slate. They actively scan the current directory for specific instruction files before they begin writing a single line of code. For Codex, this file is AGENTS.md. For Claude Code, it is CLAUDE.md. These files serve as the project’s local system prompt. They tell the agent what the stack is, how to run tests, which linters to use, and how to interact with the repository. It is a convenient feature that saves developers from repeating themselves in every single chat session. You write the rules once, and the agent persists them across all future interactions in that folder.

The power of these files comes from their location. They sit right next to the source code. When you open a terminal in a project directory and launch the agent, it ingests these instructions immediately. The assumption built into this workflow is that the directory is trusted. You cloned the repo from a verified source, or you initialized the project yourself. The agent treats the AGENTS.md file exactly like a senior engineer’s handwritten notes left on the desk. It follows them. If the file says “install dependency X,” the agent runs the command. If it says “set environment variable Y,” the agent modifies the shell context. There is no separate approval layer for the initial ingestion of these instructions because the tool assumes the file was authored by the human user.

This design creates a specific blind spot when combined with how browsers handle file downloads. Most developers are used to the standard security model: websites ask for permission to download files, or the download happens into a known, managed directory. However, certain web technologies allow pages to trigger silent file writes to the default Downloads folder without a user click or a permission prompt. This is not a new vulnerability in itself, but it is rarely a security concern because the files downloaded by the web are usually static assets, images, or documents that a human opens manually. They are not executable instructions for an autonomous agent.

When you merge these two facts, the local AGENTS.md file stops being just documentation and becomes a potential command channel. A web page can write a file named AGENTS.md into your ~/Downloads directory while you are working on something else. If you later open your AI coding assistant in that directory, thinking you are working on a different project or just exploring a folder, the agent will read that file. It will see instructions that look like routine setup. It will execute them. The file looks harmless because it is just markdown. But markdown is the interface through which the agent receives orders. This is why the threat model shifts from “blocking bad software” to “managing where the agent starts.” The agent is doing its job, but it is working in a location that was not secure by design.

What’s happening now with MALFEX

The attack vector described in the Forever Security report (opens in new tab) ties directly into a broader malware campaign named MALFEX, which researchers at CloudSEK and Checkmarx documented earlier. The campaign relies on a malicious npm package called function-color. When a developer or an agent installs this package, it pulls in a dependency named function-flag. This second package is the actual payload delivery mechanism. It fetches and executes a Windows binary that establishes persistence and steals credentials. The beauty of this supply chain attack for the adversary is that function-color appears to be a legitimate utility for handling color codes in console outputs, making it plausible within a development context.

In the specific incident Forever Security observed on a customer’s machine, the planted AGENTS.md file instructed the coding agent to perform two actions. First, it told the agent to modify the global Codex configuration file located at ~/.codex/config.toml. The instruction was to register a new server block, pointing the agent’s communication traffic to an external IP address controlled by the attackers. Second, it directed the agent to install the malicious function-color package via npm. Because the Codex configuration file is global, any modification to it persists across all future sessions on that machine, not just the one running in the Downloads folder. This means that even if the developer closes the current terminal and starts a new project in their Documents or Projects directory, the agent will still route its requests through the attacker’s server. The initial execution of the npm install triggers the malware, but the config change ensures the backdoor remains active and stealthy for subsequent interactions.

Forever Security tested this specific payload against OpenAI’s Codex agent in an isolated virtual environment. The results were stark. In over 90% of test attempts, Codex successfully executed the instructions in the AGENTS.md file, registered the malicious server, and ran the npm install command. The agent treated the detailed engineering notes in the markdown file as trusted internal documentation. It did not question the authority of the file simply because it was found in a generic Downloads directory. The agent’s trust model is based on the assumption that files within the working directory are part of the project being analyzed. Since the working directory was not secure, the trust was misplaced.

The attack against Anthropic’s Claude Code worked differently and was less effective, succeeding only about half the time. The attackers planted a CLAUDE.md file that attempted to write an ANTHROPIC_BASE_URL into the project settings file, effectively hijacking the API endpoint to leak the session’s login token. Claude Code’s safety layer requires human approval for file writes that seem out of context. However, when the instructions were wrapped in lengthy, plausible-sounding technical documentation about “internal gateway configuration,” users often approved the changes. This highlights a critical operational failure: human reviewers are too fatigued to distinguish between legitimate project setup and malicious configuration poisoning when both are written in dense, technical prose. The token leak is particularly damaging because it grants the attacker a live session that can impersonate the user, not just execute a single malicious command.

What it means in practice for developers

The most frustrating part of the Forever Security report (opens in new tab) is that it highlights a gap that cannot be closed with a traditional software patch. If a browser renders a phishing page, the vendor can update the browser engine or flag the URL. But here, the coding agent is not failing. It is succeeding. It is doing exactly what it was programmed to do, which is trust the instructions file in the current working directory and execute the commands found within. From the perspective of OpenAI or Anthropic, the local filesystem is not their responsibility. They cannot assume that a developer has not left a malicious text file in their home directory. This places the entire burden of security on the individual user or the IT admin, who must understand the subtle difference between a project repository and a generic download destination.

Forever’s internal telemetry data suggests this risk is not theoretical. They found that nearly half of their customers regularly spin up coding agents inside their Downloads directories. If that number is accurate, a significant portion of the developer population is running an automated system with terminal access in a location that the web can write to without any user permission prompt. The web browser can save a file to Downloads on its own. It does not need to ask you. It just does. If an agent is currently running in that folder, it will pick up the new file.

This means you need to check specific configuration paths on your local workstations right now. For Codex users, you should inspect ~/.codex/config.toml. You are looking for any server blocks or remote endpoints that you did not explicitly add yourself. If you see a URL pointing to a random domain or a suspicious IP address, that is a smoking gun. The file might have been modified during a previous session where an agent was tricked into running a configuration command. For Claude Code users, the risk is slightly different but equally dangerous. You need to check the project-specific settings, often located in .claude/settings.json within the repository you are working on. Look for any ANTHROPIC_BASE_URL or other API endpoint overrides. If your API traffic is being routed through a third-party server instead of the standard Anthropic endpoint, your session tokens are likely being leaked to an attacker.

Administrators should also verify that their developers are not disabling the standard approval prompts. The attack against Claude Code relied on users quickly approving writes that looked like standard setup. If your team has turned off confirmation dialogs for efficiency, you have removed the last line of defense against this specific type of configuration poisoning. The agent will simply write the malicious URL, and the token will leak before anyone notices.

What to expect next in endpoint security

Security vendors are going to have to start treating plain-text documentation files with the same suspicion they currently reserve for executable binaries. When a tool reads a markdown file and treats its contents as literal commands, that markdown file ceases to be documentation. It becomes executable code in disguise. I expect to see upcoming endpoint detection releases flag unverified markdown files sitting in system download directories or newly cloned repositories, especially when those files contain instructions about installing npm packages or modifying global configuration files.

This creates a massive tension between autonomous developer workflows and the hard reality of configuration poisoning. We want our AI assistants to be helpful, fast, and largely self-directed. We want them to read AGENTS.md and CLAUDE.md files so we do not have to manually explain the project structure every single time we spin up a new terminal window. But that exact design feature is what makes the attack described in the The Hacker News report (opens in new tab) so effective. You cannot easily patch a system that is simply doing what it was programmed to do. If an agent is designed to follow instructions, it will follow a malicious instruction just as easily as a helpful one, provided the framing looks legitimate enough to bypass human review or agent sanity checks.

Local development isolation standards are going to have to adapt to tools that require broad filesystem and terminal read-write access. Right now, most developers run their coding agents directly on their host operating system with their own user permissions. That means if the agent has access to your shell, it has access to your SSH keys, your environment variables, and your global configuration files. Moving forward, I expect more teams to mandate containerized development environments or dedicated virtual machines for AI workflows. If an agent runs inside an ephemeral container, a poisoned config.toml or a leaked token only impacts that specific container rather than compromising the entire workstation.

We are also likely to see agent maintainers introduce explicit trust boundaries for local configuration files. Much like git refuses to run certain configurations in repositories owned by other users, future versions of these coding assistants will probably refuse to parse instruction files that originate from untrusted sources or write to global paths without an explicit confirmation from the user. Until those security guardrails are built natively into the tools, you have to assume that any file in your Downloads directory is potentially hostile. Stop launching your developer tools in unverified directories, and make it a habit to audit your global configuration files before you run your next command.

Closing the gap on local agent security

The most effective countermeasure is not a new software feature, but a strict operational rule: never launch a coding agent from ~/Downloads or any other unverified directory. This folder is the only location on a standard system where a malicious web page can silently write a file without triggering a permission prompt. By keeping your agent away from this area, you break the chain of attack before it begins.

If you have not checked your global configuration files recently, do it now. Open ~/.codex/config.toml and look for any server blocks or base URLs that you did not personally add. For Claude Code users, inspect your project-specific .claude/settings.json files for an ANTHROPIC_BASE_URL variable. These lines are where an attacker would try to redirect your API traffic to a malicious server, allowing them to steal your authentication token and impersonate the model.

Think of it like finding a random .htaccess file in a public-facing web root that you did not create. In web hosting, that file is a clear indicator of compromise or at minimum, unauthorized modification. In the local development environment, a stray AGENTS.md or CLAUDE.md file in a repository you just cloned is the equivalent threat vector. It serves as the entry point for silent configuration poisoning.

If you discover any of these anomalies, assume that your login token has already leaked. A stolen API token is not just a lost request; it is a live session that allows an attacker to access your account and incur usage costs under your name. Rotate your API keys immediately. Do not wait to see if any malicious activity occurs. The cost of rotating a key is minimal, whereas the cost of an account takeover is significant.

The security posture for local development is changing rapidly. The assumption that “local means safe” no longer holds when autonomous agents are interpreting local files as executable instructions. Your security boundary now extends to the trustworthiness of the text files in your working directory. Until agent vendors introduce explicit trust boundaries for local configuration, your discipline is the only defense. Read the instruction files in new repositories before you let an agent parse them. If the file looks like legitimate engineering notes, that is not enough. Check the metadata, check who created it, and check if it belongs to the project you think it does. The gap in local agent security is closed not by a patch, but by your refusal to trust files you did not write.