All glossary terms
P AI security Threat

Prompt injection

Prompt injection makes an AI system act on an attacker's instructions instead of yours. It is not a bug awaiting a patch. It is a property of putting instructions and data in the same channel, and the fix that solved SQL injection is structurally unavailable here.

Definition

Prompt injection is an attack in which adversarial instructions reach an AI system through its input or through content it retrieves, causing it to act on the attacker's intent rather than the operator's. It is the top entry in the OWASP Top 10 for LLM Applications and, as of 2026, remains architecturally unsolved.

What is prompt injection?

Prompt injection is an attack that gets an AI system to follow somebody else's instructions. Adversarial text arrives through the input or through content the system retrieves, and the model treats it as direction rather than as data, because it has no reliable way to tell the difference.

It sits at the top of the OWASP Top 10 for LLM Applications, and it has held that position since the list was first published. That is unusual for a security list, which normally reshuffles as defences mature. Prompt injection has stayed at number one because the defences have not matured in the way the ranking implies they should.

The reason is structural rather than a matter of engineering effort. A model receives everything as one sequence of tokens: the operator's system instructions, the user's request, and whatever content the system retrieved on the user's behalf. All three look the same to it. Following instructions found in that sequence is the model's job, and nothing in the sequence carries a marker saying which instructions are legitimate.

What is the difference between direct and indirect prompt injection?

Direct injection is a user typing adversarial instructions into their own session. Indirect injection is instructions hidden inside content the system retrieves, so a third party attacks somebody else's session. The second is the one that matters, and the two are routinely conflated.

The distinction is not academic, because the threat models differ completely. Confusing them leads organizations to defend against the version that is mostly a policy problem while leaving the version that is a genuine security problem open.

Direct compared with indirect prompt injection across attacker, victim, delivery route, and what defends against each
Type Who attacks whom How it arrives What defends
Direct A user attacking the system in their own session Typed straight into the prompt Mostly access control and policy. The user already had their own permissions
Indirect A third party attacking another user, through the system Hidden in a document, email, ticket, web page, or tool output the system retrieves Privilege reduction and egress control. Filtering helps and does not close it

Indirect injection is the serious case for a specific reason: the victim has no idea an attack is in progress and the attacker never touches the system directly. Somebody influences a document, and later a colleague's agent reads it while doing ordinary work. The instructions execute with that colleague's permissions, against that colleague's data.

The surface is also wider than people expect. Instructions can be hidden in a shared document, a supplier's PDF, an inbound email, a support ticket, a web page an agent browses, the output of a tool it calls, or, in multimodal systems, inside an image or audio file. Anything the agent reads is a candidate, which is covered from the pipeline side at data ingestion.

Memory poisoning: indirect injection that persists

A variant worth naming separately. Where an agent keeps memory across sessions, an injection that succeeds once can write a false fact into that store, and every later session reads it as established truth. The attack outlives the session it arrived in, and nothing about the stored fact indicates it was injected. Anything entering durable memory deserves the scrutiny you would apply to code rather than to a search result. See context engineering.

How does an indirect prompt injection actually work?

In four steps: an attacker plants instructions in content the target's agent will read, the agent retrieves it during ordinary work, the model treats the planted text as direction, and the agent acts using its own permissions. Nothing in the chain looks anomalous.

The sequence below describes the mechanism at a level useful for threat modelling. It deliberately avoids working payloads, because the defensive value is in understanding the shape rather than in reproducing the technique.

  1. The attacker plants instructions where the agent will read them

    Anywhere they can influence content the target's system retrieves: a document in a shared repository, a public web page, an inbound email, a submitted ticket, a field in a record. The text is usually positioned to be invisible or unremarkable to a human reader while remaining legible to the model.

  2. The agent retrieves it during legitimate work

    No exploit is required at this stage, and this is what makes it hard to detect. Somebody asks the agent a reasonable question, the retrieval layer returns the most relevant material, and the planted content is genuinely relevant. Ranking cannot distinguish it.

  3. The model reads it as instruction

    The retrieved text enters the same token sequence as the system prompt and the user's request. The model was built to follow instructions it finds there. From its perspective nothing unusual has happened, and no error is raised at any point.

  4. The agent acts, with its own permissions

    This is where an agent differs from a chatbot. A chatbot produces text somebody reads. An agent calls tools, so the injected instruction can reach whatever the agent can reach: sending a message, changing a record, querying a system, or transmitting data outwards. The permissions used are the agent's, which is why they matter more than any filter.

