Skip to main content
AI strategy

Prompt Injection Prevention: A Security Checklist for Teams Building AI Features

Why prompt injection cannot be filtered away, a quick test to find risky AI features, six design patterns that contain it, and a checklist for your team.

By Jayson Hao7 min read
Tactile paper and metal editorial artwork for Prompt Injection Prevention: A Security Checklist for Teams Building AI Features
Editorial field noteITL / № 36

Key takeaways

  • The UK NCSC (December 2025) says current LLMs do not enforce a security boundary between instructions and data, so prompt injection may never be fully mitigated the way SQL injection was.
  • A feature is high risk when it combines private data, untrusted content and a way to send data out; removing any one of the three breaks the most damaging attacks.
  • Filters reduce attacks but do not stop them: in Anthropic's 2025 browser-agent tests, mitigations cut attack success from 23.6% to 11.2%, not to zero.
  • Put the real controls in deterministic code: least-privilege tool access, human approval for consequential actions, and logs of full inputs, outputs and tool calls.

What is prompt injection, and how is indirect injection different?

OWASP defines a prompt injection vulnerability as one where prompts alter a model's behaviour or output in unintended ways. In a direct injection, the person typing into your chatbot tries to override its instructions. In an indirect injection, the model reads outside content, such as a web page, an email, a PDF or a support ticket, and hidden text in that content changes what it does. OWASP notes the injected text does not even need to be visible to a human, as long as the model parses it.

Indirect injection is the one product teams underestimate. The NCSC gives the example of a recruiter using an AI tool to screen CVs: a candidate can hide instructions in their own CV, and the system processes them as if they came from the recruiter. Any feature that summarises, classifies or acts on content written by someone other than your user has this exposure.

Why prompt injection cannot be filtered away

SQL injection was solved at the root by parameterised queries, which keep code and data in separate channels. The UK National Cyber Security Centre argued in December 2025 that this comparison is dangerous: current large language models simply do not enforce a security boundary between instructions and data inside a prompt, so prompt injection may never be totally mitigated in the same way. It describes the model as an inherently confusable deputy and concludes that the goal is to reduce the likelihood and the impact of an attack. If a system cannot tolerate the remaining risk, the NCSC says, it may not be a good use case for an LLM.

OWASP reaches the same conclusion from a different angle: because model outputs are probabilistic, it is unclear whether fool-proof prevention exists. Published test results show what that means in practice. When Anthropic red-teamed its Claude in Chrome browser agent in August 2025 with 123 test cases across 29 attack scenarios, attacks succeeded 23.6% of the time without its new defences. With site permissions, action confirmations, improved system prompts and classifiers, the rate fell to 11.2%. That is a large improvement and still far from a guarantee, which is why the controls that matter most sit outside the model.

The lethal trifecta: a quick test for risky AI features

Developer Simon Willison's lethal trifecta, published in June 2025, is the fastest way to triage a feature. An AI agent is exposed to data theft when it has all three of: access to private data, exposure to untrusted content, and the ability to communicate externally. An attacker plants instructions in the untrusted content, the model reads private data, and the external channel carries it out. The NCSC blog endorses a related rule: when a model processes input from a party, its privileges should drop to that party's level.

In a feature review, we list each AI feature with three yes-or-no columns. Any row with three yeses gets redesigned before launch, usually by removing the outbound channel (no arbitrary URLs, no email sending, no rendering of external images in output) or by splitting the feature so that the part reading untrusted content never touches private data.

Six design patterns that contain prompt injection

A June 2025 paper by researchers from IBM, Invariant Labs, ETH Zurich, Google, Microsoft and others, Design Patterns for Securing LLM Agents against Prompt Injections, states the core principle plainly: once an agent has ingested untrusted input, it must be constrained so that it is impossible for that input to trigger any consequential actions. It proposes six patterns, each trading some flexibility for that guarantee.

  • Action-Selector: the model only maps a request to one of a fixed set of actions and never sees the results. Good for a support bot that routes tickets or triggers predefined workflows.
  • Plan-Then-Execute: the model commits to a plan before reading untrusted data, so tool outputs cannot add new actions. Injected text can still corrupt the data passed along, but not choose what runs.
  • LLM Map-Reduce: each untrusted document is processed by an isolated model call that returns a constrained result, such as a yes/no or a number, before anything is combined. Useful for screening many CVs, reviews or invoices.
  • Dual LLM: a privileged model plans and calls tools but never sees untrusted text; a quarantined model with no tools reads it and returns references the privileged side handles as opaque values.
  • Code-Then-Execute: the model writes a program up front, and that program, not the model, decides how data flows between tools.
  • Context-Minimization: content that could carry an injection, including the user's own prompt, is removed from the context once it has served its purpose.

