Prompt Injection
Also known as: Indirect prompt injection
Security vulnerability in which crafted text causes an AI model to follow an attacker's instructions instead of those of its developer or user.
Prompt injection exploits a basic property of large language models: they process instructions and data as the same stream of text and cannot reliably tell them apart. If an application feeds untrusted content to a model, such as an email, web page, document or tool output, text inside that content can masquerade as instructions. In direct prompt injection, a user types the malicious input; in indirect prompt injection, the instructions are hidden in material the model reads while performing a task, possibly without the user ever seeing them.
The weakness was demonstrated publicly in 2022, and the developer Simon Willison popularized the name by analogy with SQL injection, a classic flaw in which data is interpreted as code. Researchers soon showed that indirect injection could target chatbots that browse the web or read documents. The risk grows with agentic AI: an agent with access to email, files or payments that reads attacker-controlled content may be steered into leaking data or taking unwanted actions. The OWASP Top 10 for large language model applications ranks prompt injection as its leading risk.
As of 2025 there was no complete fix, because the problem stems from how language models work rather than from a single bug. Defenders rely on layered mitigations: treating all model output as untrusted, applying the principle of least privilege to tools and data, isolating untrusted content, filtering inputs and outputs, monitoring behavior and requiring human confirmation for sensitive actions. Model developers also train models to resist injected instructions, but such training reduces rather than eliminates the risk. Prompt injection is distinct from jailbreaking, which targets a model's own safety rules.
Key points
- Prompt injection arises because language models mix instructions and data in a single text stream.
- Indirect injection hides malicious instructions in documents, web pages or tool outputs the model reads.
- AI agents with access to tools and data face the greatest risk from injected instructions.
- Defenses are layered, including least privilege, isolation of untrusted content and human confirmation.
Related entries
Jailbreak (AI)
Technique for bypassing the safety restrictions of an AI model so that it produces content or actions its developers intended it to refuse.
Agentic AI
AI systems that pursue goals by planning and carrying out multi-step actions, such as using tools and software, with limited human supervision.
SQL Injection
Web application vulnerability in which untrusted input is interpreted as part of a database query, letting attackers read, change or delete data.
OWASP Foundation
Nonprofit foundation that produces free, community-built resources for improving software security, including the widely used OWASP Top 10.
Neural network trained on very large amounts of text to predict the next token, able to generate language and perform many tasks from prompts.
Principle of Least Privilege
Security principle that every user, program and process should have only the minimum access rights needed to perform its legitimate function.
Social Engineering
Manipulation of people into revealing confidential information or performing actions that compromise security, exploiting trust rather than technology.
Red Team
A group that plays the role of an adversary in authorized exercises, testing an organization's defenses, detection and response against realistic attacks.
Featured in guides
Referenced by
Other entries that discuss or point to Prompt Injection.