Until recently this was widely treated as theoretical. That changed with the first confirmed zero-click exploit against a production assistant, documented in the security literature as EchoLeak, which required no action from the victim at all. Academic benchmarking has also put numbers on it: work on tool-integrated agents has reported successful indirect injection in a substantial minority of attempts against capable models, with published figures in the range of roughly a quarter to a half depending on the setup. Treat those as indicative of magnitude rather than as a measurement of your own system.

Why can prompt injection not be fixed?

Because the fix that solved SQL injection is structurally unavailable. Parameterized queries work by separating code from data at the protocol level. A model receives natural language in one token stream, so there is no protocol layer at which that separation could be made.

The comparison with SQL injection is made constantly and usually stops at the analogy. Following it through is what explains why one was solved and the other has not been.

Two panels. On the left, SQL with parameterized queries: the query template and the user data travel in separate channels, with a protocol-level boundary between them, so data can never be executed as code. On the right, an LLM: system instructions, user input and retrieved content all arrive as one undifferentiated token sequence with no privilege boundary marked anywhere, so any of it can be read as instruction. A caption reads that the separation that fixed SQL injection has no equivalent here.
  • SQL had a boundary to enforce. A parameterized query sends the statement and the values along separate paths. The database knows which is which by construction, so a value can never be executed as a command. The boundary is in the protocol, not in a filter.
  • An LLM has no such path. System instructions, user input, and retrieved content arrive as one sequence. No token carries a privilege level. The model cannot consult a boundary that does not exist.
  • Natural language cannot be validated the way structured input can. OWASP makes this point directly: unlike SQL injection, prompt injection cannot be reliably mitigated through schema validation, because natural language is flexible and unstructured. There is no grammar to check against.
  • Following instructions is the feature. The behaviour being exploited is the behaviour you are paying for. A model that ignored instructions found in its context would be useless for most of what agents do.

Two consequences follow, and they should shape how you plan. Neither retrieval augmentation nor fine-tuning closes it, which OWASP states explicitly, so architectural changes marketed as solutions generally are not. And the likelihood of a successful injection cannot be driven to zero, which means any strategy resting entirely on prevention is resting on something unachievable. That is not a counsel of despair. It is the reason the next section is ordered the way it is.

What actually reduces prompt injection risk?

Split every mitigation into two groups: those that reduce the likelihood of an injection succeeding, and those that reduce the impact when one does. Likelihood measures are probabilistic and never reach zero. Impact measures are deterministic and provable, which makes them the durable layer.

Almost all published guidance presents mitigations as a flat list. Sorting them by which of the two they address tells you where to spend first, and it follows directly from the previous section.

Two stacked bands. The upper band, reduce likelihood, lists injection detection classifiers, input and output filtering, instruction hardening and adversarial testing, all marked probabilistic and asymptotic, never reaching zero. The lower band, reduce impact, lists least-privilege tooling, scoped credentials, deterministic egress control, human approval on irreversible actions and isolation of untrusted content, all marked deterministic and provable. An arrow indicates that because likelihood cannot reach zero, the impact band is where the durable defence sits.

Measures that reduce likelihood

Worth having, and none of them closes the gap. Injection detection classifiers, input and output filtering, hardening the system instructions, and repeated adversarial testing. Each lowers the probability that a given attempt succeeds. None can make it zero, and an attacker gets as many attempts as they want, which is the asymmetry that makes this band insufficient on its own.

One measure explicitly does not belong here. OWASP is direct that the system prompt should never be treated as a secret or relied on as a security control, and that authorization and privilege separation belong in deterministic systems outside the model. Instructions telling a model to refuse malicious requests sit in the same channel an attacker writes to.