Prompt injection prevention checklist for product teams

This is the checklist we apply when we design an AI feature. It combines OWASP's seven mitigations with the NCSC's advice and the lethal trifecta test, ordered so that the controls that do not depend on the model come first.

  • Give the application its own credentials with the narrowest scopes, and run privileged operations in code rather than exposing them as open-ended model tools.
  • Require human approval for consequential actions: payments, sending messages, deleting or sharing data, and changes to permissions.
  • Authorise every tool call against the end user's own permissions. A model refusal is not access control.
  • Define the expected output format and validate it with deterministic code before anything downstream uses it.
  • Mark untrusted content clearly, for example by wrapping it in tags and telling the model it is data, while treating this as a speed bump, not a wall.
  • Add input and output filtering, but do not rely on deny-lists of known attack phrases; the NCSC notes attackers can rephrase endlessly.
  • Block the quiet exfiltration channels: links and images rendered from model output, and fetches to URLs the model chose.

How to test and monitor for prompt injection

OWASP recommends regular adversarial testing that treats the model as an untrusted user, checking whether trust boundaries and access controls hold. Build a small attack suite from your own data types: a support ticket with hidden instructions, a PDF with white-on-white text, a product review that asks the assistant to reveal its system prompt. Run it in CI whenever prompts, models or tools change, and track the success rate over time rather than aiming for a single pass.

For Japanese teams, the AI Safety Institute's Guide to Red Teaming Methodology on AI Safety, revised by IPA in April 2025, walks through an actual red-teaming exercise on a RAG system and includes example deliverables, which makes it a practical template for planning these tests. For monitoring, the NCSC suggests logging enough to spot suspicious activity, potentially including the full input and output of the model along with tool use and API calls. Failed tool calls deserve alerts, because they can be the first sign of an attacker probing.

Buying an AI tool or guardrail: questions to ask vendors

The NCSC's advice to buyers is blunt: beware any vendor that claims it can stop prompt injection, and prefer those that explain how they reduce the risk. Willison makes a similar point about guardrail products that advertise detection rates: in web application security, 95% is very much a failing grade.

  • Which actions can the AI take without a human confirming them, and can we turn each one off?
  • Does the AI act with the end user's permissions or with a shared service account?
  • Can the product send data to destinations the model chooses, including links and images in responses?
  • What do you log, how long do we keep it, and can we export it to our own security tools?
  • What were the results of your most recent adversarial testing, and how was it scoped?

About the author

Jayson Hao

Founder of Innovation Trigger Lab and a University of Toronto Computer Science graduate with an AI/ML focus. He designs and ships production RAG systems, AI chatbots, web platforms and mobile products.

View profile

Frequently asked questions

Can prompt injection be completely prevented?

Not with current models. OWASP says it is unclear whether fool-proof prevention exists, and the UK NCSC says it may never be totally mitigated. Design so that a successful injection cannot cause serious harm.

What is the difference between prompt injection and jailbreaking?

OWASP treats jailbreaking as a form of prompt injection in which the input makes the model ignore its safety rules entirely. Prompt injection is the broader category, including indirect attacks hidden in documents and web pages.

Does a strong system prompt stop prompt injection?

It helps a little but is not a security control. OWASP lists constraining model behaviour as one mitigation among seven, and the NCSC recommends focusing on deterministic, non-LLM safeguards instead.

Is a RAG chatbot vulnerable to prompt injection?

Yes. Any document in the index can carry indirect instructions. The risk rises sharply if the chatbot can also call tools, read private data or render links and images in its answers.

Sources and further reading

  1. 1.
    LLM01:2025 Prompt InjectionOWASP Gen AI Security Project
  2. 2.
    Prompt injection is not SQL injection (it may be worse)UK National Cyber Security Centre, December 8, 2025
  3. 3.
    Design Patterns for Securing LLM Agents against Prompt InjectionsarXiv (Beurer-Kellner et al.), June 10, 2025
  4. 4.
  5. 5.
    Piloting Claude in ChromeAnthropic, August 25, 2025
  6. 6.
    AI Safety Institute revises its Guide to Red Teaming Methodology on AI SafetyIPA (Information-technology Promotion Agency, Japan), April 2, 2025