Skip to content
Illustrative close view of optical network connections and fibre cables.
Guide · Offensive security

What is prompt injection, and how do you test for it?

Prompt injection is when instructions hidden in a model’s input make an AI application do something its developer did not intend. It has topped the OWASP Top 10 for LLM Applications in every edition, and the UK’s National Cyber Security Centre has warned it may never be fully mitigated. This guide explains how the attacks work, what they have achieved in practice, and how to test for them and limit the damage.

Updated 9 min readGIFGIF Offensive Security
Prompt injection’s rank in every edition of the OWASP Top 10 for LLM Applications, to 2026
No. 1
Critical CVSS score of EchoLeak, a zero-click prompt injection flaw in Microsoft 365 Copilot
9.3
Agent goal hijack, the first risk in the OWASP Top 10 for Agentic Applications
ASI01
The year the term prompt injection was coined
2022

The short answer

A large language model reads everything in its context as one stream of text. Your instructions, the user’s question and any documents, emails or web pages the application feeds in all arrive together. Prompt injection exploits this: an attacker writes text the model treats as an instruction, so it follows the attacker rather than you.

In a simple chatbot that might mean an embarrassing reply. In an AI agent that can read mailboxes, query records or call tools, it can mean data leaking out or actions taken in a user’s name. The risk is set less by the model than by what the model is allowed to reach and do.

Direct and indirect prompt injection

Direct prompt injection is when a user types instructions designed to override the system’s rules, such as telling the model to ignore its previous instructions or to reveal its system prompt. Jailbreaking is a close relative, aimed at the model’s safety training rather than the application’s rules.

Indirect prompt injection is the bigger risk for most businesses. The hostile instructions sit in content the AI processes on someone else’s behalf: an email in the inbox, a shared document, a web page an agent browses, a support ticket or a record retrieved from a database. The victim never sees the instruction and may never interact with the attacker at all.

Common prompt injection routes
RouteHow the instruction arrivesTypical target
Chat inputTyped directly by a userSystem prompt, safety rules, other users’ data
Email and calendarHidden in a message or invite an assistant summarisesMailbox contents, contacts, sending email
Documents and filesWhite text, comments or metadata in a PDF, Word file or spreadsheetFiles the assistant can search, summaries given to staff
Web pagesText on a page an agent browses or a search tool retrievesBrowsing agents, research tools, purchasing agents
Retrieved recordsPlanted in a CRM field, ticket or knowledge base used for retrievalCustomer data, internal answers, downstream actions
Tool and MCP responsesReturned by a connected tool or server the agent trustsFurther tool calls, credentials, other agents

What prompt injection has achieved in practice

In June 2025 researchers at Aim Security disclosed EchoLeak, a flaw in Microsoft 365 Copilot tracked as CVE-2025-32711 and rated critical at 9.3. An attacker could send a crafted email that Copilot would later read while answering an unrelated question, causing it to pull sensitive data from the user’s context and send it out without the user clicking anything. Microsoft fixed it server-side, and it has been described as the first known zero-click attack on an AI agent.

The OWASP Top 10 for Agentic Applications, published in December 2025, draws on incidents like this. Its first three risks are agent goal hijack, where planted content redirects what the agent is trying to do; tool misuse, where an agent uses legitimate tools in harmful ways; and identity and privilege abuse, where an agent acts with more access than it should have.

Why it is so hard to fix

SQL injection was largely solved by keeping data and commands apart, through parameterised queries. In December 2025 the NCSC published an assessment arguing that prompt injection is different: a language model has no reliable boundary between instructions and data, so the same separation is not available. Its conclusion was that prompt injection may never be totally mitigated in the way SQL injection can be, and that systems should be designed to limit what a confused model can do.

That is why the usual first defences have limits:

  • Telling the model to ignore injected instructions helps a little, but it can be talked around.
  • Input filters and classifiers catch known patterns. Attackers rephrase, translate, encode or split instructions across several inputs.
  • Keeping the system prompt secret is not a control. OWASP treats system prompt leakage as a risk in its own right, so assume it will be read.