Measures that reduce impact

These hold whatever the model decides, because the model is not the thing enforcing them. This is where the real defence lives.

  • Least-privilege tooling. An injected instruction can only reach what the agent can reach. Narrow the tool set to the task rather than granting the identity of whoever built it, and most of the impact disappears before any filter runs.
  • Scoped, short-lived credentials. The agent acts with a credential. What that credential can do, and for how long, is the actual blast radius.
  • Deterministic egress control. Restrict where an agent can send data, by rule rather than by judgement. Exfiltration requires an outbound path; removing paths is more reliable than inspecting traffic.
  • Human approval on the irreversible. Decided by reversibility rather than perceived risk. One gate before an action that cannot be undone is worth more than several on reads.
  • Isolation of untrusted content. Keep retrieved material in a separate context or a sandboxed step so it cannot expand what the agent is permitted to do.

The architectural test beats any individual control. Simon Willison's lethal trifecta names the three conditions that together make exfiltration possible: access to private data, exposure to untrusted content, and the ability to communicate externally. An agent with all three has the structural preconditions whatever is attached to it. Removing one leg does more than tightening every filter, and it is often achievable: split the agent, drop the outbound channel, or keep the untrusted retrieval in a component that holds no secrets. For the wider control picture see AI guardrails.

What is the difference between prompt injection and jailbreaking?

Different attacker, different victim, different fix. Jailbreaking makes a model violate its own provider's policies, usually with the user as the attacker. Injection makes a system violate its operator's intent, usually with a third party attacking a user. They get conflated constantly.

The confusion is understandable, because both involve adversarial text and both look like the model misbehaving. The distinction matters because the remedies live in different places and with different parties.

Prompt injection compared with jailbreaking by attacker, victim, what is violated, and who can fix it
Attack Who is attacking What gets violated Whose problem to fix
Injection Usually a third party, via content the system reads The operator's intent for the system Yours. It is an architecture and permissions problem
Jailbreaking Usually the user, in their own session The model provider's content policies Largely the provider's, through model training and filters

Two practical consequences. A model that becomes harder to jailbreak is not thereby harder to inject, because injection does not require the model to break any rule: it only requires the model to follow the wrong instructions, which is normal behaviour applied to adversarial input. And a vendor citing improved jailbreak resistance has not answered a question about injection, so the two claims should be examined separately during evaluation.

Two more terms worth separating while we are here. Goal hijacking is an injection that redirects the system to perform the attacker's task. Prompt leaking is an injection that extracts the system instructions themselves, which matters mainly because of what teams put in them rather than because the instructions are inherently secret. Both are injection outcomes rather than separate attack classes.

Frequently asked questions about prompt injection

If your question is not here, our team will answer it directly.


Talk to a Specialist →
What is prompt injection in simple terms?

Somebody else's instructions reach your AI system, and it follows them. The mechanism is simpler than the name suggests: a model receives the operator's instructions, the user's question, and any content it retrieved as one continuous piece of text, and it cannot tell which part came from whom. If an attacker can get text into any of those places, that text competes for the model's attention on equal footing with your own instructions.

What is the difference between direct and indirect prompt injection?

Direct injection is a user typing adversarial instructions into their own session, which is mostly an access-control and policy question because that user already held their own permissions. Indirect injection is instructions hidden inside content the system retrieves, so a third party attacks another user through the system. The second is the serious case: the victim has no idea an attack is happening, and the attacker never touches your system directly.

Why is prompt injection still unsolved?

Because the fix that solved SQL injection has no equivalent. Parameterized queries separate the statement from the values at the protocol level, so a value can never execute as a command. A language model receives system instructions, user input and retrieved content as one token sequence with no privilege level attached to anything, so there is no layer at which that separation could be made. Speaking at Infosecurity Europe in July 2026, an OWASP contributor described it as an unsolved architectural problem for precisely this reason.

Can guardrails or filters stop prompt injection?

