This article explains how AI agents work, the security risks they pose, and practical defenses to control them. An agent is a language model that can take actions by calling tools, making it far more dangerous than a chatbot if compromised—a tricked agent does something wrong rather than just saying something wrong. The article covers real incidents, testable weaknesses, and control strategies grounded in the principle that agents should have minimal privileges and lack the dangerous combination of private data access, exposure to untrusted content, and outbound communication capability.
- Agent architecture creates four security touchpointsAgents operate in a loop: receive a goal, read context (system prompt, conversation, retrieved documents, tool descriptions, results), select a tool, and repeat. Security depends on four components: the model (which cannot reliably distinguish instructions from information), the context (all text treated as one stream), the tools themselves (email, files, code execution, databases, payment APIs), and the identity (the credentials tools run with). Each component is a potential attack surface.
- The dangerous combination defines real riskAn agent becomes high-risk when it simultaneously has access to private data, exposure to content an attacker can write, and a way to send data out. Any two of these three elements are manageable; all three together mean a single poisoned document, email, or web page can cause a data leak. This combination appeared in all three real incidents cited: the GitHub MCP server incident (May 2025), EchoLeak in Microsoft 365 Copilot (June 2025, CVE-2025-32711), and tool poisoning demonstrations.
- Prompt injection plus excessive agency equals damageThe article identifies prompt injection as the entry point and excessive agency as the determining factor in severity. Indirect prompt injection occurs when content an agent reads contains hidden instructions it follows. Excessive agency means the agent has more tools or permissions than the specific task requires. Together, these map to OWASP Top 10 for LLM Applications, with OWASP publishing a separate Top 10 for Agentic Applications in December 2025.
- MCP servers are dependencies requiring scrutinyThe Model Context Protocol, introduced by Anthropic in late 2024, is an open standard for connecting AI applications to tools and data. Thousands of MCP servers now exist, many written and installed by third parties with one command. Tool descriptions are plain text the model trusts, so whoever writes them can influence the model's decisions. An MCP server runs with your credentials, making it equivalent to any other software dependency in terms of security risk.
- Seven specific weaknesses enable agent compromiseThe article catalogs indirect prompt injection, excessive agency, confused deputy (agent using high privileges on behalf of low-privileged users), tool poisoning (hidden instructions in tool descriptions), unsafe tool output handling (passing results to shells or databases without validation), memory poisoning (false information stored for later sessions), and agent-to-agent trust (compromised agents passing instructions to others). Each has a primary control: treating fetched content as untrusted, least privilege per task, running tools with user permissions, reviewing/pinning tool definition
- Approval gates and breaks stop escalationRisky actions—sending, paying, deleting, sharing—must pause for human approval. Users must see what will actually happen, not just chat text. Breaking the dangerous combination by having an agent that reads untrusted content lose access to either private data or outbound tools reduces what a single compromised agent can accomplish. These defenses do not prevent compromise but limit blast radius.
- Testing requires mapping tools, sources, and pathsEffective testing lists every tool and its permissions (what it reads, changes, whose credentials it uses), identifies every text source (web pages, emails, files, tool descriptions, tool results, other agents), marks dangerous combinations, defines specific failures in advance (e.g., calling an unauthorized tool), and records the sequence of tool calls rather than relying on chat text. Testing must rerun after any new tool, server version change, or model update, as these can reopen closed attack paths.
- MCP protocol itself is not the core vulnerabilityMost MCP incidents stem from broad permissions, unvetted servers, and agents reading untrusted content rather than the protocol's design. The protocol simply connects tools; it does not enforce access control. This is fundamentally different from chatbot security, where the worst case is bad output; with agents, the worst case is a bad action with real consequences (data sent, records changed, code run).
Bottom line: Secure agents by identifying and breaking the dangerous combination of private data access, untrusted content exposure, and outbound communication, combined with least-privilege tool assignment and mandatory human approval for irreversible actions. Assume the model can be manipulated into calling any tool, then design permissions so that what it can then do is small and reversible.
An AI agent is a language model that can act: it reads information, decides what to do next and calls tools to do it. That is what makes agents useful, and it is also what makes them a security problem. A chatbot that is tricked says something wrong. An agent that is tricked does something wrong, with whatever access it was given.
This guide explains how agents and the Model Context Protocol (MCP) work, where they fail, what real incidents have shown, and the controls that limit the damage. Each section links to a lab where you can see the behaviour for yourself.
How an agent works
Every agent runs the same loop. The model receives a goal, reads its context, picks a tool, reads the tool’s result, and repeats until it decides the task is finished. Four parts matter for security:
- The model. It makes every decision, and it cannot reliably tell an instruction from information.
- The context. The system prompt, the conversation, retrieved documents, tool descriptions and tool results, all in one stream of text.
- The tools. Email, files, browsers, code execution, databases, payment and admin APIs.
- The identity. The credentials the agent’s tools run with, which decide what a mistake can reach.
What MCP is and why it matters
The Model Context Protocol is an open standard, introduced by Anthropic in late 2024, for connecting AI applications to tools and data. An MCP server describes its tools in plain language, and the model reads those descriptions to decide when and how to call them. Thousands of servers now exist, many written by third parties and installed with one command.
Two things follow. Tool descriptions are text the model trusts, so whoever writes them can influence the model. And an MCP server is software running with your credentials, so it deserves the same scrutiny as any other dependency.
Where agents fail
| Weakness | What happens | Main control |
|---|---|---|
| Indirect prompt injection | Content the agent reads contains instructions, and the agent follows them | Treat all fetched content as untrusted; limit what the agent can do after reading it |
| Excessive agency | The agent has more tools or permissions than the task needs | Least privilege, per task |
| Confused deputy | The agent uses its own higher privileges on behalf of a lower-privileged user | Run tools with the user’s permissions, checked in code |
| Tool poisoning | A tool’s description carries hidden instructions for the model | Review and pin tool definitions; alert when they change |
| Unsafe tool output handling | A tool result is passed to a shell, browser or database without checks | Validate output like any other untrusted input |
| Memory poisoning | False information is stored and shapes later sessions | Control what is written to memory; let users see and clear it |
| Agent-to-agent trust | One compromised agent passes instructions to others | Authenticate and limit messages between agents |
| Supply chain | A malicious or vulnerable MCP server, plugin or package is installed | Vet sources, pin versions, sandbox |
The common thread is in the OWASP Top 10 for LLM Applications: prompt injection is the way in, and excessive agency decides how bad the result is. OWASP also published a separate Top 10 for Agentic Applications in December 2025.
the agent hijack lab and the confused deputy lab.
The dangerous combination
An agent becomes high-risk when it has three things at once: access to private data, exposure to content an attacker can write, and a way to send data out. Any two are manageable. All three mean a single poisoned document, email or web page can lead to a leak. When you review an agent, look for this combination first, and remove one of the three wherever you can.
Real cases
- GitHub MCP server, May 2025. Researchers at Invariant Labs showed that a crafted issue in a public repository could lead an agent connected to GitHub to pull data from the same user’s private repositories and publish it. Nothing in the server was broken in the usual sense. The agent had broad access and read untrusted text.
- EchoLeak, June 2025. Aim Security disclosed CVE-2025-32711 in Microsoft 365 Copilot, described as a zero-click flaw: a single email could cause the assistant to send out internal data without the user doing anything. Microsoft fixed it on the server side and said it had seen no customer impact.
- Tool poisoning, 2025. Invariant Labs also demonstrated that instructions hidden in an MCP tool’s description are read by the model but rarely shown to the user, so a server can steer an agent while looking harmless in the interface.
Each case is the dangerous combination in practice: private data, untrusted content and a way out.
How to test an agent
Test only systems you own or have written permission to test.
- List every tool and its permissions. For each one, write down what it can read, what it can change and whose credentials it uses.
- List every source of text. Web pages, emails, files, tickets, tool descriptions, tool results, memory, other agents.
- Mark the dangerous combinations. Where can untrusted text reach a tool that reads private data or sends data out?
- Define failures in advance. For example: the agent calls a tool the user did not ask for, or acts on another user’s data.
- Test each path and record tool calls. The evidence is the sequence of calls, not the chat text.
- Check the approvals. Confirm that risky actions pause for a person, and that the prompt shows what will really happen.
- Retest after changes. A new tool, a new server version or a model update can reopen a closed path.
Our AI red teaming guide covers how a full engagement runs.
Defences that hold up
| Defence | What it does | Its limit |
|---|---|---|
| Least privilege per task | The agent gets only the tools and scopes this task needs | Takes design effort for every workflow |
| User-scoped credentials | Tools act with the requesting user’s permissions, enforced in code | Harder for shared or background agents |
| Human approval for risky actions | Sending, paying, deleting and sharing wait for a person | People stop reading if asked too often |
| Breaking the combination | An agent that has read untrusted content loses access to private data or to outbound tools | Reduces what a single agent can do |
| Sandboxing | Code execution and browsing run in an isolated environment with limited network access | Does not protect data placed inside the sandbox |
| Vetting and pinning MCP servers | Only reviewed servers at fixed versions; changes to tool descriptions raise an alert | Ongoing work as servers update |
| Short-lived, narrow tokens | A leaked credential expires quickly and reaches little | Needs identity infrastructure |
| Logging every tool call | Unusual sequences are noticed and can be investigated | Detects; does not prevent |
The rule is the same as for prompt injection: assume the model can be talked into anything, and make sure that what it can then do is small. Related reading: prompt injection in agentic workflows and identity for AI agents.
Frequently asked questions
Is MCP insecure?
The protocol is a way to connect tools; it does not decide how much access you grant. Most MCP incidents come from broad permissions, unvetted servers and agents reading untrusted content, not from the protocol itself.
How is agent security different from chatbot security?
A chatbot’s worst case is usually bad output. An agent’s worst case is a bad action: data sent, records changed, code run. The model weakness is the same; the consequences are larger.
Can a better model fix this?
Newer models resist injection more often, but none resist it every time. Safe design assumes the model will sometimes be fooled.
Should agents ever run without human approval?
For low-risk, reversible actions inside a narrow scope, yes. For anything that sends, pays, deletes or shares, keep a person in the loop.
Where can I practise legally?
On systems built for it. The SecurityElites labs include agent and tool-abuse scenarios against live models, and the SE-ARTCP certification tests the skill hands-on.
