Malicious AGENTS.md Files Can Hijack AI Coding Agents

AGENTS.md security depends on where an AI coding agent starts and which files the agent can read, modify and execute. A malicious instruction file in a broad directory such as Downloads can direct an agent to install packages, alter configuration or expose credentials. The practical defense is to start agents at a reviewed project root, restrict permissions and treat instruction files as executable policy.

What is the AGENTS.md security risk?

The AGENTS.md security risk is an indirect prompt-injection weakness in which an AI coding agent discovers hostile persistent instructions and acts on them with its available tools. The file may influence shell commands, package installation, configuration changes, network requests and Model Context Protocol connections without exploiting a conventional software vulnerability.

An AGENTS.md file is a plain-text instruction file that gives an AI coding agent persistent guidance for work within a directory scope. OpenAI’s 2026 Codex prompting guide says Codex enumerates applicable instruction files from global configuration and the directory path, inserts their contents into the conversation and is trained to follow them closely.

That behavior is useful in a controlled repository. Teams can record build commands, testing requirements, coding conventions and approval gates once instead of repeating them in every prompt. Trouble starts when the same discovery mechanism crosses into an untrusted folder.

On October 22, 2026, Forever Security disclosed an attack beginning with AGENTS.md in a user’s Downloads directory. BleepingComputer independently reported on October 25, 2026 that a web page could initiate an AGENTS.md download into the browser’s normal download location. Chrome, Microsoft Edge and Firefox showed download notifications during that test, while Brave required approval.

How can a malicious AGENTS.md file hijack a coding agent?

A malicious AGENTS.md file can hijack a coding session when the agent starts in the file’s directory, ingests its instructions and receives permission to perform the requested actions. The 2026 demonstrations used ordinary agent abilities, including running commands, installing npm packages, editing global configuration and creating Model Context Protocol server entries.

The attack chain is short. A browser places the file in Downloads, you launch an agent from that folder, and instruction discovery supplies the hostile text as context. The agent may then present dangerous actions as necessary setup work or attempt changes permitted by its execution mode.

Forever Security reported finding a malicious instruction file on a customer machine after an agent tried to install the npm package function-color. The company could not determine how the file originally arrived, so that incident shouldn’t be presented as proof of browser delivery. The later BleepingComputer test established only that web-triggered placement in the download location was possible.

See also  What to Know About Cybersecurity for Online Lending

The recovered Codex instructions were approximately 13 KB in 2026, according to Forever Security. The directions allegedly tried to change the machine-wide ~/.codex/config.toml, register a Model Context Protocol server and launch a child Codex process with approval and sandbox bypasses.

Forever Security said its Codex reproduction executed the package payload in more than 90% of 2026 attempts. Put concretely, a comparable rate would mean more than 90 successful executions per 100 trials. Independent reproduction of that percentage remained scarce as of October 27, 2026, and no specific public OpenAI or Anthropic response to the disclosure had been located by that date.

Why is this different from a malicious repository exploit?

The AGENTS.md security issue differs from a malicious repository exploit because hostile instructions can be discovered before you open or clone a compromised project. The October 2026 Downloads technique starts with plain text in a broad working directory and relies on intended instruction discovery plus normal agent powers rather than preexisting dependency code execution.

An April 2026 malicious-dependency demonstration assumed that a repository dependency was already compromised and capable of executing code. By contrast, the Downloads scenario turns the agent into the initial interpreter of attacker-supplied directions. No package needs to run before the agent decides to install one.

The distinction matters for threat modeling. Source review and dependency scanning can miss a file sitting outside the repository, while an agent launched one directory too high may inherit instructions that developers never expected to govern the project. Similar cross-agent trust problems appear in the reported AgentCorruption attack against AWS agent environments.

Rule-file poisoning also extends beyond a single filename. The PackHallu study published on October 14, 2026 described malicious prompts in files such as AGENTS.md and .cursorrules that induced agents to substitute attacker-controlled packages. OWASP’s 2026 DevSecOps guidance consequently recommends treating AGENTS.md, CLAUDE.md and comparable rules files as security-sensitive configuration.

How likely is the Downloads-folder attack?

The real-world frequency of malicious AGENTS.md attacks was unknown on October 27, 2026, but exposure to the prerequisite behavior was measurable. Forever Security reported that about half its customers had run a coding agent inside Downloads, while a researcher told BleepingComputer that Claude Code alone appeared in more than 1,300 observed Downloads sessions.

