Prompt Injection: What It Is and How to Prevent It
Prompt injection can't be fully prevented with today's models, but you can contain it. Here's how it works, how serious it is for your AI, six controls that limit the damage, how to test them and the proof buyers ask for.

Prompt injection is an attack where text an AI model reads, from a user or from a document, email, web page or tool result, is treated as instructions.
Today's models can't fully block it. So the goal is to contain the threat by limiting what the model can access and do, requiring approval for consequential actions, testing regularly and keeping the evidence.
Here's what you need to know about prompt injection and the steps you can take to prevent it.
What Is Prompt Injection?
Prompt injection is an attack where instructions hidden in text an AI model processes override the instructions its developer gave it. OWASP (the Open Worldwide Application Security Project) ranks it as the top risk for large language model (LLM) applications. OWASP defines it as user prompts that "alter the LLM's behavior or output in unintended ways."
The root cause is that a language model receives the developer's instructions and the data it's working on as one stream of text, and it has no reliable way to tell them apart. If the data says "ignore your previous instructions," the model may do exactly that.
Simon Willison named the vulnerability "prompt injection" in September 2022.
What's the Difference Between Prompt Injection and Jailbreaking?
Prompt injection attacks the application built on top of a model, getting it to do something the developer forbids. Jailbreaking attacks the model's own safety rules, getting a model like ChatGPT or Claude to write something its maker forbids.
Willison draws that line firmly. OWASP treats jailbreaking as one form of prompt injection. MITRE ATLAS, MITRE's catalog of attacks on AI systems, lists them as separate techniques (AML.T0051 and AML.T0054). For defense, the distinction matters because jailbreaking is mostly the model provider's problem, and prompt injection is mostly on the team building the application.
Can Prompt Injection Be Fully Prevented?
Prompt injection can't be fully prevented with today's models, and Anthropic, Microsoft and the UK's National Cyber Security Centre (NCSC) all describe it as a risk to reduce and contain.
In Anthropic's November 2025 tests of Claude for Chrome, an adaptive attacker with 100 attempts per environment succeeded against Claude Opus 4.5 8.0% of the time with the model alone, and 1.4% with Anthropic's improved safeguards, though Anthropic still calls prompt injection "far from a solved problem."
OpenAI wrote in December 2025 that prompt injection, "much like scams and social engineering on the web, is unlikely to ever be fully 'solved.'"
Prompt injection is something you have to take steps to minimize, while understanding you can't fully eliminate it. Often, that means making sure a successful injection can't reach anything valuable or do anything irreversible.
What's the Difference Between Direct and Indirect Prompt Injection?
Direct prompt injection comes from the person typing to your AI. Indirect prompt injection is hidden in content your AI reads on its own, and for agents with tools it's the bigger risk.
With indirect injection, the instructions sit inside an email, a shared document, a web page, a support ticket, a code comment or a tool result. The attacker never has to touch your product, only get your AI to read what they planted.

Agent workflows break down into three stages: the agent takes in data, makes a judgment about it, then takes an action. Indirect injection appears in the first stage, through data the agent was supposed to read. The more inboxes, tickets, repos and web pages an agent reads, and the fewer human checkpoints it has, the more ways in there are.
Three incidents from 2025 show the pattern:
- EchoLeak (June 2025). One email made Microsoft 365 Copilot leak internal data when the user later asked Copilot a routine question, with no clicks required.
- GitHub MCP server (May 2025). A malicious issue in a public repository got a coding agent to copy private-repository data into a public pull request. It was traced to how the agent was set up, with no bug in the server code.
- ServiceNow Now Assist (November 2025). A low-privilege user's ticket text hijacked a higher-privilege agent, even with prompt-injection protection switched on.
In EchoLeak, the GitHub MCP attack and ServiceNow, the malicious content arrived through a normal, intended channel. The harm came from what the agent was allowed to do next. The same applies to any Model Context Protocol (MCP) server, the standard way to connect agents to outside tools. Each one hands an agent new tools and new content to read at the same time.
How Serious Is Prompt Injection for Your AI?
Prompt injection is as serious as the most damaging thing your AI can do with the data it can see, so you should rate the risk by what the AI can access and what actions it can take.
There's no published standard for this rating, so here's a simple three-tier view built on those stages and Willison's "lethal trifecta":
| Your AISetup | Worst realistic outcomeImpact | SeverityRating |
|---|---|---|
| Chatbot with no tools and no private data | Bad output or a leaked system prompt | Low |
| Assistant over private data (search over docs, inbox, tickets) | Data exfiltration, often through a link or image the model renders | High |
| Agent with tools or write access | The injection acts: it sends, deletes, pays, merges or runs code | Highest |
How to Mitigate Prompt Injection Risk
Though no single defense prevents prompt injection, these steps can help to limit what an attacker can access, influence and execute if an injection succeeds.

