Guide
What Is Prompt Injection?
Prompt injection, explained for security leaders: how it works, the difference between direct and indirect attacks, why AI agents turn it from an embarrassment into a breach, and the layered defenses that limit it.
By Chief Security Officer Brief Editors · Updated
Prompt injection is an attack on an AI system in which someone places instructions in the text a language model reads, so that the model follows those instructions instead of, or as well as, the ones its user and its developer gave it. The text can be typed straight into a chat box, or hidden in an email, a web page, a document, a code comment or a tool description that the model is later asked to read.
It works because a language model receives everything as one stream of text. The system prompt, the user's request and the contents of the file it was asked to summarize all arrive the same way, and the model has no reliable way to tell an instruction it should obey from data it should only read. That is why prompt injection sits first on the OWASP Top 10 for LLM Applications, and why no vendor can honestly promise to have eliminated it.
How prompt injection works
Traditional injection attacks, such as SQL injection, exploit a program that mixes code and data in one string. Those were largely solved by keeping the two apart, for example with parameterized queries. Language models have no equivalent separation: instructions and data are both just text, and the model decides what to do from all of it at once.
An attack therefore needs only two things: a way to get text in front of the model, and wording that persuades the model to treat that text as an instruction. The first is easy whenever a system reads content from outside the organization. The second is a matter of trial and error, and attackers share what works.
- The model is given a job. A user asks an assistant to summarize an inbox, answer from the knowledge base or fix a bug in a repository.
- It reads content someone else controls. An inbound email, a retrieved document, a web page, a ticket, a pull request or the description of a tool it can call.
- That content contains instructions. Sometimes plainly worded, sometimes hidden in white text, HTML comments, metadata or formatting a person would never notice.
- The model follows them. It changes its answer, reveals data it can see, or calls tools with the permissions it was given, and the user may never know.
Go deeperSeven Security Tests Every Enterprise AI Deployment Must Pass
Direct vs. indirect prompt injection
Security teams usually split prompt injection into two kinds. They share a cause but differ in who the attacker is and where the defenses have to sit.
For an enterprise, indirect prompt injection is usually the bigger concern. Every connector that lets an assistant read outside content is a path for an outsider's instructions, and the attack runs with the access of whoever asked the assistant for help.
| Direct prompt injection | Indirect prompt injection | |
|---|---|---|
| Who writes the instruction | The person using the AI system. | A third party who never touches the system, through content it later reads. |
| Where it arrives | In the chat box or API request. | In emails, documents, web pages, retrieved knowledge-base entries, code, tickets, tool descriptions and tool outputs. |
| Typical goal | Get around the system's rules, extract its system prompt or make it produce content it should refuse. | Make the system act against its own user: leak what it can see, take actions with the user's access or mislead the user. |
| Who is harmed | Mostly the operator of the system, through misuse and reputational damage. | The user and the organization whose data and systems the AI can reach. |
| Why it is hard to stop | The attacker can try endlessly and adjust wording each time. | The user did nothing wrong, the content may look harmless to a person, and the system was asked to read it. |
Go deeperAdversarial Techniques Against RAG Systems in Enterprise AI · Agent Memory Poisoning in Multi-Tenant Enterprise Environments
Why AI agents raise the stakes
When a model can only produce text, a successful injection mostly produces a bad answer. When the model is an agent that can call tools, read files, send messages and change records, an injected instruction becomes an action taken with real credentials. What an attacker can do is bounded by what the agent can reach, not by what the attacker can reach.
- Data exfiltration. The agent is told to gather sensitive data it can see and send it out, through an email, an API call, or a link or image URL that carries the data to a server the attacker controls when it is rendered.
- Tool misuse. The agent calls tools it was legitimately given, such as payments, ticket updates or file deletion, for the attacker's purpose.
- Lateral movement. An agent connected to several systems can be steered from one to the next, chaining access no single person was meant to have.
- Persistence through memory. An injected instruction saved to an agent's long-term memory or a shared knowledge base keeps acting on later sessions and other users.
- Poisoned tools. Instructions hidden in an MCP server's tool descriptions or outputs reach every agent that connects to that server.
A widely reported example is EchoLeak (CVE-2025-32711), a vulnerability in Microsoft 365 Copilot disclosed in 2025, in which a crafted email could lead the assistant to send internal data out without the user clicking anything. Microsoft fixed it; the pattern behind it, an assistant that reads outside content and can reach internal data, is present in many deployments.
Go deeperLateral Movement Risks When AI Agents Access Internal APIs · Governing Tool Access and Blast Radius When Agents Span Multiple MCP Servers · MCP Attack Surface Created by Protocol-Level Integration Unification
Where prompt injection hides
Any content an AI system reads can carry an injection. These are the places security teams most often have to account for.
- Email and calendar invites. Anyone outside the company can send them, and assistants are routinely asked to summarize and act on them.
- Documents and knowledge bases. Files shared from outside, uploaded by customers or pulled into a retrieval index can carry instructions that surface whenever they are retrieved.
- Web pages. Browsing and research agents read pages written by anyone, including text styled to be invisible to a human reader.
- Code and repositories. Comments, README files, issues and pull requests are read by coding assistants that may be able to run commands.
- Tool descriptions and tool outputs. MCP servers and plugins describe their tools to the model in text, and return results as text, both of which the model reads as context.
- Images and files the model can parse. Text inside images, PDFs and spreadsheets is read by multimodal models just as typed text is.
Go deeperTool-Level RBAC Gaps in Native MCP Servers and the Security Risk of Trusting Vendor Claims · MCP Server Provisioning Standards for Enterprise Security Teams
How to defend against prompt injection
There is no single control that stops prompt injection, and filters that look for malicious wording can be reworded around. Mature programs assume some injections will get through and design so that a hijacked model cannot do much harm.
- Limit what each agent can reach. Give agents only the tools, data and permissions their task needs, scoped to the user they act for, so an injected instruction has little to work with.
- Keep untrusted content away from powerful tools. An agent that reads outside content should not also hold broad write access or a path to send data out; split those jobs between agents or sessions where you can.
- Require a person for consequential actions. Payments, deletions, external messages and permission changes should wait for explicit human approval that shows exactly what will happen.
- Treat model output as untrusted. Validate it before it reaches other systems, and block automatic rendering of links and images to unapproved domains, a common exfiltration route.
- Inspect inputs and outputs at a control point. A gateway between agents and their tools can screen tool inputs, outputs and descriptions for injected instructions and sensitive data, and enforce one policy across every agent.
- Log every action and watch for anomalies. A record of which agent called which tool, for whom and with what arguments is how an injection is detected and investigated after the fact.
- Test it like any other attack surface. Red-team AI systems with known injection techniques before launch and after every change to their tools, data sources or models.
The OWASP Top 10 for LLM Applications, MITRE ATLAS and NIST's taxonomy of adversarial machine learning attacks (NIST AI 100-2) all describe prompt injection and its mitigations, and are the places to check current guidance as techniques change.
Go deeperEnforcement Controls CSOs Must Demand Before Agents Reach MCP Server Connections · AI Policy Enforcement Mechanisms Beyond the Acceptable Use Document · Incident Response Playbook Design for AI Agent Breaches
What security leaders should ask about prompt injection
Whether the AI system is built in-house or bought, these questions show how exposed it is. Ask vendors to demonstrate the answers rather than describe them, and check each against their own documentation.
- What outside content does it read? Every source that someone outside the company can write to is a path for an injection.
- What can it do with what it reads? List the tools, data and credentials the system holds, and which actions it can take without a person approving them.
- How can data leave? Outbound email, web requests, rendered links and images, and tool calls to external services are all exits an injection can use.
- What happens when an injection is detected? Whether the call is blocked, the session ended, the user warned and the security team alerted, and how quickly.
- How has it been tested? Ask when it was last red-teamed for prompt injection, by whom, and what changed as a result.
Frequently asked questions
Is prompt injection the same as jailbreaking?
They overlap but are not the same. Jailbreaking tries to get a model to break its own safety rules, usually by the person using it. Prompt injection is about whose instructions the model follows, and the most damaging cases come from a third party, through content the model reads, against the user's interests.
Can prompt injection be fixed?
Not fully, with today's models. Because instructions and data reach the model as the same kind of text, model providers and security researchers treat it as a risk to be reduced and contained rather than a bug with a patch. Specific products do get fixes for specific exploits.
Do guardrail and filtering products stop it?
They catch many known patterns and are worth having, but attackers can reword around them. Treat detection as one layer, alongside least-privilege tool access, human approval for consequential actions and logging.
Does a system prompt telling the model to ignore other instructions help?
A little, and not reliably. Instructions in the system prompt are text competing with other text, and well-crafted injections regularly override them. They should not be the only control.
Who owns prompt injection risk?
Engineering teams build the mitigations into each AI system, but deciding what agents may reach, what needs human approval and how incidents are handled are security decisions, and the security leader should own them.





