Last updated:
What Is AI Agent Security? Risks, Controls, and Why Filtering Isn't Enough
An AI agent reads text and then acts on it with real credentials. It can query your database, open pull requests, send email, or call any API you give it a tool for. If an attacker can get text in front of the agent, they may be able to steer what it does, and no model-level defense reliably prevents that today.
AI agent security (often called agentic AI security) is the practice of building and running agents so that this doesn't turn into a breach. This article works from one assumption: any agent that reads untrusted content should be treated as hijackable. Security then comes from two things. You limit what a hijacked agent is able to do, and you record what it actually did in a form that doesn't depend on the agent's own account.
By the end, you'll be able to explain why filtering alone can't be a dependable security boundary, run a quick capability check on any agent design, map the main risk categories to controls, and know what evidence to capture about each agent run and how to use it to spot misuse.
What is AI agent security?
For security purposes, an AI agent is software that uses a large language model (LLM) to plan and then takes actions against real systems on someone's behalf: calling tools, reading and writing data, and talking to other services. The OWASP AI Agent Security Cheat Sheet describes agents as LLM-driven systems that reason, plan, use tools, keep memory, and take actions toward goals.
That separates agents from AI-assisted tools that only make suggestions. A code assistant that proposes a diff for you to review has a human between its output and the world. An agent that commits, deploys, or emails on its own does not, and the controls you need are very different.
It also explains how agent security differs from securing an ordinary LLM application. A non-agentic LLM app can still leak sensitive data or pass harmful output to the systems downstream of it. An agent goes further: a manipulated model produces tool calls, and those run with the agent's permissions. The closer analogy is an insider with credentials who can be talked into things by anyone who can send them a document. If you're new to the vocabulary, Dash0's agentic software engineering terminology covers terms like tools, MCP, and sandboxing.
Why AI agents are vulnerable to prompt injection
LLMs don't have a reliable boundary between instructions and data. Trusted instructions and untrusted content share the same context window, and the model can't be relied on to tell "what my user asked for" apart from "text I happened to read while doing it." Prompt injection exploits that gap.
Direct prompt injection is when the person talking to the agent tries to override its instructions. For agents, the bigger worry is indirect prompt injection: instructions planted in content the agent reads while doing its job. That content can arrive through a lot of paths:
- emails and calendar invites the agent summarizes
- web pages it browses or retrieves
- GitHub issues, tickets, and documents
- tool descriptions supplied by a third-party server
- entries in the agent's own long-term memory
- messages from other agents
Detecting and filtering malicious instructions helps, but the organizations closest to the problem say it won't close the gap. OpenAI wrote in December 2025 that "prompt injection, much like scams and social engineering on the web, is unlikely to ever be fully 'solved'" (OpenAI). The UK's National Cyber Security Centre made a similar point that same month: prompt injection may never be totally mitigated the way SQL injection can be. (NCSC)
Evaluations show why. NIST's Center for AI Standards and Innovation (CAISI) red-teamed a model that was already one of the strongest at resisting hijacking on the AgentDojo benchmark. On held-out tasks, the strongest new attack succeeded 81% of the time, compared with 11% for the strongest baseline attack. Across five injection tasks, letting attackers retry each attack 25 times raised average success from 57% to 80%. (NIST CAISI) An agent that does well against last year's attacks hasn't been shown to resist the ones aimed at it specifically.
Guardrail vendors and researchers do report large drops in attack success on benchmarks. Benchmark results can overstate real-world protection when the attacks weren't adapted to the defense being evaluated, and strong performance against a fixed attack set isn't evidence of the same protection against an adaptive attacker. As Simon Willison puts it, a 95% detection rate would be a failing grade in web application security. Treat detection as one layer, and design as if some attacks will get through.
The capability check: lethal trifecta and the Rule of Two
If you can't reliably stop an agent from being manipulated, the next question is what a hijacked agent can do. Two closely related models answer that, and together they give you a check you can run on any agent design.
Simon Willison's lethal trifecta says an agent becomes an easy data-theft target when it combines three capabilities:
- access to private data
- exposure to untrusted content
- the ability to communicate externally
With all three, an attacker plants instructions in content the agent reads, the agent reads your private data, and then sends it somewhere the attacker controls. Remove any one of these capabilities and you break that particular exfiltration path, though not every other way the agent can be misused.
Meta's Agents Rule of Two generalizes this. It says that, until prompt injection can be reliably detected, an agent session should have no more than two of these properties:
- A: it processes untrustworthy inputs
- B: it has access to sensitive systems or private data
- C: it can change state or communicate externally
The difference is property C. Willison's third leg is exfiltration. Meta widens it to any state change, which also covers an attacker making the agent delete, deploy, transfer, or approve something. If a task really needs all three, Meta's guidance is that the agent shouldn't run autonomously. It needs a human approval step or another reliable check, or the work should be split so that no single context holds all three.
Applying the check is quick. For each agent, or each session if capabilities change mid-run, ask:
- Can anything it reads have been written by someone outside your trust boundary?
- Can it read data or reach systems that would matter if they leaked or broke?
- Can it send data out, or change anything?
If the answer to all three is yes, remove a capability, split the workflow, or put an enforced approval step in front of the dangerous action.
Meta is clear about the limits. The rule targets high-impact prompt injection. It doesn't address agent mistakes, hallucinations, or plain over-privilege, and a compliant design can still fail when a user approves a warning without reading it. Use it alongside least privilege and the other controls below.
Real-world AI agent security failures
The best-documented agent security failures line up with this model. Two of them are vulnerabilities that researchers found and disclosed, with no reported exploitation in the wild. The third is an operational failure with no attacker involved. In the two injection cases, all three legs were present, and the effective fixes removed or enforced a leg rather than trying to make the model harder to manipulate.
| Case | Untrusted input | Sensitive access | Outbound or state change | Failure and mitigation |
|---|---|---|---|---|
| EchoLeak, Microsoft 365 Copilot (CVE-2025-32711), disclosed June 2025 | An attacker's email sitting in the user's mailbox | The user's Microsoft 365 data in Copilot's context | An image URL carrying the data, fetched automatically through an allowed Teams domain | No click was needed. The chain evaded an injection classifier, link redaction, and a content security policy. Microsoft fixed it server-side before disclosure and reported no exploitation in the wild |
| GitHub MCP server, May 2025 | A malicious issue on the user's public repository | The user's private repositories | A public pull request | Every tool call was legitimate on its own, and the server behaved as designed. The recommended fix was limiting each session to a single repository, which removes the combination |
| Replit agent and SaaStr, July 2025 | None. This was an agent mistake, not an attack | Production database reachable from a development session | Destructive database commands | The "code and action freeze" existed only as a chat instruction. The agent deleted production data anyway. Replit's fixes separated development and production databases and added enforced planning-only modes (Replit database update and Plan Mode announcement) |
The first two are classic trifecta attacks. EchoLeak is especially instructive because Microsoft had several detection and filtering layers in place, and the researchers' exploit chain got past all of them. What it needed was an outbound path, and that's the leg defenders could control.
The Replit case has no attacker, and the Rule of Two explicitly doesn't cover mistakes. It's in the table because it shows from another angle that a prompt instruction is not an enforceable control. The freeze was text in the context window, and the model weighed it like any other text. The fixes that mattered were boundaries enforced in infrastructure, independent of what the model decided. Rules like "never send data to external addresses" or "only touch the staging environment" in a system prompt work the same way: they nudge the model, and nothing enforces them.
The main AI agent security risks
The OWASP Top 10 for Agentic Applications 2026, published in December 2025, is a widely recognized catalog of agent risks. Its ten entries fall into a few families.
Hijacked goals. Agent Goal Hijack (ASI01) is prompt injection plus autonomy: injected content redirects the agent's plan, and because the agent runs multiple steps on its own, the damage compounds. Rogue Agents (ASI10) covers agents that end up pursuing objectives nobody intended.
Misused tools and identities. Tool Misuse and Exploitation (ASI02) is about agents using tools they're allowed to use in harmful ways, such as chaining a harmless read with a sensitive write. Identity and Privilege Abuse (ASI03) covers agents running with borrowed human credentials or more privilege than the task needs. Unexpected Code Execution (RCE) (ASI05) is what happens when agent output reaches an interpreter or shell.
Poisoned inputs and memory. Memory and Context Poisoning (ASI06) extends injection over time. An attacker plants something in the agent's memory or retrieval sources, and it influences later runs, possibly for other users.
Compromised supply chain. Agentic Supply Chain Vulnerabilities (ASI04) covers the tools, plugins, skills, models, and servers an agent depends on. Skill and plugin marketplaces for agent frameworks have already been seeded with malicious packages, and a locally installed tool server runs with the same privileges as the client that launched it.
Failures that spread. Insecure Inter-Agent Communication (ASI07) and Cascading Failures (ASI08) cover multi-agent systems, where one compromised or confused agent passes bad instructions or data to others that trust it. Human-Agent Trust Exploitation (ASI09) covers attacks on the human in the loop, such as an agent presenting a misleading summary so that a reviewer approves something harmful.
OWASP's cheat sheet adds a risk that often gets missed: denial of wallet. An agent stuck in a loop, or pushed into one, can burn through tokens and API spend with no attacker ever touching your data.
MCP as an attack surface
The Model Context Protocol (MCP) is how many agents discover and call tools, so it's where several of these risks become concrete. Invariant Labs documented tool poisoning in April 2025: a tool's description contains hidden instructions that the model reads but the user interface doesn't show. Related attacks include rug pulls, where a server changes a tool's definition after you approved it, and shadowing, where a malicious server's tool descriptions influence how the agent uses tools from other, trusted servers.
On the authorization side, the MCP security best practices forbid token passthrough. An MCP server must not accept tokens that weren't issued for it. The best practices also push for narrow, progressively granted scopes instead of wildcard permissions requested up front. Pinning tool definitions, reviewing third-party servers before connecting them, and keeping scopes tight reduce exposure to several common MCP attack patterns. A full treatment of MCP security is beyond this article.
AI agent security controls that hold up under prompt injection
The controls worth relying on share one property: they still work when the agent is doing exactly what an attacker told it to do. They bound permissions, identity, network reach, spend, and irreversible actions in places the model can't edit.
Least privilege and minimal tool sets. Give each agent only the tools its task needs, and scope each tool narrowly: one repository instead of all of them, read-only database access unless writes are the point, specific endpoints instead of a general HTTP client. Every tool you remove takes options away from an attacker. This is also the most direct way to break up a trifecta.
A distinct identity for every agent. Give each agent its own attributable identity with short-lived, narrowly scoped credentials. When an agent acts on behalf of a user, use explicit delegation rather than sharing the user's session or personal access token, and keep both identities in your authorization and audit records. That way you can revoke the agent without locking out a person, its permissions can be narrower than a human's, and your audit trail shows who did what. NIST's National Cybersecurity Center of Excellence has published a concept paper on AI agent identity and authorization, so expect more guidance here.
Sandboxing and egress control. Run agents in constrained environments, such as containers or isolated virtual machines, with restricted file system access. Restrict outbound network access to an allowlist. Egress control is the most direct way to remove the exfiltration leg. Keep the allowlist tight, though. EchoLeak got its data out through a domain that was already allowed.
Human approval bound to the exact action. For high-impact or irreversible steps such as deleting data, moving money, changing production, granting access, or sending external messages, require approval of the specific action with its specific arguments, not a general "allow this agent to proceed." OWASP recommends binding approvals to the exact action so an approval can't be reused for something else. Be realistic about approval fatigue. People rubber-stamp prompts they see constantly, so save approvals for actions that matter.
Isolated memory. Keep memory per user or per session, validate content before storing it, and expire it. Otherwise one poisoned interaction can follow every later run.
Hard limits on cost and runtime. Cap tokens, spend, iterations, and wall-clock time per run, and add circuit breakers that stop an agent that keeps repeating the same calls. These limits bound denial-of-wallet loops whether a bug or an attacker started them.
Enforcement outside the prompt. If a rule matters, make the infrastructure enforce it: separate environments, permission boundaries, policy checks on tool calls before they run. Use the system prompt to guide behavior, never to secure it.
Adversarial testing against your own setup. Published benchmark scores don't tell you how your agent behaves with your tools, data, and permissions. OWASP recommends abuse-case testing and security gates in your release pipeline. Plant injected content in the places your agent actually reads, and adapt the attacks rather than replaying a fixed list, since NIST's results show how much new attacks and retries change the outcome.
Design-level defenses
Research is moving toward architectures that resist injection by construction. One example is CaMeL, from researchers at Google, Google DeepMind, and ETH Zurich. A privileged LLM writes a plan using only the trusted user request. A separate quarantined LLM handles untrusted data and has no access to tools. An interpreter tracks where each value came from and checks security policies before every tool call. For example, it can allow sending an email only to a trusted recipient, no matter what a retrieved document says.
In the second version of the paper, CaMeL completed 77% of AgentDojo tasks with provable security, compared with 84% for an undefended system. It assumes the user's prompt is trusted, its authors note side-channel weaknesses, and the reference code is a research prototype. It's still worth watching, because it applies established security ideas (capabilities, control flow integrity, information flow control) instead of asking another model to spot attacks.
How to monitor and audit AI agents
The second half of agent security is evidence. The GitHub MCP attack was a sequence of tool calls, each of which was allowed. Looking at any single call shows nothing wrong. The problem only appears when you correlate the calls across the trajectory: read an issue from a public repository, read private repositories, write their contents into a public pull request. So you need a record of each run, structured well enough to query and alert on.

