- by x32x01 ||
An ordinary-looking Markdown file can create a serious security problem when an AI coding agent treats its contents as trusted instructions. In October 2026, security researchers at Forever Security reported finding a malicious AGENTS.md file on a customer's computer that attempted to make OpenAI Codex install malware.
The attack is especially concerning because the file doesn't need to be an executable. It's a text file that can influence what an AI agent does when it starts working in a directory.
Let's break down what happened, how Codex and Claude Code were affected, and what you can do to protect your machine.
Developers can place it inside a project to tell an agent how to work, including:
That's useful when the file comes from a trusted developer. But it becomes a security risk when someone else controls its contents.
An attacker can hide malicious instructions inside an ordinary-looking document, hoping the AI agent will follow them without the user realizing what's happening.
The important detail is that the user doesn't necessarily need to open the downloaded file manually. The risk appears when the AI agent starts working in the directory containing it.
One important clarification: Forever Security demonstrated that a website could silently download a file in this way, but the researchers did not establish how the original malicious file actually arrived on the customer's computer.
It instructed the agent to install an npm package called
The company's security product detected the attempt and blocked it before the malicious code executed on the customer's machine.
The package was subsequently removed from npm.
This is what makes the incident particularly interesting: the attacker didn't need to trick the user into running a suspicious executable directly. Instead, the attacker attempted to use the AI agent as the mechanism for installing and executing malicious software.
The researchers took the actual malicious [AGENTS.md] file recovered from the customer's machine and tested it inside an isolated virtual machine.
According to their report:
This distinction matters: the 90% figure describes the researchers' experimental setup, not a guaranteed infection rate for every Codex user.
Instead of relying on the original Codex attack file, the researchers created a separate malicious
The instructions attempted to modify Claude Code's settings, redirecting API requests through a server controlled by the attacker.
This could expose authentication tokens and potentially allow an attacker to impersonate the user's session.
Forever Security reported that the settings modification succeeded in roughly half of its attempts.
The important difference is that this was a separate experimental scenario, not evidence that the original customer's
It's that an attacker may be able to change the agent's configuration and influence what happens in future sessions.
Consider these potential consequences:
This changes how we should think about AI coding agents.
They aren't just autocomplete tools. They can read files, execute commands, install dependencies, modify configurations, and interact with external services.
Giving an agent access to these capabilities without appropriate restrictions can turn a simple instruction file into a serious security threat.
Don't start your coding agent inside your general Downloads folder.
Instead, create a dedicated directory for your development projects and open the agent inside the specific project you're working on.
For example:
This reduces the risk of an unrelated file in Downloads being treated as trusted project instructions.
Pay particular attention to:
Read their contents and look for suspicious instructions, especially requests to:
Look for unfamiliar MCP server entries or configuration changes you didn't make.
If you use Claude Code, inspect:
Pay particular attention to unexpected
An unfamiliar server or endpoint doesn't automatically mean your machine is compromised, but it deserves investigation.
Keep approval requirements and sandbox restrictions enabled whenever possible.
Be especially suspicious of instructions asking the agent to:
Take additional precautions:
The problem isn't necessarily that Codex or Claude Code has a traditional software vulnerability. It's that these agents are designed to follow instructions and perform tasks, sometimes with access to powerful system capabilities.
A malicious instruction file can exploit that trust.
The lesson is simple: Never give an AI agent unrestricted trust just because it appears to understand what it's doing.
Treat your AI coding agent like a powerful developer working on your machine. Give it only the permissions it needs, review its actions, and keep security restrictions enabled.
An AI agent can save you hours of work, but one bad instruction could cost you much more.
📌 Share this article with developers who use Codex, Claude Code, or other AI coding agents. A simple security precaution could prevent a serious compromise.
The attack is especially concerning because the file doesn't need to be an executable. It's a text file that can influence what an AI agent does when it starts working in a directory.
Let's break down what happened, how Codex and Claude Code were affected, and what you can do to protect your machine.
🔍 What Is AGENTS.md, and Why Does It Matter?
AGENTS.md is a Markdown file used to provide instructions to AI coding agents.Developers can place it inside a project to tell an agent how to work, including:
- Which coding standards to follow.
- Which tools and commands to use.
- How the project is organized.
- Which files to modify or avoid.
- How to run tests and build the project.
That's useful when the file comes from a trusted developer. But it becomes a security risk when someone else controls its contents.
An attacker can hide malicious instructions inside an ordinary-looking document, hoping the AI agent will follow them without the user realizing what's happening.
⚠️ How Did the Downloads Folder Become an Attack Vector?
The attack relies on combining two things:- A website can trigger a file download into the browser's Downloads folder without requiring the user to manually save the file.
- An AI coding agent may automatically read instruction files in the directory where it starts working.
- A malicious website
The attacker gets a specially crafted [AGENTS.md] file downloaded into the user's Downloads folder. - The user opens Codex
The user starts Codex inside Downloads and gives it an ordinary coding task. - The agent reads the instructions
Codex discovers the malicious file and processes its instructions. - The agent changes its configuration
The instructions attempt to register an attacker-controlled MCP server and install a malicious npm package. - The attack can persist
Changes to machine-wide configuration can affect future Codex sessions, even when the user moves to another project.
The important detail is that the user doesn't necessarily need to open the downloaded file manually. The risk appears when the AI agent starts working in the directory containing it.
One important clarification: Forever Security demonstrated that a website could silently download a file in this way, but the researchers did not establish how the original malicious file actually arrived on the customer's computer.
🦠 What Malware Was the AI Agent Trying to Install?
The suspicious file discovered by Forever Security targeted OpenAI Codex.It instructed the agent to install an npm package called
function-color, which researchers identified as malicious and associated with a malware campaign.The company's security product detected the attempt and blocked it before the malicious code executed on the customer's machine.
The package was subsequently removed from npm.
This is what makes the incident particularly interesting: the attacker didn't need to trick the user into running a suspicious executable directly. Instead, the attacker attempted to use the AI agent as the mechanism for installing and executing malicious software.
🧪 What Happened When Researchers Tested Codex and Claude Code?
Forever Security tested the technique against two popular AI coding agents. The results showed that both tools could be manipulated, although the attack worked differently in each case.1. OpenAI Codex: More Than 90% Success in Testing
The researchers took the actual malicious [AGENTS.md] file recovered from the customer's machine and tested it inside an isolated virtual machine.
According to their report:
- Codex followed the malicious instructions and executed the test payload in more than 90% of attempts.
- The instructions attempted to add an MCP server to the machine-wide configuration file
~/.codex/config.toml. - The configuration change could affect subsequent Codex sessions, regardless of which project the user opened.
- The attack attempted to install the malicious
function-colorpackage.
This distinction matters: the 90% figure describes the researchers' experimental setup, not a guaranteed infection rate for every Codex user.
2. Claude Code: A Different Way to Exploit the Agent
Claude Code was more difficult to manipulate.Instead of relying on the original Codex attack file, the researchers created a separate malicious
CLAUDE.md file to test another technique.The instructions attempted to modify Claude Code's settings, redirecting API requests through a server controlled by the attacker.
This could expose authentication tokens and potentially allow an attacker to impersonate the user's session.
Forever Security reported that the settings modification succeeded in roughly half of its attempts.
The important difference is that this was a separate experimental scenario, not evidence that the original customer's
AGENTS.md file directly compromised Claude Code.🔥 Why Is This Attack More Dangerous Than It Looks?
The biggest concern isn't simply that an AI agent might execute one malicious command.It's that an attacker may be able to change the agent's configuration and influence what happens in future sessions.
Consider these potential consequences:
| Risk | What could happen |
|---|---|
| Malware installation | The agent installs and runs malicious packages. |
| Configuration manipulation | An attacker adds an unauthorized MCP server. |
| Token theft | Authentication credentials may be exposed. |
| API traffic redirection | Requests may pass through an attacker-controlled server. |
| Persistent compromise | Malicious settings may affect future sessions. |
They aren't just autocomplete tools. They can read files, execute commands, install dependencies, modify configurations, and interact with external services.
Giving an agent access to these capabilities without appropriate restrictions can turn a simple instruction file into a serious security threat.
🛡️ How to Protect Yourself From Malicious AI Agent Instructions
If you use Codex, Claude Code, or another AI coding agent, follow these precautions.1. Never Run AI Agents Directly From Downloads
This is the most important recommendation.Don't start your coding agent inside your general Downloads folder.
Instead, create a dedicated directory for your development projects and open the agent inside the specific project you're working on.
For example:
Bash:
mkdir -p ~/Projects/my-project
cd ~/Projects/my-project 2. Inspect AGENTS.md and CLAUDE.md Files
Before allowing an AI agent to work in a project, check for instruction files you didn't create.Pay particular attention to:
AGENTS.mdCLAUDE.md- Unexpected configuration files inside
.claude.
Read their contents and look for suspicious instructions, especially requests to:
- Install unfamiliar npm packages.
- Execute remote scripts.
- Modify global configuration files.
- Send tokens or credentials to external servers.
- Disable security restrictions.
3. Check Your AI Agent Configuration
If you use Codex, inspect its configuration file:~/.codex/config.tomlLook for unfamiliar MCP server entries or configuration changes you didn't make.
If you use Claude Code, inspect:
.claude/settings.jsonPay particular attention to unexpected
ANTHROPIC_BASE_URL settings or API endpoints.An unfamiliar server or endpoint doesn't automatically mean your machine is compromised, but it deserves investigation.
4. Keep Approval Prompts and Sandboxing Enabled
Don't disable security features just because an instruction file tells you to.Keep approval requirements and sandbox restrictions enabled whenever possible.
Be especially suspicious of instructions asking the agent to:
- Execute commands without approval.
- Bypass sandbox restrictions.
- Run scripts with elevated privileges.
- Ignore security warnings.
5. Rotate Credentials if You Find Evidence of Compromise
If you discover a malicious instruction file or unauthorized configuration changes, don't simply delete the suspicious file and assume everything is safe.Take additional precautions:
- Stop the affected AI agent.
- Investigate unauthorized configuration changes and processes.
- Remove malicious server entries and suspicious packages.
- Revoke and replace potentially exposed API keys and authentication tokens.
- Review your account activity and check for unauthorized access.
function-color installed as part of this attack, treat the machine as potentially compromised and investigate it carefully.💡 Final Thoughts
This incident highlights a growing security challenge with AI-powered development tools.The problem isn't necessarily that Codex or Claude Code has a traditional software vulnerability. It's that these agents are designed to follow instructions and perform tasks, sometimes with access to powerful system capabilities.
A malicious instruction file can exploit that trust.
The lesson is simple: Never give an AI agent unrestricted trust just because it appears to understand what it's doing.
Treat your AI coding agent like a powerful developer working on your machine. Give it only the permissions it needs, review its actions, and keep security restrictions enabled.
An AI agent can save you hours of work, but one bad instruction could cost you much more.
❓ Frequently Asked Questions
----------------------Can an AGENTS.md file execute malware by itself?
No. It's a plain-text instruction file, not an executable program. However, an AI agent that reads it may follow malicious instructions that cause it to execute commands or install harmful software.Is OpenAI Codex vulnerable to this attack?
Forever Security demonstrated that a specially crafted instruction file could manipulate Codex under the tested conditions. The researchers attributed the attack to how agents handle trusted instructions and their working directories, rather than identifying a conventional Codex software vulnerability.Can Claude Code also be affected?
Yes. Forever Security demonstrated a separate attack using a malicious CLAUDE.md file that attempted to redirect API requests and expose authentication tokens.Is it safe to use AI coding agents?
Yes, provided you use appropriate security precautions. Work inside trusted project directories, inspect instruction files, keep approval prompts enabled, and avoid granting unnecessary permissions.Should I delete AGENTS.md from every project?
No. Legitimate projects use AGENTS.md to provide useful development instructions. The important thing is to verify that the file comes from a trusted source before allowing your agent to follow it.📌 Share this article with developers who use Codex, Claude Code, or other AI coding agents. A simple security precaution could prevent a serious compromise.