MEMike Esmalifalak, PhD

AI Security

Prompt Injection: AI Agents Can't Tell Instructions From Data

A guide to prompt injection against tool-using AI agents in 2026, explained through stealthy false data injection attacks on the power grid.

In 2009, three researchers showed that an attacker could feed false measurements into a power grid’s control system and the system’s own error checks would wave them through. In 2025, a single email sent to a Microsoft 365 Copilot user could pull private data out of the organization without the user clicking anything.

Those two attacks are sixteen years and one industry apart. I think they are the same bug.

In both cases, the system trusts any input that passes its consistency checks. The attacker does not break the checks. They craft inputs that live inside them.

I spent my PhD working on the grid version of this problem. Today, as I watch teams wire large language models to email, code repositories, browsers and databases, I keep seeing the same pattern. This guide explains prompt injection against tool-using AI agents in 2026 through that lens: what it is, why it keeps working, what has actually happened, and which defenses carry over from more than fifteen years of grid security research.

If you want the short version of the grid side first, I wrote a shorter piece on how stealthy attacks moved from smart grids to LLMs.

What is a stealthy false data injection attack?

A power grid operator cannot measure everything directly. Instead, a control center collects many meter readings, such as power flows and voltages, and runs state estimation: it solves for the most likely state of the system that explains those readings.

Measurements are noisy and sometimes wrong. So state estimation comes with bad data detection. The standard approach looks at the residual: the gap between what the meters reported and what the estimated state predicts they should have reported. If the residual is too large, something is wrong, and the bad reading gets flagged.

That is a sensible check. It catches broken sensors and random errors well.

In 2009, Liu, Ning and Reiter showed at ACM CCS that it is not a security check. In their paper, False data injection attacks against state estimation in electric power grids, an attacker who knows the grid’s configuration (the measurement matrix) can inject errors that shift the estimated state while leaving the residual unchanged. The false data is perfectly consistent with physics as the detector understands it. It passes bad data detection, and the operator now believes something false about their own grid.

The key idea is simple. The detector asks, “Is this data internally consistent?” It never asks, “Is this data true?” or “Who sent it?” An attacker who understands the consistency rule can satisfy it on purpose.

The attacker does not even need the blueprint

A natural response to Liu, Ning and Reiter was: fine, keep the measurement matrix secret. In 2011, my coauthors and I showed that this is not enough. In Stealth false data injection using independent component analysis in smart grid (IEEE SmartGridComm 2011), we showed that an attacker can use independent component analysis to infer the system structure from observed measurement data alone, then launch attacks that remain unobservable to the detector.

In other words, an attacker who can watch the system long enough can learn enough of the model to beat its checks without ever being told the model.

Keep that result in mind. It comes back later, when we talk about attackers probing an AI agent to learn its system prompt and tools.

What is prompt injection?

Prompt injection is when text that an AI model processes as data gets treated as instructions.

A large language model receives one stream of tokens. The developer’s system prompt, the user’s request, a retrieved web page, a tool’s output and the body of an email all arrive as text in the same context window. The model has no hard boundary between “this is what I was told to do” and “this is something I am reading.” It has learned conventions about which text to follow, but those are statistical habits, not enforced rules.

There are two broad types.

Direct prompt injection is when the user themself types instructions designed to override the developer’s intent, such as “ignore your previous instructions.” This is closely related to jailbreaking. It matters, but the attacker and the user are the same person, so the damage is often limited to what that user could already do.

Indirect prompt injection is the more serious problem for agents. The attacker never talks to the model directly. They plant instructions in content the agent will read later: a web page, a document, a calendar invite, an email, a code comment, an issue on a public repository. When the agent pulls that content in to do its job, the hidden instructions ride along.

The canonical paper here is Greshake et al., Not what you’ve signed up for (AISec 2023). They introduced indirect prompt injection as a class, and their framing is the clearest one I know: LLM-integrated applications “blur the line between data and instructions.” They demonstrated remote exploits against real systems, including Bing’s GPT-4-powered Chat and code-completion engines.

Standards bodies now treat this as a core risk. Prompt injection is LLM01, the top entry, in the OWASP Top 10 for LLM Applications 2025. NIST’s adversarial machine learning taxonomy, NIST AI 100-2e2025, formally covers direct and indirect prompt injection along with vulnerabilities specific to agents.

Why can’t AI agents tell instructions from data?

Here is where the grid analogy earns its place.

In state estimation, the bad data detector checks consistency. A stealthy false data injection is consistent by construction, so it passes.

In an AI agent, every check you can put in front of the model is some version of “does this text look malicious?” A well-crafted injection is well-formed natural language. It is grammatical. It may be polite. It may look like a normal note to an assistant. It passes syntactic checks, and with enough effort it passes classifier checks too. Then the model reads it and does what it says, because following instructions written in natural language is exactly what the model was trained to do.

