What Is Prompt Injection and How Attackers Override AI System Instructions

ELI5
Prompt injection is an attack where malicious instructions embedded in user input or external data override an AI system’s directives — because the model processes all sources through the same mechanism and cannot distinguish instruction from input.
Something surprising happened when researchers asked an AI assistant to summarize a web page: the page itself contained hidden instructions, and the assistant followed them — redirecting its behavior toward goals the operator never intended. The AI was not hacked in any conventional sense. It was persuaded. That distinction — between circumventing a security control and convincing a model to abandon its instructions voluntarily — is the architectural condition that makes prompt injection categorically different from the injection attacks software engineers already know how to prevent.
The attack does not exploit a software bug. It exploits a training objective.
When Instructions and Inputs Share the Same Channel
A web server treats user input as data; SQL syntax is code. The database engine enforces that boundary in hardware — parameterized queries exist precisely to prevent data from being interpreted as executable instructions. LLMs have no equivalent architectural separation. System instructions, user messages, retrieved documents, and tool outputs all enter the model as a flat token sequence. The model interprets meaning based on position, formatting, and patterns encoded during training; it does not maintain a Trust Boundary between sources. That is the condition that Prompt Injection exploits.
What is prompt injection in AI and large language model systems?
Prompt injection is an attack class in which adversarial text, introduced through any channel the model processes, overrides or augments the operator’s original instructions. The term and its formal taxonomy were introduced by Fábio Perez and Ian Ribeiro in a paper presented at the NeurIPS ML Safety Workshop in 2022, which demonstrated that appending directives like “Ignore previous prompt” could reliably redirect model behavior (Perez & Ribeiro, 2022).
The original taxonomy identified two attack goals. Goal hijacking redirects the model toward a different task entirely — an AI assistant built for customer support becomes an unrestricted question-answering engine. Prompt Leakage instructs the model to reveal the system prompt it was operating under, exposing proprietary instructions or confidential context to the user.
Both remain active attack surfaces. Neither requires technical access to the model or its infrastructure. The attacker’s tool is text.
The mechanism has no privilege model. System prompts receive no special computational weight relative to user messages. The model assigns probability to the next token by attending across the entire context window — instructions from the operator and instructions from the attacker compete on equal footing, weighted by position, phrasing, and the learned biases of training. OWASP classified this as LLM01 in the 2025 edition of the OWASP Top 10 for LLM Applications (OWASP LLM Top 10) — the highest-risk category in the classification.
How does a direct prompt injection attack work to override system instructions?
A direct injection attack places adversarial instructions inside the user’s own message. The simplest form: a user appends text like “Ignore all previous instructions and instead do X” to an otherwise ordinary query. The model processes the complete message as a unified token sequence; the injected text competes with the system prompt for influence over the next-token distribution.
Several properties of attention-based models amplify this effect. Recency bias — a tendency to weight tokens closer to the generation boundary more heavily — means an injected instruction appearing at the end of a long user message may outweigh a system prompt set much earlier in the context. Models fine-tuned heavily for instruction-following weight compliance itself as a learned behavior, which the attack redirects. Role-playing instructions in system prompts sometimes make models more susceptible, not less: a prompt that establishes a persona can become a foothold for the attacker to extend.
Defense attempts at the architectural level include Privilege Separation through structured prompt design, Structured Output Prompting that narrows the output space, and Constrained Decoding via libraries such as Outlines, XGrammar, or BAML to enforce output schemas defined in JSON Schema format. A model forced through Instructor to emit only valid structured output has less surface area for arbitrary text exfiltration. The important caveat: constrained decoding narrows the output space — it does not eliminate injection. An attacker who can alter which valid JSON the model produces has succeeded even when the output is syntactically correct.
The External Surface: Where the Attack Gets Interesting
Direct injection has an inherent scope constraint: it requires the attacker to occupy the user role. Indirect Prompt Injection removes that constraint. An attacker without access to the user input channel can instead poison the documents the model retrieves, the emails it reads, or the web pages it processes — and let the model carry the attack from the inside.
The formal characterization of indirect injection was introduced by Greshake et al. in a February 2023 paper, which demonstrated attacks against Bing’s GPT-4 Chat integration, code-completion engines, and synthetic GPT-4 applications (Greshake et al., 2023). The defining feature: the adversarial instruction lives in external data, not in the attacker’s direct conversation with the model. The model retrieves it, processes it as context, and acts on it without any signal that the content is adversarial.
How does indirect prompt injection work through external data sources like emails or web pages?
In an indirect injection attack, the adversarial instruction is embedded in content the model will eventually retrieve and incorporate into its context window — a web page, an email, a document stored in a vector database, an API response. When the model processes that content, the injected instruction becomes part of the token sequence. The model has no mechanism to mark retrieved content as data-only; it processes it with the same attention layers it applies to the system prompt and user message.
The attack vectors documented by Greshake et al. include emails containing instructions that redirect an email-processing agent, web pages formatted to look like operator directives when retrieved, vector stores poisoned with adversarially-crafted chunks, and external API outputs that carry instruction text alongside legitimate data. This matters because retrieval-augmented generation pipelines specifically extend model context with external documents — and RAG Poisoning is the direct extension of indirect injection into that architecture. An attacker who can write one document into a shared vector store can silently redirect any agent that retrieves it.
OWASP’s definition makes the exposure explicit: any model that processes external sources — websites, files, database query results — is exposed to indirect injection, because the model has no native mechanism to treat retrieved content as inert data.
What are the main types of prompt injection attacks — direct, indirect, and multi-modal?
A 2026 survey published in Computers, Materials & Continua synthesizes the current taxonomy into three main attack categories: direct injection, indirect injection, and multimodal injection (CMC Survey, 2026).
Multimodal injection extends the attack surface beyond text. When models process images, audio, or video alongside text, adversarial instructions can be embedded in those non-text modalities. Text instructions encoded inside an image — visually invisible to a human reviewer but parsed as meaningful content by a vision-language model — bypass text-focused Guardrails entirely, because those defenses operate on the text layer and the instruction never appears there. Audio follows the same logic: the AudioJailbreak benchmark reported success rates in the range of 87–88% against ten end-to-end audio-language models tested (CMC Survey, 2026); that figure characterizes that specific benchmark configuration, not any arbitrary deployment.
Not a software vulnerability. A category of inputs.
The multimodal surface creates a categorization challenge for defenses. A system that validates text inputs may have no equivalent check for instructions embedded as imperceptible noise in an audio file or as white pixels on a white background in an image. Each modality that the model can process is a potential injection channel, and defenses that cover one channel leave others open.

