Skip to main content

Indirect Prompt Injection: How Hidden Instructions Hijack AI Agents

· By Natalie Walls

Indirect prompt injection is when the attack isn't typed by the user at all. It's hidden in something the AI reads on the user's behalf.

That might be a web page an agent browses, an email an assistant summarizes, a PDF a support bot searches, or a code comment an AI coding tool reads. The user asks an innocent question. The content answers with instructions.

How it works

A language model sees its instructions and its input as one block of text. It has no reliable way to tell "text I should follow" from "text I should only read".

So when an app pulls in outside content and passes it to the model, any instructions inside that content compete with the developer's. OWASP describes indirect injection as what happens when "an LLM accepts input from external sources, such as websites or files" (OWASP LLM01:2025).

Where the idea came from

A 2023 paper by Kai Greshake and colleagues, Not what you've signed up for, showed indirect injection working against real apps, including Bing's GPT-4 powered chat and code-completion tools. Their summary still holds: LLM-integrated apps "blur the line between data and instructions."

The authors grouped the risks into data theft, "worming" (an injection that spreads itself), contaminating the information people see, and more.

What it looks like on the web today

In April 2026, Google scanned Common Crawl snapshots of billions of public pages for known injection patterns. Most hits were harmless, because they sat in research papers and security articles. The rest fell into a few groups:

  • Harmless pranks, like asking an AI to answer in pirate speak.
  • Helpful guidance, where a site tells AI readers how to describe it.
  • SEO attempts, where a page tries to get AI tools to promote it.
  • Deterrents, telling AI agents to stay away.
  • Malicious instructions, aimed at data exfiltration or destruction.

Google found "limited sophistication" so far, but a 32% relative rise in the malicious category between November 2025 and February 2026, and expects attacks to grow.

Why agents raise the stakes

A chatbot that only answers questions can, at worst, give a wrong answer. An agent can act: send email, run code, move files, call APIs. If injected text can steer the agent, the attacker borrows every permission the agent has.

The risky combination is an agent that can read untrusted content, see private data, and send information out. Any one of those alone is manageable. All three together is where most serious attacks live.

How to test your app

  1. Map the inputs. List everything the model reads besides the user's own message: retrieved documents, browsed pages, emails, file uploads, tool results.
  2. Plant a canary. Put a harmless instruction in each one, like our indirect injection payload, which only asks the model to end its answer with a marker word.
  3. Watch the output and the actions. The test fails if the marker appears, or if the app does anything nobody asked for.
  4. Scan content before it goes in. Our analyzer flags common injection patterns in a block of text, so you can check a document before your app ingests it.

For the defenses themselves, see How to Prevent Prompt Injection.