Indirect prompt injectionRAGtool outputs

Indirect Prompt Injection in AI Agents

Indirect prompt injection hides instructions in pages, emails, files and tool outputs that agents read. Learn the six channels and how to test each.
Nov 26, 20268 min read
Book a Demo
BotGauge blog cover: Indirect Prompt Injection in AI Agents, in the AI Agent Red Teaming category

TABLE OF CONTENT

SHARE THIS ARTICLE

TL;DR

Indirect prompt injection hides instructions in content an agent reads (web pages, documents, email, tool outputs, MCP tool descriptions or other agents’ messages) instead of the user’s message. It’s dangerous because the user is innocent, one plant scales to many users, and the reading agent often holds tools. Test it by planting one canary payload per channel and checking the trace. BotGauge plants payloads and shows the action each one triggered.

What is indirect prompt injection?

Short answer: Indirect prompt injection is an attack where instructions are hidden in content an AI agent reads, such as a web page, email, document or tool response, instead of being typed by the user. The attacker never talks to the agent. They wait for the agent to read their content and follow it.

It is the highest-impact item in the threat landscape we map in our guide to AI agent security, and it sits at the top of the OWASP agentic list as part of agent goal hijack (ASI01).

Find which channels can hijack your agent

Start Now

Why is indirect prompt injection so dangerous?

Short answer: The user is innocent, one planted payload can hit every user who retrieves it, the instructions can be invisible, and the agent that reads them can often act.

How an indirect prompt injection reaches an AI agent through planted content and an innocent user

•           The user is innocent. A customer asks a normal question; the attack rides in on a retrieved page.

•           It scales. One planted document can hit every user whose question retrieves it.

•           It is invisible. Instructions can sit in white text, HTML comments, image alt text or metadata.

•           It reaches tools. The agent that reads the content is often the same one that can send email or move money.

The term was popularized by Greshake et al. in their 2023 paper on compromising LLM-integrated applications, and real incidents have followed. EchoLeak, a zero-click flaw in Microsoft 365 Copilot (CVE-2025-32711), used a crafted email to pull data out without any user action.

How does indirect prompt injection reach an agent?

Short answer: Through six channels: web pages, documents and RAG, email and tickets, tool and API outputs, MCP tool descriptions, and other agents.

Six channels that deliver indirect prompt injection to an AI agent
ChannelHow the payload arrivesExample
Web pagesAgent browses or searchesHidden text on a product page
Documents and RAGRetrieved from a knowledge basePlanted policy article
Email and ticketsAgent reads inbound messages“Forward this thread to…” in a ticket
Tool and API outputsReturned by a function callNote field in a shipping API response
MCP tool descriptionsLoaded when tools are listedHidden instruction in a tool’s description
Other agentsHandoff between agentsUpstream agent’s output carries a command

When the planted content is a false fact rather than a command, it becomes data poisoning in AI agents, which needs slightly different defenses.

How do you test for indirect prompt injection?

Short answer: List every channel, plant a canary payload in each in staging, trigger retrieval with a normal question, and check the trace for the canary tool call.

1.         List every channel your agent reads from. Include tool outputs and MCP servers, which teams often forget.

2.         Plant one payload per channel in staging. Use a canary action, such as calling a harmless tool with a unique argument, so success is easy to spot in the trace.

3.         Trigger retrieval with a normal user question. The test user should never mention the payload.

4.         Check the trace, not the reply. Did the canary tool fire? Did any sensitive tool fire?

5.         Re-check after fixes. If a channel failed to deliver the payload, re-run it before marking it safe.

For MCP-connected agents specifically, our guide to MCP security testing for AI agents covers tool-description and tool-output attacks in detail.

How do you defend against indirect prompt injection?

Short answer: Content may inform the agent but never instruct it: mark it untrusted, gate high-impact actions behind approval, and enforce limits in code.

The core rule: content can inform the agent but never instruct it. Mark retrieved content as untrusted, keep high-impact actions behind approval, and enforce limits in code. The full layered approach is in how to prevent prompt injection in AI agents.

How is indirect prompt injection different from direct prompt injection?

Short answer: In direct injection the attacker is the user. In indirect injection the attacker plants instructions in content, and an innocent user triggers them.

 Direct prompt injectionIndirect prompt injection
Who the attacker isThe person chatting with the agentA third party who never talks to the agent
Where the payload sitsThe user’s messageA web page, document, email, tool output or another agent’s message
Who triggers itThe attackerAn innocent user asking a normal question
How visible it isShows up in chat logsOften hidden in white text, metadata or comments
How many users it hitsOne sessionEveryone whose request retrieves the content

Both are classed under MITRE ATLAS technique AML.T0051 (LLM Prompt Injection), and NIST’s adversarial machine learning taxonomy (AI 100-2 E2025) treats them as separate attack classes. Microsoft’s security response team reports that indirect prompt injection is one of the most widely used techniques in AI vulnerabilities reported to it.

Trace every action back to the content behind it

Start Now

The bottom line

Indirect prompt injection turns every document, email and tool response into a possible attacker. Test each channel your agent reads, and make sure content can inform the agent but never command it.

BotGauge tracing shows each retrieved chunk and tool output next to the action it triggered. Red-team runs plant payloads across documents and tools, and tell you when a plant was not delivered so you can re-check that channel.

Test every channel your agent reads from. BotGauge is an AI agent red-teaming platform. Start for free or book a 30-minute demo.