
How does indirect prompt injection reach your codebase?
Summary
An indirect prompt injection reaches your codebase through content your coding agent reads, not through anything a developer types. An attacker hides instructions in an issue, a pull request, a README, a config file or a web page, and the agent treats them as part of its task.
If that agent can write code, run commands or see secrets, the attacker gets the same reach.
This year researchers showed one GitHub issue or PR title could make the Claude Code, Gemini CLI and Copilot agents leak their own API keys. This guide explains where injected instructions enter a coding agent's workflow, what real attacks have done with them, and the layers that keep an injected agent from doing damage.
What is an indirect prompt injection?
A prompt injection is text that changes what a language model does in a way its operator didn't intend. In a direct injection, the person typing the prompt is the attacker. In an indirect injection, the attacker plants the text somewhere the model will read later.
OWASP's definition is short: indirect prompt injections "occur when an LLM accepts input from external sources, such as websites or files."
Researchers named the attack in 2023, when Greshake and colleagues showed that adversaries could exploit LLM-integrated applications remotely, without a direct interface, by planting instructions in data the application retrieves. Coding agents make the problem sharper.
They read far more outside content than a chat assistant does, and they act on it by editing files, running commands and opening pull requests.
OWASP is also candid about the limits: "it is unclear if there are fool-proof methods of prevention for prompt injection." That shapes the defense. You can't count on the model ignoring every planted instruction, so you limit what an injected agent can reach and review what it produces.
How does an indirect prompt injection reach a coding agent?
Anything the agent reads as context is a way in. For coding agents, these are the four entry points that show up most in real attacks and research:
- Issues, pull requests and comments. Agents that triage issues or review PRs read titles, bodies and comments written by anyone with a GitHub account. Instructions can sit in plain sight or inside an HTML comment that doesn't render on the page.
- Files in the repository. READMEs, docs, test fixtures and agent config files such as CLAUDE.md or AGENTS.md all go into context. A contribution that adds or edits one of these files can carry instructions.
- Dependencies and package docs. When an agent installs a package or reads its documentation to use it correctly, that text becomes context too.
- Web pages and tool output. Agents fetch documentation, search results and API responses. A 2026 study of 1.2 billion URLs found 15,300 validated injection attempts on public web pages, and about 70% sat in parts of the page a person never sees, such as headers, comments and metadata.
The common thread is trust. The agent can't reliably tell the difference between the task its operator gave it and instructions that arrived inside the material it was asked to work on.
What happened in the Comment and Control attacks?
In April 2026, researchers led by Aonan Guan showed that a single piece of GitHub text could turn three popular CI agents against the repositories they served.
VentureBeat reported that Anthropic's Claude Code Security Review action, Google's Gemini CLI Action and GitHub's Copilot agent each leaked credentials, and the Claude Code action posted its own API key as a PR comment.
The attacks worked because of how these workflows run. They trigger automatically on new issues, PRs and comments, so the attacker doesn't need anyone to ask the agent to read the malicious text. Many AI integrations also use the pull_request_target trigger, which gives the workflow access to repository secrets even when the PR comes from a fork.
The research didn't stop there. At Black Hat USA in August, a follow-up showed a pre-approved fetch domain being used to leak an API key one character at a time, and the Cloud Security Alliance's write-up lists the CVEs and fixed versions for Claude Code and Gemini CLI.
Separately, the GitInject study found that every AI provider it tested was open to at least one high-severity attack, including CLAUDE.md files from unmerged contributions being loaded as operator-level instructions.
What can an injected coding agent actually do?
An injected agent can do whatever the agent is allowed to do. That's why the same planted sentence is harmless in one setup and serious in another. In practice, attacks aim for one of four outcomes:
- Steal secrets. Read environment variables, CI tokens or config files, then send them out through a comment, a commit or a web request.
- Change code. Add a backdoor, weaken an access check or pull in a dependency, inside a change that looks like ordinary agent work.
- Change the agent's own setup. Edit a config file or a workflow so the next run starts from the attacker's instructions.
- Hide the trail. Encode stolen data so secret scanning misses it, or post output that looks routine.
In the Copilot case, the payload was hidden in an HTML comment and the stolen token was base64-encoded to slip past secret scanning, then pushed in a git commit. Each step looked like normal activity on its own.
How do you protect a codebase from indirect prompt injection?
No single control stops this, so the goal is layers that each limit the damage. Start with the agents that run unattended in CI, because they read untrusted text with no person watching.
- Separate untrusted input from secrets. Don't give an agent that reads issues, comments or fork PRs access to deployment keys or write tokens. Avoid pull_request_target for AI workflows unless you've locked down what runs.
- Give agents the least privilege that works. Scope tokens to read-only where you can, limit which tools and commands the agent can run, and keep network access to an allowlist.
- Restrict who can trigger an agent. Require a maintainer label or collaborator permission before an agent acts on an issue or PR from outside the team.
- Treat agent config files as code. Changes to CLAUDE.md, AGENTS.md, rules files and workflow files deserve required reviewers, the same as changes to CI.
- Keep a person in the loop for high-risk actions. OWASP lists human approval for high-risk actions among its core mitigations. Merges, releases and anything touching credentials are good places to require it.
- Review everything the agent produces. Every agent change should arrive as a pull request and get a security review against how your codebase works. That's where a planted instruction that slipped through shows up as a real code change.
That last layer matters because it doesn't depend on catching the injection itself. Whether the agent was steered by an issue, a README or a web page, the result lands in a diff. We looked at the reviewer side of this problem, including injections aimed at AI reviewers, in Prompts in the Pipeline: Is Your AI Reviewer Cheating?
How does Dam Secure help with indirect prompt injection?
Dam Secure doesn't stop a model from reading a planted instruction. It reviews what comes out the other side, and it gives your agents better security context to start from.
PR Security Reviews check every pull request against how your codebase actually works, whether a person or an agent wrote it. AI and agent security is one of the nine lenses each review runs, alongside access control and secrets.
A PR that weakens an access check, adds an outbound call, or changes a workflow so untrusted comments can reach secrets is the kind of change those lenses look for, and findings land on the PR in under two minutes with a suggested fix.
Managed Security Context gives Claude Code, Cursor, Codex and GitHub Copilot security context for your codebase in the formats they already read. It's generated from your codebase and the vulnerabilities you've already fixed, then raised as a PR for your team to review, so changes to that context get reviewed like any other code.
FAQ
What is the difference between direct and indirect prompt injection?
In a direct injection, the attacker types the malicious prompt into the model themselves. In an indirect injection, the attacker plants instructions in content the model reads later, such as a web page, a file or a GitHub issue, so the victim's own agent carries out the attack.
Can a GitHub issue hack my AI coding agent?
It can if an agent reads that issue automatically and has access to secrets or write permissions. In 2026, researchers showed issue and PR text making three CI agents leak their API keys. Limiting who can trigger agents and what they can reach removes most of the risk.
Can prompt injection be fully prevented?
Not today. OWASP says it's unclear whether fool-proof prevention exists, which is why defenses focus on least privilege, separating untrusted input from secrets, human approval for risky actions and reviewing every change an agent makes.
Are AI code reviewers vulnerable to prompt injection?
Yes, any reviewer that reads PR content can be targeted, which is how the Claude Code Security Review action leaked its key. Run reviewers with the least access they need, keep secrets away from untrusted triggers, and don't let a single automated approval merge code on its own.
Want to see Dam Secure review your team's PRs? Speak to our team.
.webp)


.webp)