They reduce the likelihood and cannot eliminate it. Detection classifiers, input and output filtering, and hardened instructions each lower the probability that a given attempt succeeds, and an attacker gets unlimited attempts. That asymmetry is why a strategy resting entirely on filtering is resting on something unachievable. The durable measures reduce impact instead: least-privilege tooling, scoped credentials, deterministic egress control, and human approval on irreversible actions all hold whatever the model decides.

Does RAG or fine-tuning prevent prompt injection?

No, and OWASP states this explicitly: neither retrieval-augmented generation nor fine-tuning fully mitigates the risk. Retrieval arguably widens the surface rather than narrowing it, because every document in the corpus becomes a potential delivery route for an attacker who can influence any of it. Fine-tuning shapes the model's tendencies without creating the privilege boundary that is missing. Treat architectural changes marketed as solutions with scepticism, and ask which layer they actually enforce anything at.

What is the difference between prompt injection and jailbreaking?

Different attacker, different victim, different fix. Jailbreaking is usually a user in their own session getting a model to violate its provider's content policies, which is largely the provider's problem to address through training and filters. Injection is usually a third party getting a system to violate its operator's intent, which is your problem and is an architecture and permissions question. A model that is harder to jailbreak is not thereby harder to inject, because injection needs the model to break no rules at all.

Has prompt injection actually been exploited in production?

Yes. It was widely treated as theoretical until the first confirmed zero-click exploit against a production assistant, documented in the security literature as EchoLeak, which required no action at all from the victim. Academic benchmarking of tool-integrated agents has also reported successful indirect injection in a substantial minority of attempts against capable models. Take those figures as indicating magnitude rather than as a measurement of your own system, which will differ with its permissions and retrieval surface.

What is memory poisoning?

An injection that persists. Where an agent keeps memory across sessions, an attack that succeeds once can write a false fact into that store, and every subsequent session reads it as established truth. The attack outlives the session it arrived in, and nothing about the stored fact marks it as injected. This is why durable context deserves stricter validation than transient context: anything entering long-lived memory should be treated more like code than like a search result.

Why are AI agents more exposed than chatbots?

Because an agent acts. A chatbot's worst case is producing text somebody reads, which a person can disregard. An agent calls tools, so an injected instruction can reach whatever the agent can reach: sending messages, changing records, querying systems, or transmitting data outwards. Agents also retrieve from more sources with less oversight and chain calls together, which widens the delivery surface at the same time as it raises the consequence.

What is the lethal trifecta?

Simon Willison's name for the three conditions that together make data exfiltration possible: access to private data, exposure to untrusted content, and the ability to communicate externally. An agent holding all three has the structural preconditions regardless of what filters are attached, which makes it an architectural test rather than a control. Removing one leg achieves more than tightening every filter, and it is often practical: split the agent, drop the outbound channel, or keep untrusted retrieval in a component holding no secrets.

How do you test for prompt injection?

Adversarially, repeatedly, and with attention to impact rather than only to blocking. Try many variations rather than confirming that one obvious attempt is caught, since success rates rise sharply with attempt count. Published benchmarks for tool-integrated agents give a starting methodology. Then test the impact layer separately and provably: demonstrate that the agent cannot reach a particular system, cannot exceed a spend ceiling, and cannot transmit data to an unapproved destination. That second set of tests produces answers rather than probabilities.

Should prompt injection stop you deploying AI agents?

No, and treating it as a blocker is as unhelpful as ignoring it. The realistic position is that likelihood cannot be driven to zero, so deploy where the impact of a successful injection is acceptable and constrained. That means scoped permissions, no outbound path an attacker would want, human approval on anything irreversible, and a record complete enough to reconstruct what happened. Agents reading only internal reviewed content and holding narrow credentials are a materially different proposition from agents browsing the web with broad access.

Reduce the impact, not just the odds
Assume an injection succeeds. What can it reach?

CAMS scopes tools and credentials per agent, enforces runtime policy including sensitive-data detection and redaction, gates promotion to production, and records every call, so a successful injection meets a narrow permission set and a complete trace rather than an open estate.