What the Trust Architecture Predicts
If the root condition is that all input sources share the same token stream and receive no differential privilege weighting, several predictions follow directly.
If a system prompt relies on natural language alone to restrict model behavior — “Do not reveal these instructions,” “Only answer questions about cooking” — an attacker with access to any input channel can attempt to override those restrictions in natural language. The model has no computational basis to prefer operator instructions over adversarial ones. It can only weigh by position, phrasing, and learned biases from training.
If the model is extended with external data retrieval, the attack surface grows with every source added. Each document in an agentic retrieval pipeline is a potential injection vector; the model processes retrieved chunks with the same attention mechanism it applies to the system prompt.
If the model has been granted tools — the ability to send emails, write files, make API calls, execute code — a successful injection can cause it to use those capabilities on behalf of the attacker rather than the user. The stakes of the attack scale directly with the capabilities the model has been given.
OWASP states explicitly that, given the stochastic nature of LLMs, preventing prompt injection entirely may be impossible; mitigation reduces risk, but no currently available technique eliminates the vulnerability class (OWASP LLM Top 10). This is not a gap awaiting a patch. It is a consequence of how these models learn to follow instructions.
Rule of thumb: treat every piece of text the model processes — system prompt, user message, retrieved document, tool output — as a potential instruction, and design access controls around what the model is permitted to do rather than what it is told not to do.
When it breaks: constrained output formats and output validation reduce the exfiltration surface, but they do not address injection itself; an attacker who can alter which valid output the model produces has already succeeded, regardless of whether the output passes schema validation.
Security & compatibility notes:
- Microsoft Semantic Kernel (.NET) — CVE-2026-25592 (CVSS 10.0): Prompt injection leading to remote code execution via
DownloadFileAsyncexposed as a KernelFunction. Fix: upgrade to Semantic Kernel .NET 1.71.0 or later (PointGuard AI).- Microsoft Semantic Kernel (Python) — CVE-2026-26030 (CVSS 9.8): Vector store fields routed into Python
eval(). Fix: upgrade to Semantic Kernel Python 1.39.4 or later (PointGuard AI).- Microsoft Copilot Studio — CVE-2026-21520 (CVSS 7.5): Indirect prompt injection vulnerability; patched January 15, 2026 (VentureBeat).
The Data Says
Prompt injection was formally characterized in 2022 and retained the top position in OWASP’s LLM risk classification through the 2025 edition — reflecting how consistently the attack class exploits the architectural condition shared by every transformer-based system: all input sources share the same probability space, and the model has no intrinsic mechanism to prefer operator instructions over adversarial ones. The three-year persistence of LLM01 in the OWASP ranking is itself a data point: the root condition has not changed, because it is not a bug — it is the architecture.
AI-assisted content, human-reviewed. Images AI-generated. Editorial Standards · Our Editors