Join our Newsletter — 33% off our NHI Course
Home› FAQ› Agentic AI & Autonomous Identity› How do malicious AGENTS.md files influence coding agents?
Agentic AI & Autonomous Identity

How do malicious AGENTS.md files influence coding agents?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 25, 2026 Domain: Agentic AI & Autonomous Identity

Malicious AGENTS.md files can steer coding agents by supplying hidden instructions that change tool use, code edits, file access and network calls. If the agent ingests repository instructions without trust boundaries, the file can redirect it to exfiltrate secrets, alter code or execute unsafe commands during normal development workflows.

How malicious AGENTS.md files change an agent’s behaviour

AGENTS.md is not just documentation when a coding agent treats repository instructions as executable guidance. A malicious file can shift the agent’s priorities before a human reviewer sees the result, changing what it reads, which files it opens, what commands it runs, and whether it follows safe defaults or attacker-supplied instructions instead.

The practical issue is trust boundary collapse. Once the agent accepts repository-local instructions as authoritative, the file can become a control point for tool use and workflow decisions, so the same development task can be redirected into secret collection, unauthorized edits, or unsafe command execution.

What the attacker is trying to achieve

Most malicious AGENTS.md abuse aims to make the agent act as a helper for the attacker, not the developer. That can mean prompting the agent to search for credentials, open sensitive configuration, copy data into logs or comments, or make code changes that look routine but introduce risk later.

Because the file is embedded in the normal developer workflow, the attack often blends into ordinary repository activity. The agent may appear to be obeying project conventions while actually following instructions that widen its access or weaken the review path. AI Coding Agents Security Guide is a useful starting point for understanding why instruction files, sandboxing and secret exposure need to be treated as one problem.

In the worst cases, the file is used to steer tool calls toward destructive or exfiltrating actions, especially when the agent can reach terminals, cloud tools, issue trackers or other connected services. The risk is not that the file is “code” in the normal sense, but that the agent may treat it as a source of authority.

Where the security boundary fails in practice

The failure usually happens when repository instructions are loaded without verifying whether they are trusted, scoped or approved for the current task. If the agent has broad file access, network access or command execution, the malicious instructions can exploit those capabilities without needing a traditional vulnerability in the model itself.

That is why repository instruction files belong in the same defensive conversation as prompt injection, over-scoped tokens and sandbox design. A coding agent that can read local files, call tools and commit changes needs explicit boundaries on which instructions it is allowed to follow. The clearest lesson from real-world abuse is that the instruction channel and the action channel must be separated.

AI Coding Agent Incident Playbook is the right internal reference when you need to think through what to check after a malicious instruction file has influenced agent behaviour, including credential rotation, configuration review and recovery steps.

How to reduce the impact before it becomes an incident

Defence starts with assuming that repository content may be hostile, stale or manipulated. Treat AGENTS.md as an input that needs policy, not as a universally trusted source of operational truth. The agent should not be allowed to expand its privileges, alter its tool scope or ignore safety gates simply because a file in the repo tells it to.

Keep the agent’s effective authority narrow, especially around shell execution, secrets access and outbound network calls. If the task does not require those capabilities, they should be disabled or heavily mediated. This matters most in repos that can be touched by external contributors, forks, package updates or unreviewed documentation changes.

When the workflow depends on local instruction files, pair them with reviewable controls such as explicit allowlists, sandboxing and human approval for sensitive actions. AI Coding Assistant Security Checklist and AI Coding Assistants vs Autonomous Coding Agents both help distinguish low-risk assistance from agents that can actually execute, modify and expose material systems.

OWASP Agentic AI Top 10 is also relevant because instruction-file abuse commonly lands in tool misuse and identity or privilege abuse, which are exactly the failure modes that turn a helpful agent into an unsafe one.

Risk and Threat Considerations

Malicious AGENTS.md files are dangerous because they can turn ordinary repository context into an execution path. The main exposure is not just wrong output, but unauthorised file access, secret leakage, unsafe command execution and unwanted code changes inside trusted developer workflows.

Failure mechanism: The agent ingests repository instructions without a strong trust boundary, then follows attacker-supplied guidance as if it were part of the legitimate task, causing it to widen tool use or change behaviour.

Impact: A successful file can redirect the agent into exfiltrating secrets, modifying code, invoking risky commands or persisting unsafe changes that look like normal development activity.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and MITRE ATT&CK define the specific risk controls and attack patterns relevant to this topic.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI02 — Tool MisuseMalicious repo instructions can steer an agent into unsafe tool actions.
ASI03 — Identity & Privilege AbuseThe attack abuses agent authority and over-broad access to file, network and command tools.
ASI01 — Agent Goal HijackA hostile AGENTS.md file can redirect the agent away from the user’s intended goal.
Recommendation — Restrict tool permissions and require approval for sensitive agent actions. Bind agent authority to least privilege and separate trusted from untrusted instructions. Validate the task objective before executing repository-supplied instructions.
MITRE ATT&CKT1204 — User ExecutionThe file manipulates what the human or agent chooses to run or trust.
T1059 — Command and Scripting InterpreterMalicious instructions can induce unsafe shell or scripting actions during development workflows.
Recommendation — Scrutinize instruction-driven execution paths for hidden attacker influence. Constrain shell access and monitor agent-run commands for unexpected intent.

Practitioner Guidance

What to verify: Confirm whether the agent treats AGENTS.md as advisory text or as an instruction source with execution consequences. If it can change tool scope, file access or outbound requests, you need a trust model, not just a parser.

Decision rule: If the repository can be modified by people who should not be able to steer the agent’s behaviour, do not let instruction files control high-risk actions. Keep the agent in a constrained mode until you know the repo and its contributors are trusted.

Practitioner takeaway: The key control is not blocking AGENTS.md entirely, it is preventing repository-local instructions from becoming authority over sensitive actions, secrets and commands.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org