AI Glossary / Prompting and human-AI interaction / Intermediate

Indirect prompt injection

Indirect Prompt Injection (Prompting and human-AI interaction)

Definition

Indirect prompt injection is an attack in which instructions are hidden inside content that an AI system reads on someone's behalf, such as a web page, email, document or search result, and the model follows those instructions as if its user had written them. It differs from direct prompt injection, where the person typing into the system is the attacker. The term is used consistently, though defenses and naming vary between vendors.

What it means

Many AI tools now read material you did not write. An assistant may summarize an inbox, browse a supplier site, search a shared drive or process a customer upload. Any of that material can contain text meant for the model rather than for you. If the model treats that text as an order, a stranger has effectively gained a say in what your assistant does.

The risk grows with what the assistant can do. A tool that only summarizes can at worst give a misleading summary. A tool that can send email, edit records, run code or move money can be steered into doing those things. This is why the topic matters most for AI agents and connected tools, and less for a chat window with no access to anything.

How it works

A language model receives one long stream of text. Your instructions, the developer's rules and the content it fetched all arrive together as words. The model has no reliable built-in way to tell which words are commands from a trusted party and which are just data. A sentence in a web page that says to ignore earlier instructions and do something else can look, to the model, much like a legitimate instruction.

A typical attack has three steps. First, the attacker places hidden text where the assistant will find it. It might be white text on a white background, a comment in a page's code, small print in a PDF or a line at the bottom of an email. Second, a real user asks the assistant to read or process that content. Third, the model absorbs the planted text along with the legitimate content and may act on it, for example by revealing private information, changing its answer or calling a tool it should not.

No single fix removes the problem. Common defenses are layered: limit what the assistant can do, require human approval for sensitive actions, separate untrusted content from instructions where possible, filter and monitor outputs, and give each tool the narrowest access it needs. Effectiveness varies, and defenders generally assume some attempts will get through.

Three practical examples

  • Finance team: An assistant that reads incoming supplier invoices as PDFs is asked to extract amounts and bank details. One invoice contains tiny hidden text telling the assistant to report a different payment account as verified. A control that requires a person to confirm any change of bank details catches it.
  • Retailer: A shopping helper on a store's site summarizes product reviews for customers. A reviewer plants text in a review telling the assistant to recommend one product and criticize competitors. The summaries become quietly biased until reviews are screened and the output is checked.
  • Support desk: An assistant drafts replies by reading customer emails and can look up order records. An email includes hidden text asking it to include the last five orders of another customer in the reply. Limiting the assistant to the current customer's records prevents the leak even if the instruction is followed.

Think of it this way

Imagine a new assistant who reads the whole mail pile aloud and acts on it, and one letter in the pile says to hand the filing cabinet keys to whoever is asking. A careful person knows a letter is not their boss. The analogy stops working because a model has no built-in sense of who is the boss: all text looks alike to it, so the boundary has to be built around the model with permissions and approvals.

Worked example

A small firm tests an assistant that reads 200 supplier emails per week and can draft payment requests. The team plants 20 test emails containing hidden instructions to change a bank account. In the first run the assistant follows the hidden instruction in 6 of the 20 test emails, so the failure rate is 6 divided by 20 = 0.30, or 30 percent.

The team then adds a rule that any bank detail change must be approved by a person. The assistant still follows the hidden text in 6 of 20 emails, but each of those 6 now stops at the approval step. Changes that complete without a person = 6 x 0 = 0. The attack still succeeds against the model, yet it no longer succeeds against the business. The lesson is that the control around the model, not the model's good behavior, provides the safety.

Illustrative case study

Fictional case: Harbor Lane Outfitters, a made-up online retailer, launched an assistant that read customer messages and could issue refunds up to a set limit. A tester sent a message with hidden text telling the assistant to refund the most recent order in full and to mark the message as resolved. The assistant complied, and the refund went out before anyone noticed. The team did not try to make the model smarter. They moved refund approval out of the assistant, so it could only propose a refund, and a staff member approved it. They also stripped hidden formatting from incoming messages and logged every proposed refund. A second round of test messages produced several proposals but no unapproved refunds.

