Get the free coreGet core

Indirect prompt injection: when the attack hides in what the agent reads

Updated 4 min readSection 05 / Threats
SHORT ANSWER

Indirect prompt injection is when the malicious instructions sit in something the model reads, not in what you type. It happens when an LLM, the AI model behind the agent, accepts input from external sources, such as websites or files. The attacker does not need access to your chat: this kind of attack can be carried out remotely, without a direct interface. The main risk is that an agent with private data, untrusted content and a way to send data out can be tricked into stealing that data.

If you only know the basic idea, start with the prompt injection overview. This page is about the case that matters most for coding agents: the text comes from content, not from you.

01What makes an attack indirect

An agent does more than answer your message. It opens files, fetches web pages, reads package documentation and calls tools. Every one of those is a way for outside text to reach the model. The model follows any instructions that make it to the model, whether or not they came from its operator.

So the attacker does not need your chat. They need to put text where your agent will read it: a file in a repository, a web page, package documentation, the description of a tool. That is the whole trick behind indirect prompt injection.

02Direct vs indirect prompt injection

A direct attack comes through the prompt input itself. An indirect attack reaches the model through content it was asked to read. Both try to override or manipulate the assistant's instructions by inserting malicious text.

DirectIndirect
Where the text sitsIn the input someone typesIn an external source such as a website or a file
How the attacker reaches the modelThrough the inputRemotely, without a direct interface
Who sees itWhoever reads the chatOften nobody: it need not be human-visible or readable

For an agent that works on its own, the indirect column is the one to worry about, because nobody is watching the pages it reads.

03Where the hidden text can sit

Prompt injection can happen when the agent retrieves and follows instructions from untrusted content, for example a web page or a dependency README. A dependency README is the documentation file that ships inside a package you install.

Other places follow from the same idea:

04How a hidden instruction travels: a Cursor chain

CVE-2025-54135 shows how an indirect prompt injection gets from planted text to running code. Today Cursor agents can modify workspace files without approval, except for configuration files. Before version 1.3.9 that gap was wider: an agent could create a new dotfile, a file whose name starts with a dot, without approval.

An attacker could chain an indirect injection to write to the settings file and trigger remote code execution, which means running the attacker's commands on the victim's machine, without the victim's approval. It was fixed in version 1.3.9. If you use Cursor, check that you run 1.3.9 or later; the settings that limit this kind of chain in each tool are on prompt injection in coding agents.

Read as a chain: the agent reads planted text, the text asks for a file write, creating a new file needed no approval, and the file the agent wrote ran code. This case is also in the table of real cases on the overview.

05How the data gets out

Reading your files is half of the attack. The other half is sending them somewhere, and two cases show how.

An agent with private data, untrusted content and a way to communicate externally can be tricked into accessing the private data and sending it to the attacker.

06Where to go from here

In Claude Code, an MCP server that fetches outside content is one of the doors, and a cloned repository cannot approve its own servers. Reviewing .mcp.json does not show every server a session can load. Claude Code prompts for approval in interactive sessions before using project-scoped servers from .mcp.json files.

It is unclear if there are fool-proof methods of prevention, so the useful question about indirect prompt injection is what a successful one could reach: your private data, and a way to send it out. The wider picture is in AI agent security. The prevention checklist lists the measures and where each one falls short. Settings for Claude Code, Cursor and Codex are on the coding agents page.

Hidden instructions show up only in what the agent does next, so it helps to see what ran: Artificial Immunity's free, open-source core watches agent sessions and program starts on your Mac and reports what it finds.

FAQ

What is the main risk of an indirect prompt injection attack?

The agent can be tricked into reading your private data and sending it to the attacker, when it combines private data, untrusted content and a way to communicate externally.

What are the key differences between direct and indirect attacks?

A direct attack comes through the user's prompt input and alters the model's behavior. An indirect one arrives through external sources such as websites or files that the model accepts as input. The attacker can reach the model remotely, without a direct interface.

Can a web page really give orders to my agent?

It can try. Prompt injection can happen when the agent retrieves and follows instructions from untrusted content, such as a web page or a dependency README.

Can I spot the hidden text by reading the page?

Not reliably. Injections do not need to be human-visible or readable, as long as the model parses the content.

Is a tool description a form of indirect injection?

Invariant Labs calls tool poisoning a specialized form of indirect prompt injection. It has its own page on this site.

Sources

  1. OWASP LLM01: Prompt Injection
  2. Greshake et al., arXiv 2302.12173
  3. OpenAI Codex docs: internet access
  4. Simon Willison: the lethal trifecta
  5. Claude Code docs: MCP
  6. Claude Code docs: permissions
  7. Claude Code security advisories
  8. NVD: CVE-2025-54135
The text that steers your agent may be on a page you never opened. Artificial Immunity watches the Mac where your agents work.Get the free core