Glossary

Prompt injection

Prompt injection is an attack in which someone writes text that a language model reads as instructions, overriding what the application's developers told it to do. The text can be typed by a user or hidden in an email, web page or document the model processes.

Request a questionnaire review

Direct and indirect injection

TypeWhere the instruction comes fromExample
DirectThe user types it into the chatA message telling the assistant to ignore its rules and reveal its instructions
IndirectContent the model reads while working: emails, web pages, files, tool resultsWhite-on-white text on a web page telling a browsing agent to send the user's data elsewhere

Indirect injection is the bigger risk for an AI agent, because the attacker never needs access to the chat. They only need to put text in the model's path.

Why there is no complete fix

SQL injection has a reliable cure: parameterised queries keep code and data apart. A language model has no such separation. Instructions and data reach it as the same kind of text, and the model decides what to follow. Filters and better training lower the success rate, but attackers rephrase. The 2025 edition of the OWASP Top 10 for LLM Applications lists prompt injection first.

Defences that limit the damage

  • Limit what the model can do. Give tools the narrowest permissions: an assistant that can only read cannot be tricked into deleting. See least privilege.
  • Require a person for consequential actions such as payments, outside emails and record changes, enforced by the system, not by a line in the prompt.
  • Treat model output as untrusted. Validate it before it reaches a database or a command, and encode it before a browser renders it, so injected links or images cannot carry data out.
  • Mark untrusted content in the prompt, and keep secrets out of the context window entirely.
  • Log, monitor and test. Record every tool call, and include injection cases in AI red teaming before launch and after every change.

An example

Imagine a support agent that reads incoming emails and can look up orders and reply. An attacker sends an email with a hidden line asking the agent to forward recent orders to an outside address. If the reply tool can only answer the original sender, and exports need approval, the attack fails even when the model is fooled. This example is hypothetical.

Related terms

Prompt injection is one reason human-in-the-loop approval matters. Our AI application security page and the security checklist for AI agents cover the controls in depth.

A small first step

Send us your next security questionnaire

Share the questionnaire or security review a buyer sent you. On a short call we show which answers you already have evidence for, which gaps to fix first, and what can be automated next time.

Message us on WhatsApp

Keep exploring

Ready to build something secure?

Tell us about your product. We will reply with a clear plan.

Start a project

We would like to use Microsoft Clarity to see how visitors use the site, so we can improve it. It sets cookies and is off unless you accept. Cookie policy