Prompt injection
Prompt injection is an attack where text fed to a language model, typed by a user or hidden in a web page, file or tool result, changes the model's behaviour in ways its developer did not intend.
Also called: indirect prompt injection, direct prompt injection
By Divya Sharma · Checked Nov 15, 2026 · How we review
LLMs read instructions and data through the same channel: text. A model cannot reliably tell a developer's system prompt from a sentence an attacker planted in an email it was asked to summarise. OWASP lists prompt injection first in its Top 10 for LLM applications.
Direct and indirect
In a direct injection, the user types the attack, for example asking the bot to ignore its earlier instructions. In an indirect injection, the attack arrives inside content the model processes: a web page, a PDF, a code comment, a calendar invite or the description of an MCP tool. The user may never see it. Greshake et al. showed that LLM-integrated applications blur the line between data and instructions, which lets an attacker reach the model without any direct access.
Why it matters for agents
A chatbot that only writes text can be embarrassed. An agent that can read files, call APIs and send messages can be steered into acting. The worst cases chain injection with data exfiltration: the planted text tells the agent to collect private data and send it somewhere. Tool poisoning is a form of indirect injection delivered through tool metadata.
How it differs from a jailbreak
A jailbreak tries to make the model break its own safety training. Prompt injection tries to override the application's instructions. The techniques overlap, and the same text can do both.
Defences
There is no complete fix today. Common layers are input and output guardrails, keeping untrusted content clearly separated, narrow agent permissions, an agent sandbox, and human approval before sensitive actions. See the OWASP entry for the full list of mitigations.
Related terms
- Jailbreak (LLM)
- A jailbreak is a prompt or technique that gets a language model to produce output its safety training is meant to refuse, such as harmful instructions, by role-play, obfuscation, odd encodings or long adversarial text.
- Data exfiltration (AI agents)
- Data exfiltration, for AI agents, is when an attacker tricks an agent into reading private data it can access and sending it out, through a web request, an email, an image link or another channel the attacker controls.
- Agent sandbox
- An agent sandbox is an isolated environment, such as a container, virtual machine or operating-system restriction, in which an AI agent runs code and commands so it cannot reach files, networks or data outside set limits.
- Tool poisoning
- Tool poisoning is an attack where a malicious tool, often an MCP server, hides instructions in its tool description or metadata; the AI model reads them as guidance and may leak data or misuse other tools without the user noticing.
- Guardrails (AI)
- Guardrails are runtime checks placed around a language model that inspect inputs and outputs and block, rewrite or redirect them, so an application stays on topic, avoids harmful content and follows rules the model alone would not reliably keep.