The OWASP cheat sheet gives a solid baseline for what to capture:
- every agent decision, tool call, and outcome
- token usage and cost per session and per user, which also catches denial-of-wallet loops
- for high-risk actions, the action classification, authorization outcome, approval identifier, execution result, and the policy version in force
Record the identity the agent acted as and the human or system that initiated the run. Without that link, an audit trail tells you which token did something, not who was responsible.
For format, the OpenTelemetry GenAI semantic conventions define a vendor-neutral shape for agent telemetry. A typical instrumented agent run contains an invoke_agent operation with descendant operations for each model call (chat) and tool call (execute_tool). Depending on your framework, that run may itself sit inside a larger distributed trace. Attributes like gen_ai.agent.name, gen_ai.tool.name, and, when the framework supplies one, gen_ai.tool.call.id identify what ran. OpenTelemetry also defines conventions for MCP that are compatible with GenAI tool execution, so you can correlate direct tool calls and MCP-mediated calls in the same trace, with protocol-specific context where your instrumentation provides it. Because the format is an open standard, your evidence isn't tied to whichever agent framework or vendor you use this year.
Two caveats apply. First, the GenAI conventions are still at Development status and recently moved to their own repository, so attribute names can change between releases. Second, capturing prompt and message content is opt-in, for good reason. The full text of prompts, tool arguments, and responses is the most useful material for spotting injection and reconstructing an incident. It's also likely to contain personal data and secrets, and OWASP explicitly warns against logging PII or credentials in plain text. A common compromise is to capture full content only outside production and limit production to metadata, or redact at the source. Staging data can hold secrets and personal data too, so apply redaction, access controls, and retention limits wherever you capture content.
Once you have trajectories, look for patterns across steps. The standard GenAI attributes cover the agent, model, tool, and token usage. Most of the context below, such as resource sensitivity, authorization decisions, and approvals, needs application-specific instrumentation.
| Pattern in the trajectory | What it may indicate | Context you'll likely need to add |
|---|---|---|
| A sensitive read followed by a write or request to a public, external, or previously unseen destination | Data exfiltration, as in the GitHub MCP and EchoLeak cases | Resource sensitivity, destination |
| Repeated denied tool calls or approval requests | Attempts to get around controls | Authorization decisions |
| A high-risk action with no matching approval, or with arguments that differ from the approved ones | Approval boundary violation | Approval ID, approved arguments |
| Use of elevated privileges or resources outside the task's scope | Privilege abuse | Credential scope, target resource |
| A sudden rise in tool calls or token spend without progress | Runaway loop or denial of wallet | Iteration count, cost |
| A tool definition that changed since it was approved | Rug pull or supply chain compromise | Tool definition version |
| The agent reports success, but the downstream system disagrees | Unreliable reporting or a hidden failure | Downstream system records |
Treat these as signals to investigate, not proof of compromise. When one fires, the controls above are what let you respond: stop the run, revoke the agent's credentials without locking out a person, quarantine its memory, and check the systems it touched for changes.
Traces are also not automatically an audit trail. Tracing pipelines sample, drop, and expire data, and instrumentation can miss steps. For security-critical actions, have the tool or policy-enforcement layer write its own audit event, covering the authorization decision, the approval, and the result, and include the trace ID so you can join the two. Store those records where the agent can't modify or suppress them, with access controls and retention that fit their purpose. Then check the systems the agent changed. Their own records are the independent confirmation of what actually happened, which is the point of the argument in AI safety is an observability problem that an agent should never be the only witness to its own actions.
Telemetry tells you what the agent did. Whether that was acceptable is a separate question, which is where evals and checks against downstream systems come in. What is agentic observability covers this in more depth.
AI agent security frameworks and standards
You don't need to build an agent security program from scratch. A few sources cover most of what you need:
- The OWASP AI Agent Security Cheat Sheet is the most practical baseline. It covers controls for tools, input handling, memory, human approval, output validation, monitoring, multi-agent systems, data protection, and adversarial testing. It's actively maintained, so check it again periodically.
- The OWASP Top 10 for Agentic Applications 2026 gives you a shared risk vocabulary for threat models and reviews.
- The MCP security best practices cover tool integrations, authorization, and local server risks. The specification is versioned, so read the version your clients and servers implement.
- NIST's CAISI ran a request for information on securing AI agent systems in early 2026 and launched an AI Agent Standards Initiative covering security and agent identity. Check both for their latest published work.
Final thoughts
The most useful habit in AI agent security is to assume an agent that reads untrusted content can be manipulated, then design so that a manipulated agent can't do much harm. Run the capability check on every agent: untrusted input, sensitive access, and the ability to act or send data out. When all three are present, remove one, split the work, or put an enforced approval in front of the dangerous step. Put your boundaries in permissions and infrastructure rather than in prompts.
Then make the agent's work observable. Capture the security-relevant trajectory of each run, correlate tool calls with authorization decisions, and check outcomes against the systems the agent changed. A successful tool call tells you an action ran, not that it should have. That record is how you find out whether your controls are working, and what happened when they didn't.
If you're building out that evidence layer, start with LLM observability: a developer's guide and what is an agent harness.
