A coding agent reads a lot before it writes anything: the issue it was assigned, comments on it, the README, docs, source files, test output, and sometimes web pages and package docs. It treats all of that as context.
The problem is that a language model can't reliably tell the difference between context it should use and instructions it should follow. If text in that context says "ignore the task and do this instead," the model may comply. This is prompt injection, and OWASP lists it as the top risk in its Top 10 for LLM applications.
For coding teams, the question isn't whether a model can be tricked. It's what an agent can do once it has been.
Where injected instructions can come from
- Issues and comments. On public repositories, anyone can open an issue. If agents pick up issues automatically, the issue body is untrusted input.
- Pull request descriptions and review comments from outside contributors.
- Files in the repository, including docs, config files and code comments, especially in dependencies or vendored code.
- Tool output. Test logs, error messages and command output that include text from elsewhere.
- Web pages and package docs the agent fetches while researching.
Instructions can be hidden: inside HTML comments, collapsed sections, long lines, or text written to look like part of the file.
What an injected agent might try
- Add a dependency, a script or a CI step that runs attacker code
- Read secrets from the environment and print them into logs or a pull request
- Weaken a check: skip a test, loosen a permission, remove validation
- Push to a branch or merge without review
All of these depend on what the agent is allowed to do. That's where to focus.
Limit what a fooled agent can do
You can't make a model immune to prompt injection. You can make injection low-impact:
- No secrets in the agent's environment. Run agents with the minimum credentials needed, and keep production keys out entirely.
- Scoped repository tokens. Access only to the repositories in the task, and no permission to merge or push to protected branches.
- Sandboxed execution. Tests and commands run in an isolated environment with limited network access.
- Treat outside input as untrusted. Don't let agents act automatically on issues or comments from people outside the team.
- Review the diff, not the description. An injected change can come with a perfectly reasonable summary.
- Gate the merge. Nothing reaches main without tests on the exact commit, an independent review and a human approval.
How AI CodeOps handles it
In AI CodeOps, agents work in sandboxes with tokens scoped to the repositories you choose, and policies control what each agent may do. Agents can't approve or merge their own work. A separate AI review checks the real diff, including changes nobody asked for, and a pull request only opens when tests pass on that exact commit, the review has no open high or critical findings, and a person approves. If anything errors, the gate fails closed.
That doesn't make prompt injection impossible. It means a fooled agent produces a pull request that gets caught, not a change that ships.
Free during the open beta: https://aicodeops.dev
Top comments (0)