Prompt Injection: The Unsolved Security Problem in Every LLM Application
Prompt injection is what happens when text a model reads as data gets treated as instructions, and there is currently no reliable way to prevent it, because a language model has no structural boundary between the two. The comparison to SQL injection is the one everyone reaches for, and it is instructive right up to the point where it stops. SQL injection was solved, genuinely and permanently, by parameterized queries: the database receives the command structure and the user data through separate channels and can no longer confuse them. No equivalent exists for language models. The system prompt, the retrieved document, the user's question, and the tool output all arrive as one undifferentiated token stream, and the model's willingness to follow instructions found in that stream is not a bug to be patched, it is the capability the product is built on. For chat applications this produces embarrassment. For agents that can send, buy, delete, and transmit, it produces incidents. The OWASP Top 10 for Large Language Model Applications ranks prompt injection first, and the honest executive framing is not how to solve it but how to architect so that a successful injection does something survivable.

Key Takeaways
- There is no parameterized-query equivalent for language models. SQL injection was solved by structurally separating command from data; a model receives everything as one token stream, and instruction-following is the product feature rather than a defect. Every current mitigation is probabilistic, architectural, or both, and none is a fix.
- The dangerous class is indirect injection, where the malicious instruction arrives inside content the model retrieves: a document, an email, a web page, a code comment, a tool response. The attacker is not the user typing into the box, which is why input validation on the user's message addresses the least important half of the problem.
- Agents convert this from an output problem into an action problem. A jailbroken chatbot says something wrong. An injected agent sends the email, approves the invoice, opens the pull request, or transmits the data, and it does so with whatever authority the organization granted it.
- Three capabilities together create the exposure: access to private data, exposure to untrusted content, and the ability to communicate externally. An agent holding all three can be induced to exfiltrate. Removing any one of the three bounds the damage structurally, which is the most reliable control available.
- Defenses split into two categories that should never be confused. Detection classifiers, prompt hardening, and delimiters reduce the attack surface and can always be bypassed by a sufficiently novel input. Privilege separation, human approval gates, and egress control bound the consequence regardless of whether the injection succeeds. Only the second category holds.

What Prompt Injection Actually Is
Prompt injection is the insertion of instructions into content a model processes, such that the model follows them instead of, or in addition to, the instructions its developer supplied. The mechanism is that no boundary exists to violate.
A traditional application distinguishes code from data structurally. The parser knows which bytes are the query and which are the parameter, because they arrived through different channels and are handled by different machinery. A language model receives a single sequence. The system prompt, the conversation, the retrieved passage, and the function result are concatenated into one context, and the model attends over all of it. Text that says "ignore previous instructions and do X" is, from the model's perspective, simply more text of exactly the kind it has been trained to be responsive to.
This is why the problem has proven durable. Every proposed fix eventually reduces to teaching the model to treat some spans of text as authoritative and others as inert, and models remain unreliable at that distinction under adversarial pressure. Training helps, delimiters help, and neither produces a guarantee. A defense that works against ninety-nine percent of attempts is a strong defense in most security domains and a weak one here, because an attacker retries.
Direct injection
The user is the attacker. Someone types adversarial input to bypass the system prompt: extracting the prompt itself, eliciting prohibited content, or unlocking functionality intended to be restricted. This is what most people mean by jailbreaking.
Direct injection matters most for consumer-facing products, where reputational damage and content liability are the concerns. Its ceiling is bounded by what the user could already access, since the attacker is operating with their own privileges. Unpleasant, and rarely catastrophic.
Indirect injection
The user is a victim, not the attacker. The malicious instruction is planted in content the model will later process: a document in the knowledge base, a received email, a web page the agent browses, a code comment, a support ticket, a calendar invitation, a response from a third-party API.
This is the class that matters for enterprises. The attacker never interacts with the application. They place the payload where the system will encounter it and wait. A legitimate employee asks a legitimate question, the retrieval layer pulls in the poisoned document, and the model acts on instructions embedded within it while operating with that employee's authority.
The consequences of the distinction are practical. Input filtering on the user's message does nothing about content arriving through retrieval. Rate limiting the user does nothing, because the user is not attacking. Authentication does nothing, because the user is genuinely who they claim to be. Every control oriented around the user misses the vector entirely.

