↑ Resources / Security

Detecting Indirect Prompt Injection in AI Agents

Security · 7 min read ·

An agent that reads the world can be told what to do by the world. A web page it summarizes, an email it triages or a file it opens can carry instructions, and a model that follows instructions well may follow those too. This is indirect prompt injection, and it is the main route to what OWASP's Top 10 for Agentic Applications lists first: agent goal hijack.

This guide covers why the attack is hard to stop at the input, why it is easier to see in what the agent does afterwards, and what that kind of detection can and cannot catch.

What indirect prompt injection is

In a direct prompt injection, the attacker is the person typing. In an indirect one, the attacker never talks to the agent at all. They place text where the agent will read it: a hidden line on a web page, a paragraph in an email signature, a comment in a document, a field in a support ticket. When the agent pulls that content into its context, the planted text arrives alongside the user's request, and the model has no reliable way to tell data from instructions.

The term comes from a 2023 paper by Greshake and colleagues, "Not what you've signed up for", which showed the attack against LLM-integrated applications. Agents make it more serious, because an agent does not only answer. It calls tools: it sends mail, writes files, queries databases and moves money.

Why filtering the input is not enough

The first defense most teams reach for is a filter in front of the model: a classifier or a set of rules that looks for injected instructions in what the agent is about to read. It is worth having. It catches known patterns and raises the cost of the crude attacks.

Its limit is that the attacker controls the wording. Instructions can be paraphrased, split across sentences, written in another language or hidden in formatting, and a filter has to recognize every variant to be complete. It also has to inspect content, which some teams cannot or will not send to another service.

OWASP's own guidance says it is unclear whether fool-proof prevention exists, and recommends layered defenses on the assumption that some attempts will get through. The useful question then is how quickly you notice when one does.

Look at what the agent does next

An injection that works changes the agent's behavior. That is the point of it. A summarizing agent that starts sending email, a support agent that queries a table it has never touched, a payments agent that pays someone new: each of these is visible in the agent's tool calls, without reading a single prompt.

Detection on this side needs a reference for what normal looks like, and normal differs by agent. A research agent calling a search tool fifty times is routine. A billing agent doing the same is not. So the baseline has to be learned per agent, from its own runs.

  • A tool the agent has never used for this task. The sharpest signal. An injected goal usually needs a capability the original task did not, and the first call to it is the moment to flag.
  • An abrupt shift in the action mix. A sudden change in which tools are called and in what proportion, measured against the baseline. CUSUM is a standard statistical method for this.
  • A gradual drift. Some manipulations, like a poisoned memory or a slowly changing retrieval source, move behavior a little at a time. A windowed comparison of tool distributions, such as Jensen-Shannon divergence, catches what a single run does not show.

All three work on metadata: which tool, in which order, in which session. None of them needs the content of what the agent read or wrote.

What this approach misses

Behavioral detection sees changes in what an agent does. An injection that stays inside the agent's normal pattern, using the tools it always uses with arguments that look ordinary, can pass unnoticed. Exfiltrating data through a tool the agent already calls every run is the hard case.

Detection also comes after the fact by design: the first unusual call has happened when it is flagged. If that call must not happen at all, you need something in the path that can hold it, not only an alarm. That is the difference between monitoring and control.

Neither limit is a reason to skip detection. Input filtering, least privilege on tools and behavioral monitoring cover different failures, and the combination is stronger than any one of them.

Where Kyde fits

Kyde Score watches the behavior side. It reads tool calls over OpenTelemetry, learns each agent's baseline from its first 30 runs over at least 3 days and flags new tools for a task, abrupt shifts and gradual drift with deterministic detectors. It never reads prompts or responses. When an agent's score changes band, it sends a signed webhook.

Score reports. Stopping a call before it runs takes Kyde Control, a gateway that sits in the agent's path and runs in your own environment. Compare the two.

KYDE Score

Kyde Score learns how each agent behaves from its own OpenTelemetry tool calls and flags the run where it starts doing something new: a tool it never used for that task, an abrupt shift, a slow drift. Deterministic detectors, no LLM, no prompt content.

Score an agent →