Skip to content

Prompt injection in coding agents: where it comes from and how to limit the damage

A coding agent reads issues, web pages and files. Any of them can contain instructions. How prompt injection works and which controls help.

Published by Contextingo.

Prompt injection means that text the agent reads contains instructions, and the agent follows them as if you had given them. The OWASP Top 10 for LLM applications lists it as LLM01, the first risk.

Where the text comes from

  • An issue or a pull request comment written by someone else.
  • A web page the agent fetched to read documentation.
  • A file in a dependency, a README, or the output of a tool.
  • A record that another agent or person saved to shared knowledge.

What can go wrong

An agent that can run commands, read files and make network requests can be steered into reading a secret and sending it somewhere, or into changing code you did not ask about. The risk is highest when three things come together: access to private data, exposure to untrusted text, and a way to send data out.

Controls that help

  1. Give the agent least privilege: only the folders and commands the task needs.
  2. Keep approval prompts on for commands that write outside the repository or use the network.
  3. Keep secrets out of the working folder and out of the agent’s environment.
  4. Treat text from issues, pages and shared records as data. Never paste untrusted instructions into a trusted file such as CLAUDE.md.
  5. Review every change before it is accepted. A person reading the diff is the control that does not depend on the model.

In Contextingo

Records written by agents are marked with a status, a record a person confirmed cannot be changed by an agent, and an agent cannot accept its own work. See the security page for what a connected agent can and cannot do.

Source

Questions

Good to know.

Can prompt injection be fully prevented?

Not by the model alone. The practical approach is to limit what an agent can do and to review what it changes.

Is a README a risk?

It can be, if it comes from a source you do not control, because the agent reads it as text.

Nothing learned is lost. Nothing unchecked is done.