Common misconceptions and mistakes

Only the person typing can attack the assistant. In indirect prompt injection the attacker never talks to the assistant at all. They only need to place text where it will later read it.

A stronger or newer model solves it. Better models can resist more attempts, but no model is known to be immune, so permissions and approvals still matter.

Hidden text must be invisible to be dangerous. Injected instructions can sit in plain sight, such as a line in a review or an email signature, and still be followed.

It only matters for chatbots on websites. The exposure comes from what the assistant can read and do, so internal tools that read email, files or tickets carry the same risk.

Business use

Start by listing what your AI tools read from outside your control and what they are allowed to do. Treat anything from the web, email or uploads as untrusted. Remove permissions the task does not need, require human approval for payments, data sharing and record changes, and keep logs. Run planted-instruction tests before launch and repeat them after changes, much like the worked example.

Measure how often test attacks change the assistant's behavior, how often a control stops them, and how many sensitive actions pass through approval. Costs include reviewer time, some loss of speed and ongoing testing. The main risks are data leakage, unauthorized actions and quietly manipulated outputs. Guidance on managing such risks is available in frameworks such as the NIST AI Risk Management Framework.

People also ask

What is the difference between direct and indirect prompt injection?

In direct prompt injection the user typing to the assistant is the one trying to override its rules. In indirect prompt injection the instructions are planted in outside content the assistant reads, so the attacker never interacts with it directly.

Can indirect prompt injection be fully prevented?

Not with any single technique known today. Organizations reduce the risk by limiting permissions, requiring approvals for sensitive actions and monitoring behavior.

Does it matter if my AI tool cannot take actions?

It matters less, since a read-only tool can mainly mislead rather than act. It can still produce biased summaries or expose information from its context, so outputs should be checked.

Check your understanding

In the worked example, what was the failure rate before the approval rule?

Answer: 6 of 20 test emails, which is 0.30 or 30 percent.

Why did the approval rule make the business safe even though the model still followed the hidden text?

Answer: Every changed bank detail had to be approved by a person, so the 6 followed instructions stopped at that step and none completed.

Why is an assistant that can send email riskier than one that only summarizes?

Answer: Injected instructions can make it take real actions, such as sending data out, instead of only producing a misleading summary.

Who is the attacker in indirect prompt injection?

Answer: A third party who plants instructions in content the assistant later reads, not the person using the assistant.

Related terms

  • Prompt injection
  • AI agent
  • Tool use
  • Guardrails
  • Human-in-the-loop
  • Least privilege
  • Red teaming
  • Jailbreak

Learn next

Map the content sources and permissions of one AI tool you use, then run a few planted-instruction tests against it. Read next about prompt injection, AI agents and guardrails to see how the pieces fit together.

  • Prompt injection
  • Guardrails

More in Prompting and human-AI interaction

  • Human review - Human review is the practice of having a person check, correct, approve or reject an AI system's output before it is used or acted on.
  • Image-to-image - Image-to-image is a way of using a generative AI model in which you supply an existing picture as the main input, usually with a short text instruction, and...
  • Incremental Few-shot Learning - Incremental few-shot learning is learning new categories or capabilities in successive stages from small labeled datasets while retaining useful performance...
  • Instruction hierarchy - An instruction hierarchy is a ranking of the sources of instructions an AI model receives, so that when two instructions conflict, the higher-ranked one wins.
  • Instruction tuning - Instruction tuning is additional training that teaches a language model to respond to tasks expressed as instructions.
  • JSON mode - JSON mode is a setting offered by some AI model providers that constrains a language model to produce output that is valid JSON, a common text format for...

Sources

NIST, AI Risk Management Framework: https://www.nist.gov/itl/ai-risk-management-framework Anthropic, Building effective agents: https://www.anthropic.com/engineering/building-effective-agents DAIR.AI, Prompt Engineering Guide: https://www.promptingguide.ai/ The sources were consulted for background on AI risk management, agent design and prompting practice; the examples, analogy, worked example and case are original educational illustrations. Checked 9 Nov 2026.

Previous: Indicator function Next: Indirect sampling

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer