Safeguard
AI Security•

How can prompt injection reach a coding agent through your repository?

Prompt injection reaches a coding agent through issues, pull requests, docs, dependencies and tool results. Here is the input map and a control for each.

Safeguard Security Team
3 min read

Prompt injection reaches a coding agent through anything it reads that someone outside your trust boundary could write: issue text, pull request descriptions, comments, documentation in dependencies, fetched web pages, and tool server results. Map those inputs, then limit what the agent can do after reading them.

Definition

OWASP defines indirect prompt injection as instructions arriving when a model accepts input from external sources such as websites or files. It also notes that injected content does not have to be visible to humans, only parseable by the model. In a coding setting, that means text hidden in markup, comments, or metadata.

The input map

InputWho can write itExample risk
Issues and commentsAnyone with an account, for public repositoriesInstruction asking the agent to change files or reveal data
Pull request textContributors, including forksSame, plus text in the diff
README and docs of dependenciesPackage authorsInstructions hidden in documentation the agent reads while researching
Web pages the agent fetchesAnyonePage content that tries to redirect the task
Tool server resultsThe tool owner, or whoever fills its dataReturned records carrying instructions
Project rule filesAnyone who can commitA changed rules file that alters agent behavior

What to do about each entry

  1. Separate untrusted content from instructions. OWASP advises denoting untrusted content clearly to limit its influence. Where your tool supports it, use the setting; where it does not, do not rely on it.
  2. Cut the actions that follow. Injection is harmful when the agent can do something damaging next. Remove network egress, restrict file writes, and require approval for commands. That is the real defence, because filtering text will not catch everything.
  3. Review rule files like code. Put CODEOWNERS on them so a change needs an owner's approval.
  4. Keep public issue text away from privileged agents. An agent with write access should not auto process issues from strangers.
  5. Check tool results. Prefer narrow tools that return structured fields over tools that return free text.

The combination to avoid

Three things together make the worst case: untrusted input, access to private data, and the ability to send data out or take actions. Remove at least one. Most teams find the outbound path is the easiest to close. See the rule of two for agents.

Test it

OWASP recommends adversarial testing and treating the model as an untrusted user. A simple test: plant a harmless instruction in a test issue, such as asking the agent to add a marker line to a file, and see whether it complies. If it does, your boundaries need work. More in testing coding agent guardrails.

Safeguard offers an MCP Guardrail for tool access, policies, and pull request gates that sit after the agent acts, so a harmful change still meets a check.

Quick check

Can a filter stop prompt injection?

Filters help but are not reliable alone. OWASP lists them beside least privilege and human approval, not instead of them.

Are private repositories safe from this?

Safer, not safe. Dependencies, fetched pages and tool results still bring outside text into the agent's context.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.