Prompt injection is a security vulnerability in which crafted input alters a large language model’s behavior or output in unintended ways. OWASP ranks it first in its Top 10 for LLM applications (LLM01:2025), and the input can affect the model even if humans cannot see it.
Key practices include:
How a Prompt Injection Attack on an LLM Works
Instructions and data can overlap
LLM applications process system instructions alongside user input and external content. Even when these are separated structurally, models may struggle to distinguish trusted instructions from malicious text embedded in the content they are asked to process.
Attacks can come from multiple sources
Prompt injection may be direct, through a user’s message, or indirect, through a webpage, email, uploaded document or retrieved data containing malicious instructions.
The impact depends on the application's access
An injected instruction might manipulate a summary or response, but in applications connected to sensitive data, APIs or autonomous agents, it could also contribute to data exposure or unauthorized actions. The risk increases when the application grants excessive permissions or relies on the model alone to enforce security rules.
A real case: Stanford student Kevin Liu got Microsoft’s Bing Chat to divulge its programming with a prompt that began ‘Ignore previous instructions.’
A simple example would be : Imagine a receptionist who gets one sheet of paper containing both the manager’s rules and a visitor’s note. If the note says ‘disregard the rules above’, the receptionist has no way to know the note isn’t from the manager.
Types of Prompt Injection
- Direct: The user's own prompt changes the model's behavior, intentionally or not.
- Indirect: The model accepts external input, such as websites or files, and that content alters its behavior.
OWASP’s scenarios show the range: a support chatbot told to query private data stores and send emails; a summarized web page with hidden instructions that exfiltrate the conversation through an image link; an edited RAG document; split payloads in a resume; encoded prompts (Base64, emojis); and CVE-2024-5184 in an LLM-powered email assistant.
Prompt Injection vs. Jailbreaking
Prompt injection manipulates an LLM through malicious instructions embedded in user input or external content. Jailbreaking specifically attempts to bypass a model’s safety restrictions. Although the techniques differ, they can overlap and produce similar security risks.
Learn more in What Is a Jailbreak Attack on LLMs?.
LLM Prompt Manipulation: What It Can Cause
Prompt manipulation can lead to sensitive data exposure, system prompt leakage, misleading responses or unauthorized actions through connected tools. The potential impact depends on the application’s permissions, the data it can access and the decisions it influences. Understanding these risks helps security teams prioritize safeguards based on the potential business impact.
AI Prompt Injection Defense
No single control can reliably prevent every prompt injection attack. A layered defense reduces risk by combining input validation, access restrictions, output checks and ongoing security testing.
Key practices include:
- Restrict model access to sensitive data and tools.
- Validate inputs and outputs against application requirements.
- Separate untrusted external content from trusted instructions where possible.
- Require human approval for high-impact actions.
- Test applications with realistic adversarial prompts and monitor suspicious activity.
Security teams should also recognize that filters and detection systems can miss novel attacks or incorrectly flag legitimate requests. Treat the model as one component of the security architecture, not as the sole enforcement mechanism.
One Text Stream, Two Kinds of Authority
LLMs can struggle to distinguish trusted instructions from malicious content, making prompt injection a broader application security challenge. Understanding AI security fundamentals, LLM guardrails and insecure output handling helps explain why protecting AI systems requires controls beyond input filtering alone. For a closer look at how meaning can be exploited to manipulate model behavior, explore our guide to semantic attacks on LLMs.
Ultimately, effective prompt injection defense depends on limiting trust, restricting model permissions and continuously testing safeguards against evolving attack techniques.
Frequently Asked Questions (FAQ)
1. What is the purpose of prompt injection?
Attackers use it to override instructions, leak data or trigger unauthorized actions. IBM notes researchers also use it to understand LLM capabilities and security gaps, and that it is not inherently illegal.
2. What is the difference between direct and indirect prompt injection?
In direct injection the attacker types the malicious prompt. In indirect injection the instruction hides in content the model retrieves, such as a web page or document, so the victim may never see it.
3. How do you avoid prompt injection in an LLM?
You cannot eliminate it, so layer defenses: least privilege, input and output filtering, separation of untrusted content, human approval for high-risk actions and regular adversarial testing.
Protect AI and LLMs, everywhere.
Discover AI & LLM threats, block prompt injection and jailbreak attacks, and enforce security policies at scale.
Related Content
- What Is AI Security?
- What Is a Jailbreak Attack on LLMs?
- What Is Data Poisoning in AI Models?
- What Is Insecure Output Handling in LLM Applications?
- What Is AI Supply Chain Security?
- What Are LLM Guardrails?
- What Is Retrieval-Augmented Generation (RAG) Security?
- What Is an AI Model Supply Chain Attack?
- What Are the Security Risks of Using AI?
- What Is a Semantic Attack on an LLM?