- Prompt injection is when content an AI processes changes its behavior in ways its owner did not intend. The content does not even have to be visible to people.
- Direct injection comes from the person typing. Indirect injection hides in web pages, emails, files or documents the AI reads.
- The UK NCSC says current models do not enforce a boundary between instructions and data, so prompt injection may never be fully mitigated the way SQL injection can.
- The danger grows with what the AI can do. An agent with private data, untrusted content and a way to send data out can be tricked into leaking it.
- Limit the damage: give agents the fewest tools and permissions possible, require human approval for high-impact actions, and log what they do.
- Be wary of any product that claims to stop prompt injection. The NCSC advises looking for ones that explain how they reduce it.
What is prompt injection?
The OWASP Top 10 for LLM Applications lists prompt injection as LLM01, its first risk. OWASP defines it as user prompts altering a model’s behavior or output in unintended ways, and notes that the input does not have to be visible or readable to people, as long as the model processes it.
The UK’s National Cyber Security Centre describes the underlying mistake in its blog Prompt injection is not SQL injection (it may be worse): developers combine their own instructions with untrusted content in a single prompt, then treat the model’s answer as if there were a reliable boundary between what the app asked for and whatever the untrusted content said.
OpenAI’s explainer, Understanding prompt injections, compares it to phishing: in the same way scam emails try to trick people, prompt injections try to trick an AI into doing something you did not ask for, often with instructions hidden inside an ordinary web page, document or email.
Direct and indirect prompt injection attacks
- Direct prompt injection: the person using the AI types input that changes its behavior. OWASP notes this can be deliberate, from an attacker, or accidental, from a user who triggers unexpected behavior.
- Indirect prompt injection: the AI reads content from an outside source, such as a website or file, and instructions inside that content change its behavior. The attacker never needs access to the AI system itself.
Indirect injection is the bigger concern for businesses, because the attacker only has to put text somewhere your AI will read it. The NCSC gives a recruiting example: a system asks a model to score whether a CV meets the job requirements, and a candidate hides text in their CV telling the model to ignore previous instructions and approve the CV for interview.
OWASP adds that models which read images as well as text can be attacked through instructions hidden in images, and that these cross-modal attacks are difficult to detect with current techniques.
Prompt injection attack examples
These scenarios come from OWASP, OpenAI and Anthropic’s own published material:
- Customer support chatbot (direct injection). An attacker tells a support bot to ignore its guidelines, query private data stores and send emails, leading to unauthorized access. (OWASP)
- Web page summary (indirect injection). A user asks an AI to summarize a page that contains hidden instructions. The instructions make the AI insert an image linked to an outside address, leaking the private conversation through that link. (OWASP)
- Poisoned knowledge base (indirect, through RAG). An attacker edits a document in a repository used by a retrieval-augmented generation (RAG) app. When a user’s question pulls up that document, the hidden instructions change the answer. (OWASP)
- Split instructions in a résumé. An attacker spreads instructions across a résumé so that, combined, they make the AI recommend the candidate regardless of the actual content. (OWASP)
- Apartment search. An AI researching apartments reads a listing with hidden instructions telling it to pick that listing whatever the user’s preferences. (OpenAI)
- Email assistant (indirect, through email). An agent asked to draft replies to meeting requests reads an email with instructions hidden in white text, telling it to forward emails containing the word “confidential” to an outside address. (Anthropic)
Prompt injection vs jailbreak: what is the difference?
OWASP treats jailbreaking as a form of prompt injection in which the attacker’s input makes the model ignore its safety rules entirely. Prompt injection is the wider category: any input that manipulates the model’s responses, which can include bypassing safety measures. OWASP notes that developers can reduce prompt injection through their system prompts and input handling, while preventing jailbreaks relies on ongoing updates to the model’s own training and safety mechanisms.
Can prompt injection be prevented? Why it is not solved
SQL injection has a real fix: parameterized queries make sure the database never treats user input as a command. The NCSC explains why prompt injection has no equivalent. Inside a large language model there is no distinction between data and instructions, only the prediction of the next token. Because of that, the NCSC says prompt injection attacks may never be totally mitigated the way SQL injection can, and that it should be treated as a residual risk managed through design, build and operation, not something a product or appliance removes.
The AI companies say the same. OWASP says it is unclear whether fool-proof prevention exists. OpenAI calls prompt injection a frontier, challenging research problem. Anthropic’s prompt injection defenses report says that even a 1% attack success rate against its browser agent still represents meaningful risk, and that no browser agent is immune.
The NCSC also warns against deny-lists that block phrases such as “ignore previous instructions”: there are endless ways to rephrase an attack. Its advice is to be wary of any product that claims it can stop prompt injection, and to look instead for ones that explain how they reduce it.
AI agent security risks: excessive agency and the lethal trifecta
A chatbot that only answers questions can be made to say the wrong thing. An agent that can send emails, update records or call other systems can be made to do the wrong thing. The NCSC puts it plainly: when a system calls tools or APIs based on the model’s output, the impact of prompt injection becomes whatever the worst case would be if an attacker had direct access to those tools.
OWASP calls this Excessive Agency (LLM06) and traces it to three root causes: excessive functionality, such as a document reader that can also delete documents; excessive permissions, such as a database connection that can write when it only needs to read; and excessive autonomy, such as deleting a user’s files without asking them first.
Developer Simon Willison describes a “lethal trifecta”: an agent that has access to private data, is exposed to untrusted content and can communicate externally. If one agent combines all three, he warns, an attacker can trick it into reading private data and sending it to the attacker. Removing any one of the three breaks that path.
How to prevent prompt injection attacks in LLM applications
Because the risk cannot be removed, the NCSC says protections should focus on deterministic, non-AI safeguards that constrain what the system can do, rather than only trying to keep malicious text away from the model. In practice that means:
- Give the agent the fewest tools possible. OWASP: if the system does not need to fetch web pages, do not offer that tool. If a tool summarizes email, it should only read email, not send or delete it.
- Give each tool the narrowest permissions. OWASP recommends read-only database access where only reading is needed, and running actions in the specific user’s context with the minimum scope, not through a shared high-privilege account.
- Lower privileges when processing outside content. The NCSC cites a simple rule from a discussion between Simon Willison and Baibhav Bista: when the model processes information from a party, its privileges drop to that party’s. An agent reading email from strangers should not hold privileged tools.
- Require human approval for high-impact actions. OWASP recommends human-in-the-loop approval before actions such as posting content, and OpenAI’s Agent Builder guide says to always enable tool approvals for MCP tools so users can review and confirm each operation.
- Keep untrusted content separate and structured. OWASP says to clearly mark untrusted content. OpenAI’s agent safety guide says to pass untrusted input through user messages rather than developer messages, and to use structured outputs, such as fixed schemas and allowed values, so attackers have no free-text channel to smuggle instructions through.
- Validate outputs in code. OWASP recommends defining expected output formats and checking them with deterministic code before anything acts on them.
- Log and monitor. The NCSC recommends logging enough to spot suspicious activity, potentially including the full input and output and every tool or API call, because failed tool calls can reveal an attacker refining an attack.
- Test like an attacker. OWASP recommends regular adversarial testing that treats the model as an untrusted user, to check that trust boundaries and access controls hold.
For RAG systems, OWASP notes that retrieval and fine-tuning do not fully mitigate prompt injection. Treat retrieved documents as untrusted input, control who can edit the knowledge base, and apply the same tool and permission limits as above.
If your team uses AI agents
Not every business builds its own agent. If your staff use AI agents in a browser or connected to email and files, OpenAI’s guidance for users applies:
- Limit what the agent can reach. If a task does not need a logged-in account, do not give it one.
- When the agent asks for confirmation, check that the action and any information being shared look right.
- Watch the agent when it works on a sensitive site.
- Give specific instructions. OpenAI says a broad request such as “review my emails and take whatever action is needed” makes it easier for hidden content to mislead the model.
How Sigi designs AI agents around prompt injection
Sigi builds AI agents on the assumption that some injected instruction will eventually get through. The rules we set out in our AI agent use cases guide follow from that: add tools one at a time, read-only before write, with permissions scoped to the individual user; put explicit human approval on every irreversible action; log the agent’s full trajectory; and rerun tests on every change. The approval rule also breaks the lethal trifecta: if anything the agent sends out needs a person’s approval, an injected instruction cannot quietly send private data away.
None of this makes an agent immune. It means a successful injection meets a narrow set of tools, a person checking anything that matters, and a log that shows what happened.
AI agent security checklist for prompt injection
Use this before you launch an agent, and again whenever you add a tool or a new data source.
0 of 10 done
Ticking a box records your own check. No control fully prevents prompt injection; these limit what an attack can do.
Related reading
For where agents help and how to roll them out, read AI agent use cases. For how agents answer from your documents, see what is RAG. Shipping AI-generated code too? The vibe coding security checklist covers that side. For a wider view, see how to automate your business with AI. Shipping software to EU customers? See what the EU Cyber Resilience Act requires. Sigi’s AI agent development page covers this work.