1. Give the Model the Least Access It Needs
Scope every tool, API key and data source to the task you need it to complete. An AI that summarizes support tickets doesn't need write access to your CRM, and an agent that drafts emails doesn't need permission to send them.
A common design risk is giving AI access to everything a human user can see and manage. That means a successful injection could exploit whatever permissions the agent inherits from that user. Instead, scope access by task and, where possible, use separate credentials for the AI so its access is visible and revocable on its own.
2. Cut the Paths Data Can Leave By
Prompt injection can expose sensitive data if an attacker can get the AI to transmit it outside your system. One technique is to include links or images in the model's response that point to an attacker-controlled server. The URL can contain sensitive information, which gets exposed when a browser or agent automatically loads the resource.
Restrict outbound requests from the AI's execution environment using network allowlists, and prevent model-generated links and images from automatically loading external resources. Apply the same restrictions to tools and integrations that can transmit data externally.
3. Require Human Approval for Consequential Actions
Human-in-the-loop controls are an important way to reduce the impact of prompt injection. Approval gates can stop an injected instruction before it causes damage, provided the reviewer understands exactly what they're approving.
Require approval for consequential or irreversible actions, including sending emails, making payments, deleting records, merging code or sharing data externally. Show the reviewer the exact action, target and parameters, and enforce approval in the application before execution.
Reading and drafting can generally run with less friction, but access to sensitive information should still be restricted, particularly when the agent processes untrusted content in the same session.
4. Treat Model Output as Untrusted Input
LLM output can carry an attacker's payload into whatever reads it next. Validate and sanitize output before it reaches a browser, shell, database or another agent. Use context-appropriate protections, such as HTML sanitization, parameterized database queries and strict API schemas. Never pass model-generated text directly to a function that executes it as code.
5. Mark and Separate Untrusted Content
Clearly identify retrieved content as untrusted and keep it separate from trusted system instructions. Preserve its source and trust level so the application can distinguish user instructions from external documents, emails and web pages.
This helps reduce confusion between instructions and data, but labeling alone isn't a security boundary. Enforce permissions in your application, outside the model, so untrusted content can't make the AI do more than you allow.
6. Log Everything the Model Reads and Does
Logs enable you to investigate prompt injection after it happens. Record security-relevant inputs, retrieved content, tool calls, approval decisions and outputs in tamper-resistant storage.
Redact credentials, secrets and unnecessary personal information, restrict access to logs and define retention periods. A hijacked agent may act with the user's permissions, so without visibility into the content it retrieved and the actions it took, an incident can be difficult to distinguish from legitimate user activity.
How to Test for Prompt Injection
Testing your defenses against prompt injection requires AI-specific adversarial testing. A traditional penetration test doesn't automatically cover vulnerabilities in LLM applications. Unless explicitly included in the scope, you shouldn't assume it tests for prompt injection, jailbreaks or unexpected model behavior.
A useful prompt-injection test covers:
- Direct and indirect attacks: Test malicious instructions in user prompts and content your AI retrieves or reads, including documents, emails and web pages.
- Tool-call abuse: Test whether injected instructions can make an agent call unauthorized tools, manipulate parameters or perform actions outside the user's permissions.
- Data exfiltration: Test whether an attacker can extract sensitive information through generated links, rendered images or outbound requests, where these capabilities exist.
Autonomous security testing platforms like RunSybil and XBOW can also help teams test more frequently than a traditional annual penetration test. However, check that the assessment explicitly covers LLM-specific vulnerabilities, including direct and indirect prompt injection.
How to Prove Your Prompt Injection Defenses to Buyers
SOC 2 and ISO 27001 are still core requirements for enterprise buyers, SOC 2 mainly in North America and ISO 27001 internationally. Neither shows that you've addressed the AI-specific risks buyers increasingly ask about: how you govern the AI in your product, validate its outputs and respond when a model makes a bad decision.
When a buyer asks about prompt injection, the answer that holds up is an honest one. Describe your defenses, what you've tested and when, known limitations, and who owns remediation.
Show buyers the restrictions you've placed on your AI, the test results that demonstrate those restrictions work, and the evidence of ongoing monitoring. Map your controls to relevant standards and criteria they recognize, but don't imply those standards explicitly certify your prompt injection defenses. Also publish a short posture summary in your Trust Center, and keep detailed test reports and data flows available to buyers under NDA.
How Do SOC 2, ISO 42001 and Other Frameworks Cover Prompt Injection?
SOC 2 and ISO 42001 don't explicitly name prompt injection, but both provide frameworks for addressing it.
For products built on LLMs, prompt injection should be considered as part of the ISO 42001 AI risk assessment (clause 6.1.2), particularly where it represents a realistic threat to the system. Its potential consequences should also be considered in the AI system impact assessment, which explicitly covers intended use and foreseeable misuse (clause 6.1.4). Any resulting risk treatment decisions and selected controls should be documented in the Statement of Applicability (clause 6.1.3).
SOC 2's existing Trust Services Criteria don't contain AI-specific requirements, but auditors can assess relevant safeguards under existing criteria covering risk assessment, logical access, system monitoring and change management. The specific controls expected will depend on the product, its risks and the scope of the audit.
The EU AI Act's Article 15 requires high-risk systems to resist attempts to alter their outputs by exploiting vulnerabilities, without naming prompt injection. For most high-risk systems, those obligations now start December 2, 2027.
AIUC-1 names prompt injection directly. It's a specialized standard for AI agents that includes mandatory requirements on agent actions, tool calls and output handling, and optional requirements on adversarial input detection and real-time input filtering.
Start With What Your AI Can Touch
The prompt-injection defenses that matter most are decided when you design what your AI can read, see and do. Those limits are your strongest defenses, and also what a buyer will want to understand if they ask how you mitigate the risk of prompt injection.
As a starting point, write down every data source your AI reads, every system it can see and every action it can take. That list tells you where you need to focus, and decides which controls you'll need to implement first.
If you want to dig deeper into how to prevent prompt injection or want to know more about AI risk and frameworks like ISO 42001 or AIUC-1, our AI-powered GRC practice can help. Talk to our team here.



.avif)