The flaw is not that the filter is poorly built. The flaw is architectural. The system’s trust decision is based on the shape of the input, not on where the input came from or whether it is entitled to give orders.

Classic software security solved a version of this decades ago. SQL injection became largely preventable when developers stopped building queries by gluing strings together and started using parameterized queries, which keep code and data in separate channels. LLMs do not yet have a reliable equivalent of a parameterized query. Everything is still one string.

That is why I call this the defining security problem of AI agents. A chatbot that can only talk back has limited blast radius. An agent that can read your inbox, call APIs, push code and send messages turns “the model misread some text” into “the attacker took an action as you.”

What is the lethal trifecta for AI agents?

In June 2025, Simon Willison gave the clearest practical framing of when prompt injection becomes dangerous. He called it the lethal trifecta. An agent is at serious risk of data theft when it combines:

  1. Access to private data, such as your email, files or internal systems.
  2. Exposure to untrusted content, meaning any text or images an attacker could control.
  3. A way to communicate externally, which becomes an exfiltration channel.

With all three, an attacker can plant instructions in the untrusted content that tell the agent to read the private data and send it out through the external channel. No malware, no stolen password. Just text.

Meta turned this into a design rule a few months later. Its Agents Rule of Two says that until prompt injection can be reliably detected, an agent should hold at most two of these three properties in a single session:

  • processing untrusted inputs,
  • accessing sensitive systems or private data,
  • changing state or communicating externally.

If a task genuinely needs all three, the agent should not run it on its own. A human should be in the loop, or the task should be split.

I like this rule because it is honest. It does not assume a filter will catch the attack. It assumes the attack will sometimes succeed and limits what success can achieve.

What real prompt injection attacks have happened in 2025 and 2026?

The question of whether this is theoretical was settled in 2025. Here are the cases I think every team shipping agents should know.

EchoLeak: the stealthy attack that passed the detector

EchoLeak is the cleanest modern example of a stealthy injection beating a purpose-built detector. It was a zero-click attack on Microsoft 365 Copilot, tracked as CVE-2025-32711 with a CVSS score of 9.3 and disclosed in June 2025.

The exploit was discovered by Aim Security. The chain worked like this, according to a case study of the exploit:

  • A single crafted email reached the victim’s mailbox. When Copilot later pulled that email into context, its hidden instructions took effect.
  • The email got past Microsoft’s cross-prompt injection attack (XPIA) classifier, the filter specifically designed to catch this.
  • Reference-style Markdown links got around Copilot’s link redaction.
  • An auto-fetched image, routed through a Microsoft Teams proxy that the content security policy allowed, carried the data out.

Each layer was a reasonable defense. Each was bypassed by input that looked acceptable to that layer. This is exactly the shape of the Liu, Ning and Reiter attack: the payload satisfied every consistency check in its path.

Microsoft patched the issue and, as reported by The Hacker News, said there was no evidence of malicious exploitation in the wild. That is good news. The lesson stands anyway.

GitHub MCP: an architectural problem, not a bug

In May 2025, Invariant Labs showed how an agent connected to GitHub through the Model Context Protocol could be hijacked by a malicious public issue. The agent also had access to the user’s private repositories. When asked to look at issues on a public repo, it read the attacker’s issue, followed its instructions, and leaked private repository data into a public place.

All three legs of the trifecta were there: private repos, an attacker-written issue, and the ability to write publicly.

The researchers stressed that this was not a code bug in GitHub’s server that a patch could fix. It was architectural. DevClass reported the suggested mitigations: restrict an agent to one repository per session and use least-privilege tokens. The report also noted a human factor that I recognize from industrial systems: the researchers suspected many users pick an “always allow” confirmation policy instead of reviewing each action.

OpenAI’s admission about browser agents

In December 2025, writing about its Atlas browser agent, OpenAI said that prompt injection is unlikely to ever be fully solved, comparing it to scams and social engineering aimed at people. The company noted that agent mode expands the threat surface and advised users to limit the agent’s logged-in access to sensitive accounts and to require confirmation before it sends messages or makes payments.

I find that statement useful. When a leading model provider says the problem may be permanent, the right engineering response is to design systems that stay safe when injection succeeds.

2026: from research to live exploitation

By 2026 the picture had shifted from demonstrations to real attacks. A Cloud Security Alliance research note reports that indirect prompt injection had moved to live exploitation by late April 2026, citing Forcepoint’s documentation of 10 payloads in the wild and Unit 42’s catalog of 22 delivery techniques.

