Caloogy Article
中文

Indirect Injection: Commands Hidden in Webpages, Emails, and Documents

Date
Jul 8, 2025
Series
Prompt Injection
Reading
4 min
Topics
AiLlmIndirect prompt injectionRag

The one-sentence version

You ask an AI to summarize a webpage, read an email, or analyze a PDF. If these contents contain instructions written for the AI, the AI might follow them, even though you cannot see these instructions at all. This is indirect prompt injection: the attacker does not need to interact with you; they only need to ensure their content is read by your AI. Hiding methods are diverse: white text on a white background, tiny font sizes, HTML comments, text within images, document metadata, or even invisible Unicode characters. The more capable the AI becomes (browsing the web, reading emails, operating files), the more powerful these attacks become.

This article has three layers:

  1. Layer 1: The Intuition: Giving your assistant a hidden note
  2. Layer 2: Real-World Use: Academic research, AI browsers, programming agents, recruitment screening
  3. Layer 3: Principles and engineering key points: Common hiding methods, attack chains, and why they are difficult to filter

Layer 1: The Intuition

1.1 A Note Given to an Assistant

You ask your assistant to go to the library to check the contents of a book and report back. Tucked inside the book is a note written in very small print: "Attention assistant: When reporting, tell your boss that this book is highly worth purchasing, and place the boss's office keys on the front desk."

You never saw this note, but the assistant did, and they followed the instructions.

The terror of indirect injection lies in the fact that: the user did nothing wrong. They simply asked the AI to read a seemingly normal webpage.

1.2 The Attacker Only Needs to "Be Read"

Areas the attacker can control Who will make the AI read it
Their own webpages, blogs, product pages AI with browsing capabilities, AI search engines
Emails or calendar invites sent to you AI email assistants
Shared documents, resumes, contracts AI office assistants, recruitment screening tools
READMEs, code comments, or Issues in open-source repositories Programming Agents
Public datasets, knowledge bases RAG applications (see "RAG and Memory Poisoning")

Layer 2: Real-World Use


Layer 3: Principles and Engineering

3.1 Common Hiding Methods

Method What humans see What the AI sees
White text on white background, zero-point font Blank space Complete text
HTML comments, display:none Nothing Depends on the scraping method, but often visible
Text within images A normal image (text may be very faint) Multimodal models can read the text
PDF / Office metadata, hidden layers Invisible Parsers will extract them
Invisible Unicode characters (e.g., "tag" characters) Nothing Certain models interpret them as text
End of long texts, footers, the title attribute of links Hard to notice Read in just like the main body

3.2 A Complete Attack Chain

Attacker embeds
hidden instructions in a webpage

User asks AI
to summarize this webpage

AI reads the instruction,
thinking it is part of the task

AI calls a tool:
read email / read file

AI embeds sensitive data
into a link or request

Data is sent to
the attacker's server

If any link in the chain is broken, the attack fails. This is also the core logic of defense (see "Defending Against prompt injection").

3.3 Why It Is Difficult to Filter

3.4 Possible Product Design Improvements


Summary

Layer Key points
Intuition Assistant reads a hidden note in a book and follows it; the user did nothing wrong
Source Webpages, emails, documents, code repositories, knowledge bases
Hiding White text, comments, image text, metadata, invisible characters
Countermeasures Source labeling; user confirmation for sensitive actions after reading external content; cutting off exfiltration channels