Filters are still worth having. They are one layer, not the fix.

How to limit the damage

The controls that hold up are the ones that still work when the model has been fooled. The UK AI Cyber Security Code of Practice, and the ETSI EN 304 223 standard built on it, apply the same principle across the AI lifecycle.

  • Least privilege for agents. Give each agent its own identity with only the permissions its task needs, and short-lived credentials rather than broad API keys.
  • Human approval for consequential actions. Payments, external email, deleting records and changing permissions should need a person to confirm.
  • Keep untrusted content away from sensitive capability. An agent that reads inbound email or the open web should not also hold broad access to confidential data and an outbound channel.
  • Treat model output as untrusted. Validate it before it reaches a browser, database, shell or another system, and block automatic loading of external links and images that could carry data out.
  • Fix the permissions underneath. Assistants such as Copilot surface whatever a user can technically reach, so tighten oversharing before switching them on. A configuration review covers this.
  • Log and monitor. Record prompts, retrieved content and tool calls so unusual behaviour can be spotted and investigated.

How to test for prompt injection

Testing should follow the attacker’s routes rather than a fixed list of jailbreak prompts. A useful test:

  • maps every source of content the application reads, including retrieved records and tool responses
  • plants instructions in each source and checks whether the model follows them
  • measures impact, meaning data disclosed, actions taken and tools misused, rather than odd replies
  • tests the conventional application around the model, since model output passed unchecked to other systems can become injection or code execution
  • maps findings to the OWASP Top 10 for LLM Applications and for Agentic Applications, so developers, auditors and boards share one vocabulary

Model behaviour changes with updates, so a test is a point-in-time view. Retest after a model change, a new tool or a wider rollout. Our AI and agent security testing covers each of these steps, alongside web application testing for the application around the model.

Sources
  1. Prompt injection is not SQL injection (it may be worse)National Cyber Security Centre
  2. The OWASP Top 10 for LLM Applications (2026): what changed and why it mattersCloud Security Alliance
  3. OWASP Top 10 for Agentic Applications for 2026OWASP GenAI Security Project
  4. Zero-click AI vulnerability exposes Microsoft 365 Copilot data without user interactionThe Hacker News
  5. AI Cyber Security Code of PracticeDepartment for Science, Innovation and Technology
  6. ETSI sets out new European standard to strengthen AI cyber securitytechUK

Common questions

Short answers to what buyers ask most often.

What is prompt injection in simple terms?

Tricking an AI system with text. An attacker writes instructions the model treats as commands, either by typing them or by hiding them in content the AI reads, so it does what the attacker wants instead of what its developer intended.

What is the difference between direct and indirect prompt injection?

Direct injection is typed by the person talking to the AI. Indirect injection is hidden in content the AI processes, such as an email, document or web page, so the victim may never see it.

Is prompt injection the same as jailbreaking?

They overlap. Jailbreaking usually means getting a model to break its safety training. Prompt injection is broader: getting an application to follow an attacker’s instructions, which can leak data or trigger actions.

Can prompt injection be prevented?

Not completely, according to the NCSC. The practical approach is to limit what a fooled model can reach and do, through least privilege, human approval for sensitive actions and careful handling of output.

Is Microsoft 365 Copilot vulnerable to prompt injection?

Any assistant that reads untrusted content can be targeted. Microsoft fixed the EchoLeak flaw in 2025, but the wider risk depends on your configuration, especially how much data each user’s permissions expose to Copilot.

What is the OWASP Top 10 for LLM Applications?

A community list of the most critical security risks in applications built on large language models, maintained by the OWASP GenAI Security Project. Prompt injection has been ranked first in every edition, including 2026.

How do you test an AI agent for prompt injection?

By planting instructions in every source of content the agent reads, then checking whether it leaks data, misuses tools or takes actions it should not. A good test measures impact, not just unusual replies.

Confidential enquiry

Get a quote built on your scope.

A short outline of the systems involved is enough to agree scope, days and authority before any testing.

Discuss your test