The OWASP GenAI Security Project, which has published quarterly lists of major incidents for the past two years, released its GenAI Exploit Round-up Report for Q1 2026 in April. And in May 2026, Microsoft’s security team wrote about remote code execution vulnerabilities in AI agent frameworks that could be triggered through prompts. Their title says it well: prompts become shells.

That last point matters. Once an agent can run code, prompt injection stops being a data leak problem and becomes a full system compromise problem.

Agents that remember things across sessions add another dimension, since an injection can persist. I cover that separately in memory poisoning in AI agents.

Why don’t prompt injection filters and guardrails work on their own?

This is the section where my grid background makes me the most opinionated.

Residual-based bad data detection is a good detector of accidents. It is a poor detector of adversaries, because adversaries read the detector’s rule and design around it. Prompt injection classifiers, guardrail models and keyword filters are in the same position. They are trained and evaluated mostly on attacks that existed when they were built. A motivated attacker gets to move after the defense is published.

The strongest evidence is a 2025 paper with a pointed title: The Attacker Moves Second, by Nasr, Carlini, Tramèr and colleagues. They took 12 published defenses against jailbreaks and prompt injection and attacked them with adaptive methods, meaning attacks tuned specifically against each defense. For most of the defenses, attack success rates went above 90%. Most of those defenses had originally reported near-zero attack success.

Read that twice. Defenses that looked nearly perfect under static evaluation failed most of the time against an attacker who knew how they worked.

This is the AI equivalent of the stealthy false data injection attacker who knows the measurement matrix. And my 2011 ICA work suggests the attacker may not even need to be told how the defense works. They can learn it by observing. For agents, that means probing: sending varied inputs, watching which get blocked and which get through, and inferring the system prompt, the available tools and the shape of the filter.

EchoLeak fits this pattern too. The XPIA classifier existed precisely to catch cross-prompt injection, and a crafted email passed it.

So here is my position. Filters are worth having. They raise the cost of casual attacks and catch a lot of noise. But if your security story for an agent depends on a filter catching every injection, you do not have a security story. You have a detection rate against yesterday’s attacks.

How do you defend AI agents against prompt injection?

The grid security community spent years moving past residual checks. The defenses that came out of that work map surprisingly well onto agents. I group them into four principles.

1. Model normal behavior, not just bad inputs

Our response to stealthy false data injection was to stop asking only “is this measurement consistent?” and start asking “does this pattern look like normal operation?”

In Detecting stealthy false data injection using machine learning in smart grid (IEEE Systems Journal, 11(3), 1644-1652), we proposed two approaches. One was a supervised detector, a distributed support vector machine trained with ADMM. The other was an unsupervised statistical anomaly detector that needs no labeled attack data. Both used PCA to reduce the dimensionality of the measurements. The point was that attacks crafted to satisfy the residual test still change the statistical distribution of the data, and a model of normal behavior can pick that up.

In Detecting false data injection attacks on power grid by sparse optimization (IEEE Transactions on Smart Grid, 5(2), 2014), we framed detection as separating a matrix into two parts: a low-rank component representing normal grid measurements, which are highly structured over time, and a sparse component representing attacks. Normal behavior has structure. Attacks tend to break it.

I also coauthored work applying anomaly detection to industrial fault diagnosis in a data mining approach for fault diagnosis (Measurement, 2014).

For agents, the equivalent is to watch what the agent does, not only what it reads. Baseline the normal sequences of tool calls for a given task. A summarize-my-inbox task that suddenly fetches an external image URL, reads files it never touched before, or calls a send function is a deviation worth flagging or blocking, regardless of whether any input looked malicious.

This does not require the detector to understand the injection. It only requires knowing what normal looks like.

2. Use independent signals and track provenance

In grid protection, you do not want every decision to hinge on one stream of measurements that an attacker can shape. You want independent signals that an attacker would have to compromise separately.

For agents, the most principled version of this I have seen is CaMeL, from researchers at Google, Google DeepMind and ETH Zurich (Defeating Prompt Injections by Design). CaMeL extracts the control flow and data flow from the trusted user query up front. Untrusted data retrieved later can fill in values, but it can never change what the program does next. Provenance tracking records where every piece of data came from, and policies decide what data from each source is allowed to do.

That is the parameterized-query idea, rebuilt for agents. On the AgentDojo benchmark, CaMeL solved 77% of tasks with provable security, compared with 84% for an undefended system. That is a real cost in capability, and it is an honest one. You give up some tasks to get a guarantee.

Two practical forms of independent signals you can adopt now:

  • Taint tracking. Mark any content that came from an untrusted source, and refuse to let tainted content choose a tool, a recipient or a URL.
  • Out-of-band confirmation. For sensitive actions, confirm with the user through a channel the injected content cannot touch, and show them exactly what will happen.

3. Separate privileges

Grid security relies heavily on segmentation. Not every component should be able to reach every other component.

