Prompt injection is an attack in which text that an AI agent reads as data is interpreted by the model as instructions. The agent is told to summarize a document, and the document contains a line telling it to do something else. Because a language model processes its instructions and its input as the same kind of text, it cannot reliably tell them apart.
How it works
Direct injection: The attacker is the one talking to the agent and crafts input that overrides the system prompt. This is the jailbreak case, and the attacker has to have access to the agent.
Indirect injection: The attacker plants instructions in content the agent will read later: a web page, an email, a support ticket, a code comment, a document in a shared drive, a calendar invite. The agent’s legitimate user asks it to process that content, and the planted instructions execute with the user’s authority. This is the more dangerous case because the attacker never touches the agent directly.
Why it is hard to stop
The problem is structural. A model has one input channel. Everything in it, from the developer’s system prompt to the contents of a PDF, is text that shapes the next output. Defenses exist: instruction hierarchies, delimiters, classifiers that scan input for injection patterns, and models trained to resist. All of them reduce the success rate. None of them reduce it to zero, and an attacker only has to succeed once. Every published evaluation of injection defenses has found bypasses.
What an injected agent can do
The consequence of injection depends entirely on what the agent can reach. An agent with no tools can only produce a wrong answer. An agent with tools can act on one, for example:
Exfiltrate: Read secrets, files, or data it has access to and send them somewhere the attacker controls, for example by embedding them in a URL it is told to fetch.
Act on the attacker’s behalf: Approve a request, merge a change, send a message, change a configuration, transfer a resource. The action carries the legitimate user’s authority.
Persist: Modify its own instructions, memory, or the content other agents will read, so the injection spreads or survives.
Effective controls for these actions
Because injection cannot be fully prevented at the model layer, the most effective control is at the action layer: limit what a manipulated agent can do, and make sure the harm is bounded even when the manipulation succeeds:
Hold nothing worth stealing. If the agent has no credentials in its environment, an injection that tells it to exfiltrate secrets has nothing to exfiltrate. Credentials held by a gateway outside the agent, and bound to that gateway’s platform, are useless to an attacker even if a reference to them leaks.
Authorize every action. If each tool call is checked against the task’s scope by a system that does not read the same untrusted content, an injected instruction to do something out of scope is refused regardless of how convincing it was.
Record everything. A per-call audit trail that names the agent, its host, and its owner turns a successful injection into a detectable and attributable event rather than a silent one.
Prompt injection cannot be eliminated, so the practical goal of these approaches is to make a successful injection useless. The agent can be induced to attempt anything, and the attempt fails anyway.