
An AI coding agent can read a bug report, inspect a repository and run tests without waiting for a separate instruction at every step. That is useful until something it reads tries to take over the job.
Prompt injection is the attempt to turn material the agent should examine into instructions it obeys. For a coding agent, that material could be an issue, a code comment, a downloaded document or text printed by a tool. The practical question is simple: who is allowed to change what the agent is doing?
A bug report is evidence, not unlimited authority
Consider this fictional task: fix a delivery-fee calculation that rounds the final amount incorrectly. The developer permits changes to the calculation and its tests, but has not requested a deployment.
The issue contains useful inputs and expected totals. It also contains a paragraph claiming that the team has already approved disabling a security check and uploading a configuration file to an external diagnostic service.
Those are different kinds of information. The numerical example can help reproduce the bug. The paragraph is asking for new actions with different consequences. Its appearance inside the issue does not establish that the developer approved them.
A safe response would extract the reproduction case, leave the unrelated actions alone, and flag the suspicious request. The agent should still be able to fix the rounding error. Refusing the injected direction need not mean abandoning the legitimate work.
How the boundary gets crossed
A typical failure has three steps: the agent encounters lower-trust text, interprets it as an authoritative direction, then uses a tool to act on it. The text may claim to come from an administrator or describe an unnecessary action as a prerequisite for finishing the task.
OWASP’s prevention guidance identifies code comments, documentation, issue descriptions and forged tool observations among the relevant entry points. It also cautions that text labels and keyword screening are not enforceable security boundaries.
That explains why a rule such as “ignore malicious instructions” is useful guidance but insufficient protection. The application also needs to restrict what can actually happen when the model makes a poor judgment.
A trusted tool can return untrusted text
Suppose a test runner prints an exception message containing a customer-supplied string. The runner may have executed correctly, yet part of its output still originated with a customer. A search tool can similarly return a document written by someone outside the team.
For the fictional rounding task, imagine the failing test prints a message insisting that all remaining checks should be skipped. The useful evidence is the failed assertion, input and observed result. The demand to skip checks should not become the agent’s next instruction.
Keep the source visible when passing evidence between steps. A summary should say “the issue requests an upload,” rather than silently converting that into “upload approved.” This is especially important when one agent prepares a summary for another.
Review authority as carefully as content
A project can legitimately contain instructions for AI tools. Teams may maintain a reviewed guidance file explaining build commands, conventions and test locations. But a familiar filename alone cannot establish trust. A proposed change from an unfamiliar contributor can modify that file too.
For this workflow, review instruction-file changes alongside code changes. Ask who introduced the direction, whether it belongs to the task, and whether it asks for access or effects beyond the developer’s request. Treat claims of prior approval as claims until the approval can be verified.
This complements planning and human review: a clear assignment gives reviewers something concrete against which to compare later actions.
Use several controls, each with a clear job
GitHub’s Copilot cloud agent documentation describes protections including restricted branch access, human review before merging, internet restrictions and filtering certain hidden content. These are product-specific controls, not guarantees that apply to every coding assistant.
Anthropic’s sandboxing explanation distinguishes filesystem isolation from network isolation. One limits which files a process can reach or change; the other limits external connections. They address different parts of an unwanted action.
For the rounding example, a sensible arrangement is a disposable development workspace with synthetic orders, no production credentials and no deployment access. The agent can edit the intended files and run the approved test suite. A request to send files elsewhere is evaluated separately, with the exact destination and data visible to the reviewer.
Do not grant broad access simply because an unexpected message calls it essential. If a legitimate dependency is missing, resolve that specific dependency rather than approving a general escape from the working boundary.
Check behavior, not just reassuring words
In a disposable test repository, add a harmless test fixture that asks the agent to change an unrelated marker file. Ask it to complete the normal rounding task. Then inspect the actual diff and action log.
Did it preserve the unrelated file? Did it finish the requested fix? Did it report the suspicious text without obeying it? Repeat with the instruction placed in an issue excerpt and simulated tool output. Use no real secrets and no real external destination.
This small exercise is a workflow check, not a security certification. One successful run cannot prove resistance to every attack. Anthropic’s discussion of trustworthy agents likewise emphasizes layered defenses across the model, surrounding software, tools and environment, with no guarantee from any single safeguard.
The goal is useful autonomy with a reliable boundary: repository content helps the agent understand the work, while verified authority and enforced controls determine what it may do.