For agents, privilege separation is the most reliable defense available today, because it limits the damage when everything else fails:

  • Apply the Rule of Two. Design each agent session so it holds at most two of untrusted input, sensitive data, and external communication or state change.
  • Use least-privilege tokens. An agent that triages public issues does not need write access to private repositories.
  • Scope sessions narrowly. One repository per session, as suggested after the GitHub MCP case. One mailbox folder, not the whole mailbox.
  • Close exfiltration paths. Many of the attacks above ended with data leaving through an image fetch, a link or a proxy. Restrict outbound requests to what the task requires.

4. Assume the attacker knows your defenses

This was the hardest lesson from the false data injection literature. Liu, Ning and Reiter assumed the attacker knew the system. Our ICA paper showed the attacker could learn it. We also studied the problem as an interaction between attacker and defender, in work on bad data injection in electricity markets using game theory (IEEE Transactions on Smart Grid, 4(1)) and on bad data injection in smart grid: attack and defense mechanisms (IEEE Communications Magazine, 51(1)). Once you model the attacker as someone who responds to your defense, static detection rates stop meaning much.

For agents, that means:

  • Red-team with adaptive attacks. Evaluate your defenses the way The Attacker Moves Second did, with attacks optimized against your specific setup, not with a fixed list of known jailbreak strings.
  • Assume your system prompt will leak. Do not put secrets or security logic in it.
  • Re-test after every change. New tools, new data sources and new model versions all change the attack surface.

What should teams shipping AI agents do in 2026?

Here is the checklist I would hand to any team putting an agent in front of real data.

  1. Map the trifecta. For each agent, write down what private data it can reach, what untrusted content it reads, and how it can communicate externally or change state. If it has all three, redesign or add a human checkpoint.
  2. Cut privileges first. Least-privilege tokens, narrow session scopes, and no standing access the task does not need.
  3. Block exfiltration channels. Restrict outbound network calls, image fetches and link rendering to what the task requires.
  4. Separate trusted intent from untrusted data. Prefer designs in the spirit of CaMeL, where the plan comes from the user and retrieved data cannot rewrite it.
  5. Confirm sensitive actions out of band. Show the user the exact action and its target, and do not let users permanently “always allow” high-risk tools.
  6. Monitor behavior, not just inputs. Log tool calls, baseline normal sequences per task, and alert on deviations.
  7. Keep filters, but do not depend on them. Treat classifiers as one layer that reduces noise.
  8. Test adaptively. Red-team with attacks tuned to your defenses, and repeat after each change.
  9. Watch the incident feeds. OWASP’s quarterly round-ups and vendor research are now the best way to learn the techniques attackers actually use.
  10. Anchor on standards. Use OWASP LLM01 and NIST AI 100-2e2025 as shared vocabulary with your security team and auditors.

Training data is a related but separate attack surface. If your agent or model learns from data an attacker can influence, read my guide on how to detect poisoned training data.

The same lesson, sixteen years later

The grid community learned that a check for consistency is not a check for trust. Attackers who understand the rule, or who can learn it from observation, will craft inputs that satisfy it.

AI agents are relearning that lesson at much greater speed and scale. Every agent that reads untrusted text and acts on it has a residual-style detector at its core: “this looks like reasonable text, so I will process it.” Injection is reasonable-looking text with an agenda.

The good news is that we know what works when detection alone fails. Model normal behavior. Rely on independent signals. Separate privileges so a successful attack cannot do much. And design against an attacker who moves second.

About the author

I am Mohammad (Mike) Esmalifalak, PhD, Electrical Engineering (machine learning research), University of Houston. My doctoral research focused on stealthy false data injection attacks on smart grids and machine learning methods to detect them. I now work as a Lead Data Scientist in Toronto, focused on industrial machine learning. You can find my papers on the research page.

Frequently asked questions

What is indirect prompt injection?

Indirect prompt injection is when an attacker hides instructions inside content an AI agent reads, such as an email, web page or GitHub issue, and the agent follows them as if they came from the user.

What is the lethal trifecta for AI agents?

Simon Willison's term for an agent that has access to private data, exposure to untrusted content, and a way to communicate externally. With all three, an attacker can trick it into stealing data.

Can prompt injection be fully prevented?

Not today. OpenAI has said it is unlikely to ever be fully solved, and adaptive attacks have bypassed most published defenses. The practical goal is to limit what a successful injection can do.

— Mike

Mohammad (Mike) Esmalifalak, PhD, is a machine learning scientist in Toronto whose research on smart-grid security has been cited 2,600+ times. More about me.

More on AI Security

The newsletter

One thoughtful email a week on practical AI.

What's actually working in applied and industrial AI — no hype, no spam. Unsubscribe anytime.