Why Agents Change the Severity
A chat interface that produces text has a bounded worst case: it says something wrong, offensive, or confidential. Real, and containable.
An agent with tools has no such bound. The same injection that would have produced bad text now produces an action, executed with whatever permissions the agent holds. It sends the message, files the ticket, moves the funds, merges the change, or calls the API that transmits the data. There is no human reading the output before it takes effect, because eliminating that human is usually the point of deploying the agent.
Three capabilities together define the exposure, and the framing has become the standard way to reason about agent risk: access to private data, exposure to untrusted content, and the ability to communicate externally. An agent with all three can be instructed by injected content to read something sensitive and send it somewhere the attacker controls. The exfiltration channel need not look like one. A rendered image whose URL contains the data, a web request to an attacker-controlled endpoint, a reply to an email thread, or a comment posted to an issue tracker all work.
The value of the framing is that it converts an unbounded worry into a design checklist. An agent that reads untrusted content and holds private data but cannot reach the outside world cannot exfiltrate. An agent that reads untrusted content and can communicate externally but holds nothing sensitive has nothing to leak. Removing one leg is a structural fix, and it is achievable, whereas making the model injection-proof is not.
| Agent capability | What injection can achieve | Structural control |
|---|---|---|
| Reads untrusted external content | Delivers the payload at all; the entry point | Restrict sources to vetted corpora; treat all retrieved content as hostile input |
| Holds credentials to private data | Reads what the attacker names | Scope credentials per task; agent authority never exceeds the delegating human's |
| Can send email or messages | Exfiltration, plus social engineering from a trusted sender | Allowlist recipients; require approval for external sends |
| Can make outbound network requests | Exfiltration through URLs, including rendered images | Egress allowlist; block arbitrary domains and image fetches |
| Can write to systems of record | Data destruction, fraudulent records, persistent backdoors | Human approval for writes; no delete authority; append-only where feasible |
| Can move money or commit spend | Direct financial loss | Hard approval gate above a threshold; per-task spend caps enforced outside the model |
| Can modify code or infrastructure | Persistence, supply-chain compromise | Pull requests only, never direct merge; human review of every diff |
What Actually Mitigates and What Only Reduces
The most consequential distinction in this whole subject is between controls that shrink the attack surface and controls that bound the consequence. Both are useful. Only the second class is dependable, and treating the first as sufficient is the error that produces incidents.
Controls that only reduce the surface
Detection classifiers. A model or heuristic that inspects input for injection attempts. These catch known patterns and are worth deploying, and they are pattern matching against an adversary who can rephrase indefinitely. Every published classifier has been bypassed. Useful as a layer, never as a boundary.
System prompt hardening. Instructing the model to disregard instructions found in retrieved content. This helps measurably and fails under pressure, because the defense and the attack occupy the same channel and the model is arbitrating between two sets of instructions with no principled basis for preferring one.
Delimiters and spotlighting. Marking untrusted content with tags or encoding so the model can distinguish it. Genuinely improves resistance. Does not survive an attacker who understands the scheme, and the scheme is usually inferable.
Model-level training. Providers train models toward instruction hierarchy, prioritizing developer instructions over content. This raises the bar with every generation and has not eliminated the problem, and building an architecture on the assumption that the next model will is not a plan.
Controls that bound the consequence
Privilege separation. The agent holds the minimum authority its task requires, scoped per task rather than provisioned as a standing union of everything it might ever need. A successful injection then commands an actor that cannot do much. This is the same delegation discipline described in AI agent identity and access management, and it is the single highest-value investment available.
Human approval gates. For consequential and irreversible actions, a person confirms before execution. The gate must be genuine: a human who can actually evaluate what is being approved, at a volume low enough to permit evaluation. An approval stream nobody reads is a logging mechanism.
Egress control. Restricting where the agent can send data: allowlisted recipients, allowlisted domains, blocked image fetches from arbitrary URLs. This removes the exfiltration leg of the trifecta and is often the cheapest structural control to implement.
Output mediation. Validating what the agent produces before it takes effect. Schema validation, checking that a proposed action falls within a permitted set, and scanning outbound content for sensitive data. The enforcement patterns are covered in AI guardrails for production systems, and the natural place to apply them uniformly is the chokepoint described in the AI gateway.
Sandboxing. Executing agent actions in an environment where damage is contained and reversible: an isolated account, a staging dataset, a branch rather than the main line.
| Technique | What it stops | What it cannot stop | Class |
|---|---|---|---|
| Detection classifier | Known injection phrasings and public jailbreaks | Novel phrasing, obfuscation, encoding, non-English payloads | Surface |
| System prompt hardening | Casual and low-effort attempts | A determined attacker operating in the same channel as the defense | Surface |
| Delimiters and spotlighting | Naive injection that ignores the marking scheme | An attacker who infers the scheme and writes to it | Surface |
| Instruction-hierarchy training | A rising share of attempts with each model generation | The residual, which is what an adversary retries until they find | Surface |
| Least-privilege per-task credentials | Anything outside the task's granted scope | Misuse within that scope | Consequence |
| Human approval gate | Irreversible actions taken without review | Anything below the threshold; approval fatigue at volume | Consequence |
| Egress allowlist | Exfiltration to attacker-controlled destinations | Exfiltration to an allowlisted destination the attacker can read | Consequence |
| Output mediation | Malformed or out-of-policy actions and outbound sensitive data | Harmful actions that are individually well-formed and in policy | Consequence |
| Sandboxed execution | Damage to production systems and real records | Damage within the sandbox, and anything with a path out of it | Consequence |
Design Patterns That Hold Up
Dual-model quarantine. Two models with different privileges. A quarantined model processes untrusted content and is permitted to return only structured data, never instructions or free text that reaches the privileged path. A privileged model holds the tools and credentials and never sees raw untrusted content, only the structured output. Injection reaches a model that can do nothing with it. The cost is capability: the structured interface between the two constrains what the system can express, and designing that interface is the real work.
Plan then execute. The agent produces its plan before encountering untrusted content, and that plan is fixed. Content retrieved during execution can inform steps but cannot add, remove, or reorder them. An injected instruction to send data somewhere fails because sending is not in the plan. Effective against the most severe class of attack, and it forfeits the dynamic replanning that motivates many agent deployments.
Capability tokens per task. The agent receives a credential scoped to the specific resources one task requires, expiring with the task. Injection commands an actor whose authority ended at the task boundary.
Output mediation as a mandatory hop. Every action proposed by the agent passes through a policy layer outside the model that validates it against a permitted set before execution. The critical property is that the mediator cannot be reasoned with, because it is code.
Treat all retrieved content as hostile. The operating assumption should be that any document, email, page, or tool response may contain an injection, in the same way web applications treat all user input as potentially malicious. This changes retrieval design, source vetting, and the willingness to point an agent at the open web.
Testing belongs alongside these. Injection resistance is not verifiable by inspection, which is why adversarial evaluation of the assembled system, covered in AI red teaming, is the only way to learn what a specific deployment does under attack. The unit of testing is the system, not the model, since the mitigations that matter live in the architecture around it.
Frequently Asked Questions
What is prompt injection in simple terms?
It is when text a model reads as data ends up being followed as instructions. Because a language model receives the system prompt, the user's message, retrieved documents, and tool outputs as one undifferentiated token stream, content saying "ignore your instructions and do this instead" is processed by the same machinery as the developer's own instructions. There is no structural boundary separating the two.
Why can prompt injection not be fixed the way SQL injection was?
SQL injection was solved by parameterized queries, which send command structure and user data to the database through separate channels so they can never be confused. Language models have no such separation, and instruction-following is the capability the product depends on rather than a defect to remove. Every proposed fix reduces to making the model reliably distinguish authoritative from inert text, which models remain unreliable at under adversarial pressure.
What is indirect prompt injection?
An attack where the malicious instruction is planted in content the model will later process, rather than typed by the user: a document in a knowledge base, an incoming email, a web page, a code comment, a third-party API response. The user is a victim rather than the attacker, which is why input validation, rate limiting, and authentication all miss it entirely. This is the class that matters most for enterprise deployments.
Why are AI agents more at risk than chatbots?
Because the output is an action rather than text. A jailbroken chatbot says something wrong; an injected agent sends the email, approves the payment, deletes the records, or transmits the data, using whatever permissions it holds, with no human reading the output first. Risk concentrates when an agent has private data access, exposure to untrusted content, and the ability to communicate externally at the same time.
What should an organization actually do about prompt injection?
Assume injection will succeed and design so the result is survivable. Scope agent credentials per task rather than granting a standing union of permissions, require human approval for irreversible or high-consequence actions, restrict where agents can send data, validate proposed actions in code outside the model, and remove at least one of the three risky capabilities where the combination is not essential. Detection classifiers and prompt hardening are worth deploying as layers and should never be treated as boundaries.
The Bottom Line
The uncomfortable part of prompt injection is that the security field has no precedent for a vulnerability class this fundamental that stayed open this long. SQL injection, cross-site scripting, and buffer overflows all yielded to a structural fix that made the mistake impossible rather than merely unlikely. Prompt injection has produced no such fix in the years it has been understood, and the reason is architectural rather than a matter of insufficient effort.
That should change how the decision is framed. The question is not whether an application can be made injection-proof, because it cannot, and vendors claiming otherwise are describing a classifier with a good benchmark score. The question is what a successful injection accomplishes. In a well-architected system the answer is that it commands an agent with narrow, task-scoped authority, whose consequential actions require human confirmation and whose outbound traffic is restricted to known destinations. It fails quietly and gets caught in review.
In a poorly architected system the answer is that it commands an agent holding standing credentials to production data, with the ability to send anywhere, on behalf of a user who asked an ordinary question. That difference is entirely a matter of design decisions made before deployment, and it is the only variable an organization actually controls.