What is prompt injection?
Prompt injection is an attack in which text given to an AI model contains instructions that override what its developer or user intended, so the model leaks data or takes unwanted actions.
Also called: Indirect prompt injection, Jailbreak
How it works
A large language model reads its instructions and its data in the same stream of text. It cannot reliably tell the two apart. An attacker who can put text in front of the model can write something that looks like an instruction, and the model may follow it.
In direct prompt injection, the attacker types the text into the chat. In indirect prompt injection, the text hides in content the model reads later: a web page, an email, a PDF, a product review or a tool response.
Why it matters for agents
The risk grows when the model can act. An AI agent with access to email, files, payments or an internal API can be told by a hidden instruction to send data out, change settings or make a purchase. The agent's owner did not approve the action, but the agent had the permission to take it.
Examples
These are hypothetical cases of the attack.
- A web page contains hidden text telling a browsing agent to ignore its task and visit a phishing link.
- A support ticket tells an AI triage tool to mark the sender's account as verified.
- A document uploaded for review instructs a model to say it passed all checks.
How teams defend against it
No single fix exists, so teams layer controls. They give agents the least access they need, require human approval for sensitive actions, keep untrusted content apart from system instructions, and check model output before it triggers an action.
Logging what the model read and what it did helps teams find an injection after the fact. For high-risk decisions, a model's output should be one input among several, not the final word.
Related terms
- Large language model (LLM)A large language model (LLM) is a neural network trained on large amounts of text to predict and generate language. It powers chat assistants, AI agents and many text tools.
- AI agentAn AI agent is software that uses a language model to plan and take actions toward a goal, such as browsing sites, calling APIs or filling in forms, with little or no human input at each step.
- Model Context Protocol (MCP)The Model Context Protocol (MCP) is an open standard that lets AI applications connect to outside tools and data through MCP servers, using one common interface.
- Social engineeringSocial engineering is manipulating people, rather than systems, into giving up information, access or money, usually by building false trust or creating pressure.
- PhishingPhishing is a scam where attackers pose as a trusted company or person, by email, text, call or fake website, to trick people into sharing credentials, codes or money.