The available numbers measure risky behavior and laboratory success, not a population-wide compromise rate. Forever Security also said roughly one-quarter of observed 2026 agent sessions opened a real browser, creating another route through which an agent could encounter downloads and web content.

Reported 2026 test results and exposure indicators for hostile instruction files
Observation Reported 2026 result What the number establishes
Codex package-payload reproduction More than 90% of attempts High success in Forever Security’s test, not an independently established universal rate
Claude Code API redirection About 50% of attempts Configuration change and OAuth-token exposure in the firm’s setup
Claude Code same-session execution About 20% of attempts Code execution during the original session in roughly one trial out of five
Customers running agents in Downloads About 50% Broad-folder launches were common in Forever Security’s customer observations
Observed Claude Code Downloads sessions More than 1,300 The risky launch pattern occurred repeatedly, according to BleepingComputer’s source
See also  California's Leading Cybersecurity Official Advocates for Reform Following Dismissal

Those results deserve attention, but they also deserve restraint. The Codex and Claude Code success rates came from one security company’s October 2026 testing, with limited public detail about sample sizes and environment variation. Honestly, percentages this dramatic shouldn’t become risk forecasts until other researchers reproduce them.

Browser behavior adds friction rather than a complete defense. Notifications can be overlooked, and a harmless-looking text file doesn’t carry the visual warning users associate with an executable. Comparable trust assumptions have also enabled fake Claude advertising and redirect attacks and the Poper Blocker browser-extension incident.

How do you protect coding agents from malicious instruction files?

Effective AGENTS.md security uses five controls together: project-root scoping, instruction-file review, sandbox isolation, meaningful approval prompts and restricted network access. The safe default in 2026 is a reviewed project directory with only task-required files mounted, no home-directory exposure, no long-lived credentials and no automatic permission bypass.

A useful boundary model starts with one question: what is the smallest directory the task actually requires? BleepingComputer’s 2026 reporting identifies the specific project root as the safe boundary, rather than the home directory, Downloads or a broad parent containing several repositories.

Use the following controls before allowing an agent to run commands:

  • Start the agent from the reviewed project root, and expose additional directories only for a defined task.
  • Review unexpected AGENTS.md, CLAUDE.md, .cursorrules and related files as carefully as scripts or build configuration.
  • Place repository instruction files under code ownership, pull-request review and monitoring for unauthorized changes.
  • Keep sandbox restrictions and approval prompts enabled; Anthropic’s 2026 documentation labels --dangerously-skip-permissions as hazardous.
  • Inspect requests involving package installation, global settings, new Model Context Protocol servers, API endpoint changes or disabled safeguards.

OpenAI’s 2026 sandbox guidance recommends isolating files, credentials and network access, mounting only task-required inputs and avoiding home-directory mounts. Long-lived credentials should remain outside the execution environment, while outbound traffic should be limited to destinations the task genuinely needs.

Approval prompts don’t fix AGENTS.md security by themselves. A user who approves an opaque installation command has confirmed the attacker’s desired action without understanding it. Package names deserve particular scrutiny because agent-assisted substitution has become a recurring route into AI infrastructure, as the PoeLLM malware campaign affecting AI servers illustrates.

Disposable environments provide a sensible exception for permissive modes. If the container has no valuable credentials, no home-directory mount, no unrestricted egress and no path back to production, the blast radius is far smaller. On a developer laptop, skipping permissions is hard to justify.

See also  Charming Kitten APT attempts to infiltrate Israeli cyber specialists

FAQ about AGENTS.md security

Is AGENTS.md itself malware?

An AGENTS.md file is not inherently malware; it is a text-based instruction file for coding agents. The security risk arises when hostile content directs an empowered agent to perform dangerous actions.

Can deleting AGENTS.md stop the attack?

Deleting an untrusted AGENTS.md can remove that instruction source, but you should also inspect global configuration, installed packages, Model Context Protocol entries, child processes and credentials for changes already made.

Does an approval prompt make AI coding agents safe?

An approval prompt reduces risk only when you understand the exact command and its consequences. Requests to install packages, edit global configuration, add servers, redirect APIs or disable safeguards require direct inspection.

Should AGENTS.md be committed to Git?

A legitimate repository AGENTS.md should generally be version-controlled so ownership rules, pull-request review and change history can protect it. OpenAI’s August 3, 2026 Codex workflow guide describes the file as optional persistent repository guidance and recommends explicit scopes, boundaries and approval gates.

EN