Coding agent prompt injection explained: how READMEs, issues and MCP output steer an agent, documented 2025-2026 incidents, and the controls that hold up.
Prompt injection in a coding agent happens when text the agent reads, such as a README, issue, dependency output or MCP tool result, is treated as an instruction. Because the model can't reliably separate data from commands, the defense is architectural: sandbox execution, keep secrets out of reach, limit network egress, and require human approval for consequential actions. Running a local model doesn't change this.
- LLM01, Prompt Injection
- Up to 84% (Copilot, Cursor)
- Max 2 of 3: untrusted input, sensitive access, external actions
- No
Key takeaways
- OWASP lists prompt injection as LLM01 and separates direct injection (the user's input) from indirect injection (files, pages and tool output the model ingests).
- A 2025 academic study of Copilot and Cursor, built on 314 payloads, reported attack success rates of up to 84% for malicious command execution.
- Documented 2025-2026 cases include a GitHub MCP data leak, a Cursor README attack, a maintainer-planted instruction in a library's test output (jqwik), and a GitHub Agentic Workflows leak.
- The mitigations that hold are controls outside the model: sandboxes, least-privilege tokens, egress limits, and approval gates. Guardrail prompts and denylists alone don't.
- A local model removes the cloud provider from the data path, not the injection risk. The attack works on whatever model reads the text.
What is prompt injection in a coding agent?
Prompt injection in a coding agent is untrusted text that the agent reads and then treats as an instruction. OWASP’s LLM01 entry defines it as input that alters a model’s behavior in unintended ways, and splits it into two kinds. In direct injection, the user’s own input changes the behavior. In indirect injection, the model ingests external content, such as a website or file, that contains instructions.
Coding agents are mostly an indirect-injection problem. They read files, dependency output, issues and web pages, and they hold tools that matter: a shell, a file system, git credentials, network access. In a chat window, a successful injection produces bad text. In an agent, it can produce a command.
The root cause is structural. Simon Willison’s lethal trifecta write-up puts it plainly: LLMs follow instructions wherever they appear in context and can’t reliably tell trusted instructions from malicious ones embedded in content. His comparison to guardrail products that claim to stop “95% of attacks” is worth keeping: in web security, 95% is a failing grade.
Where does untrusted input enter a coding agent?
Untrusted input enters through anything the agent reads that you didn’t write. That is more than it sounds like, because agents read automatically and at volume.
- Repository files. READMEs, contributing guides, code comments, config files and agent instruction files such as AGENTS.md in a repo you just cloned.
- Issues, PRs and commit messages. Anyone can file an issue on a public repo, and an agent asked to triage issues will read all of them.
- Dependency and tool output. Test runner output, build logs, package install messages and error text all flow back into the model’s context.
- Web pages and docs. Anything fetched during research or while following setup steps.
- MCP tool descriptions and results. A connected server’s descriptions and responses are context the model acts on. Anthropic’s own security docs note that it does not security-audit MCP servers and encourages writing your own or using ones from providers you trust.
- Images and other media. Multimodal agents read pixels too, so any referenced image is input.
The pattern across all of them: the reader isn’t the author, and the agent doesn’t know the difference.
What incidents and research have documented it?
Documented cases now cover research, vendor disclosures and one deliberate in-the-wild stunt. None of the following needs an attack string to explain, and this page doesn’t include any.
| Date | Case | Pattern | Source |
|---|---|---|---|
| May 2025 | GitHub MCP server leak, found by Marco Milanta and Luca Beurer-Kellner | An issue in a public repo steered an agent with access to private repos into writing private data into a public PR | Willison |
| Jul 2025 | Cursor README attack, HiddenLayer | Hidden instructions in a README; command denylist bypassed; tools chained to exfiltrate data. Patched in Cursor 1.3 | HiddenLayer |
| Sep 2025 | AIShellJack study, 314 payloads against Copilot and Cursor | Poisoned development resources; up to 84% attack success for malicious command execution | arXiv 2509.22040 |
| May 2026 | jqwik 1.10.0 on Maven Central | Maintainer put an agent-targeted instruction in runtime output, hidden from humans with terminal control codes | Snyk |
| Jun 2026 | Mozilla 0DIN proof of concept | Clean-looking repo whose setup steps led an agent to fetch and run a payload at runtime, so nothing malicious was in the repo to scan | Help Net Security |
| Jul 2026 | GitLost, Noma Labs | A public issue steered a GitHub Agentic Workflow with cross-repo read access into publishing restricted content; a small wording change got past the guardrails | InfoQ |
The jqwik case is the one that shows intent. Per Snyk, a maintainer shipped a release that told coding agents to destroy work, then softened it after backlash, and at least one major agent recognized the instruction and refused to act. No credentials were stolen. It is still the first clear case Snyk knew of where a maintainer used prompt injection as a supply chain weapon.
For context on prevalence, a Google team that swept a public web archive for known injection patterns in early 2026 found mostly pranks, SEO manipulation and false positives, with only a small number of exfiltration or destruction attempts and limited sophistication. The same post reported the malicious category growing by a relative 32% between November 2025 and February 2026 (Google). In other words, the threat is real and the attackers are still early.
We build CandorNo GPU? Use a hosted model
Uncensored AI, right in your browser.
Candor runs open models with refusals removed, so it answers the questions other assistants deflect. New accounts get free credits, no card needed.
Try Candor freeWhat do developers report in practice?
Developers report that the most dangerous variable is how much an agent is connected to, not how clever the payload is. These are community reports, quoted for color and not run as tests by this site.
- In the Hacker News threads on jqwik, one commenter argued the stunt stayed contained only because the library is niche, and that the same move on a popular dependency would be a serious supply-chain event (HN comment). Another pointed out that a payload could sit in a transitive dependency the user never chose, and fire when an agent is asked to debug a project (HN comment).
- A third thread ran in the opposite direction: a commenter argued the specific jqwik trick wouldn’t work on modern models (HN comment). That is plausible for one payload and one model. It is not a defense, since the attacker iterates and you don’t see the attempts.
Which mitigations actually work?
A commenter on the Hacker News launch thread for a rootless agent sandbox noted that a policy of read-only everywhere with writes only to the current directory prevents accidental damage such as a hallucinated rm -rf ~, but not injection, because it leaves SSH keys readable (HN comment). Commenters on the GitLost coverage made the same point from the other side: the risk is an agent wired to too much context and too-broad tokens, and a small wording change moved the request across the guardrail’s decision boundary (InfoQ). That is why the mitigations that work sit outside the model and limit what a hijacked agent can reach. OWASP’s own list includes least privilege, human approval for high-risk actions, segregating external content and adversarial testing, alongside constraining model behavior and filtering. The first group is enforced by software. The second relies on the model behaving.
| Control | What it stops | Cost / caveat |
|---|---|---|
| OS-level sandbox for shell commands | A hijacked command touching files or network outside allowed bounds | Setup time. Anthropic’s docs say the sandbox holds regardless of what the model chose to run, but reads are open by default, and built-in tools, MCP servers and hooks run outside it |
| Network egress allowlist | Data leaving to an attacker’s server | Breaks tools that need arbitrary hosts |
| No secrets in the agent’s environment | Credential theft even after hijack | Needs a credential proxy or short-lived tokens |
| Least-privilege tokens, one repo at a time | Cross-repo leaks like the GitHub MCP and GitLost cases | Less convenient than one broad token |
| Human approval for shell, network and git push | Consequential actions you didn’t intend | Prompt fatigue. Allowlist safe commands and keep prompts for the rest |
| Disposable VM or container | Persistence and lateral movement | Slower start. Anthropic’s best-practice list for untrusted content includes running tool calls in VMs |
| Command denylists, system-prompt rules | Little on their own: HiddenLayer’s Cursor research bypassed a denylist | Cheap, so fine as an extra layer, never the main one |
Two design rules are worth memorizing. Willison’s lethal trifecta: don’t give one agent private data access, untrusted-content exposure and external communication at once. Meta’s Agents Rule of Two (October 2025) formalizes the same idea: until injection can be reliably detected, an agent in a single session should satisfy no more than two of three properties: it processes untrusted inputs, it accesses sensitive systems or private data, and it can change state or communicate externally. If a task needs all three, the source suggests a fresh session or human supervision.
The Mozilla finding adds one more: approval prompts help only if you can see what a command will actually do at runtime. Their recommendation is to treat setup scripts from unfamiliar repos as untrusted code even when the agent suggests running them.
Does running a local model help?
No. A local model keeps your code off a third party’s servers, but the injection works on whatever model reads the text. The mechanism Willison and OWASP describe is a property of how LLMs process context, not of where they run.
This is an inference from those sources, not a measurement. There’s also a specific caution for readers of this site. Abliterated and heavily fine-tuned open models have had refusal behavior removed or altered, and nothing guarantees that their resistance to injected instructions is better than the base model’s. Test your own model on your own workflows before assuming it is. Our local coding agent setup guide and Claude Code with a local model pages cover the tooling. The sandbox and egress rules above apply to them unchanged, and arguably matter more when the agent runs with your user’s full local permissions.
What is the checklist for teams adopting coding agents?
Start with blast radius, then add friction where it counts.
- Inventory what the agent can reach. Files, env vars, tokens, MCP servers, network. List them.
- Run it in a sandbox or disposable environment, and deny reads of
~/.ssh, cloud credential files and similar paths explicitly. - Scope tokens per task. One repo, read-only unless a write is needed, short-lived.
- Apply the Rule of Two per session. If an agent reads public issues, it shouldn’t also hold private-repo write access.
- Gate consequential actions. Shell execution of unfamiliar commands, network calls, pushes and deletions need a human, with the real command visible.
- Treat unfamiliar repos and new dependencies as untrusted. Read setup steps before the agent runs them. Check CI and agent logs for unexpected text after dependency updates.
- Review diffs. Look for unexplained deletions and new outbound calls in agent-authored commits.
- Pin and review MCP servers. Prefer ones you wrote or can audit, and keep the list short.
- Run adversarial tests on systems you own, with authorization, as part of security research work or AI pentesting programs, never against third-party repos.
- Keep tools updated. Several of the cases above were patched by vendors after disclosure.
FAQ
What is prompt injection in AI coding agents?
It is the use of text in files, issues, dependency output or tool results to make an agent follow instructions its user didn’t give. OWASP calls the file-and-tool version indirect prompt injection.
Can prompt injection be fully prevented?
Not with current techniques. Guardrails reduce success rates, but they are probabilistic, so teams rely on sandboxing, least privilege and approval gates that limit damage when one succeeds.
Is MCP prompt injection different from other kinds?
The mechanism is the same, but MCP widens the surface: tool descriptions and tool results both enter the model’s context, and an agent with several servers may combine private data, untrusted content and outbound access. Anthropic’s docs advise using MCP servers you wrote or trust.
Does a sandbox stop prompt injection?
It doesn’t stop the model from being steered, but it limits what a steered shell command can touch. Per Anthropic’s docs, it doesn’t cover built-in tools, MCP servers or hooks, and reads are open by default unless you configure denies.
Are local LLMs safer against prompt injection?
They are more private, not necessarily safer. The vulnerability is in how the model treats context, so run local agents with the same sandbox, egress and approval controls as hosted ones.
We build CandorSkip the setup
Want an uncensored model without hosting one?
Candor (candorai.dev) is an uncensored AI chat app that runs in your browser: it answers the questions mainstream assistants dodge, on health, money, law and work, without the lecture. New accounts get free credits, no card needed.
Facts from candorai.dev, checked Nov 10, 2026. Candor never changes how we rank or review models. Disclosure.
Sources (10)
- LLM01:2025 Prompt Injection, OWASP Gen AI Security Project
- "Your AI, My Shell": Demystifying Prompt Injection Attacks on Agentic AI Coding Editors, arXiv 2509.22040
- GitHub MCP exploited: accessing private repositories via MCP, Simon Willison (May 26, 2025)
- The lethal trifecta for AI agents, Simon Willison (Jun 16, 2025)
- Agents Rule of Two: A Practical Approach to AI Agent Security, Meta AI (Oct 31, 2025)
- How hidden prompt injections can hijack AI code assistants like Cursor, HiddenLayer (Jul 31, 2025)
- jqwik 1.10.0 protestware and prompt injection, Snyk (May 2026)
- Mozilla warns of indirect prompt injection risk in AI coding agents, Help Net Security (Jun 29, 2026)
- GitLost: prompt injection leaks private repo data via GitHub Agentic Workflows, InfoQ (Jul 23, 2026)
- Claude Code security and sandboxing documentation, Anthropic
Written by Refusal Rate editors from papers, model cards, official docs and pricing pages. Anything we ran ourselves is labeled as our own test, with the hardware and settings. Our method.