Explainer
MCP security: tool poisoning, token scope and the lethal trifecta
The real attacks on MCP setups, from tool poisoning and rug pulls to token passthrough and the lethal trifecta, what hosts do about them, and a checklist.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
The Model Context Protocol makes it easy to give an agent new abilities: install a server, and the model can read your tickets, query your database or post to Slack. The same ease is the risk. Every MCP server is either code running on your machine or a service your agent sends data to and takes instructions from, and the model cannot reliably tell a legitimate instruction from a malicious one.
This explainer covers the attack classes that have been demonstrated, what the specification and hosts do about them, and a checklist for using and building servers. Sources are linked inline; facts were checked on 20 November 2026.
The core problem
A language model treats everything in its context as potential instructions: your request, the system prompt, tool descriptions, and the text that comes back from tool calls. MCP adds two new sources to that context, both of which you may not control:
- Tool metadata: names, descriptions and input schemas, written by the server author.
- Tool output: whatever the server returns, which often includes text written by third parties (issue bodies, emails, web pages, documents).
Most MCP attacks are prompt injection delivered through one of those channels, combined with tools powerful enough to do damage.
Attack classes
Tool poisoning
Invariant Labs described tool poisoning in April 2025: hidden instructions in a tool’s description that the user never sees but the model reads. Their example was an innocent-looking add tool whose description told the model to read ~/.cursor/mcp.json and ~/.ssh/id_rsa and pass the contents in an extra parameter. The confirmation dialog showed a call to add; the arguments carried the secrets. (Invariant Labs)
Rug pulls
A server can change its tool descriptions after you approved it. A server that was harmless on Monday can ship poisoned descriptions on Friday, through a package update or simply because a remote server changed. Approval at install time does not protect you from what the server says later.
Tool shadowing
In a session with several servers, one server’s description can change how the model uses another server’s tools. Invariant’s demonstration had a malicious server’s description redirect all messages from a trusted send_email tool to an attacker’s address. You do not even have to call the malicious tool; its description sits in context and does the work.
Injection through tool output
In May 2025 Invariant Labs showed an attack on the official GitHub MCP server: an attacker files an issue in a public repository containing instructions. When the user asks their agent to look at that repository’s issues, the agent reads the issue, follows the instructions, pulls data from the user’s private repositories, and publishes it in a pull request on the public repository. Nothing was wrong with the server’s code. The flaw was the combination of capabilities. (Invariant Labs)
The lethal trifecta
Simon Willison named the pattern behind that attack in June 2025. An agent is exposed to data theft when it has all three of:
- access to private data,
- exposure to untrusted content, and
- a way to communicate externally (send email, make web requests, open pull requests, even render an image from a URL).
(Simon Willison) MCP makes it easy to assemble all three by accident, one sensible-looking server at a time: a mail server that reads your inbox (private data plus untrusted content) and a web fetch tool (external communication) is enough. The practical defence is to make sure no single agent session has all three.
Token problems
Remote servers act on your behalf with OAuth tokens, which creates classic access-control failures that the MCP specification addresses directly:
- Token passthrough. A server that accepts any token and forwards it to a downstream API lets an attacker reuse tokens across services and breaks audit trails. The 2026-07-28 specification says servers “MUST NOT accept or transit any other tokens” and must validate that tokens were issued for them.
- Over-broad scopes. A token with
files:*oradmingranted up front turns any leak into full access. The specification’s security guidance recommends a minimal starting scope and step-up requests when a privileged tool is first used. - Confused deputy. MCP servers that proxy to a third-party API with one shared client ID can be tricked into handing an authorisation code to an attacker unless they run their own per-client consent screen. (MCP security best practices)
- State handle hijacking. With protocol sessions removed in the 2026-07-28 revision, servers that need state hand out handles as tool arguments. A server that treats possession of a handle as proof of identity lets anyone who guesses one act as its owner.
Local server compromise
A local (stdio) server is a program you run with your own permissions. A malicious package, or a one-click install that hides a harmful command, executes with access to everything you can access. A local server that listens on HTTP without authentication can also be reached by other processes, and by web pages through DNS rebinding, which is why the transport specification requires servers to validate the Origin header and recommends binding to 127.0.0.1.
What hosts and the protocol do about it
No host makes these risks go away, but current ones help:
- Approval before use. Claude Code asks before using servers from a project’s
.mcp.json; Cursor asks before MCP tool calls by default; Codex only reads project MCP config in trusted projects. - Visible tool lists.
/mcpin Claude Code and Codex, and Cursor’s settings panel, show which tools each server exposes. Read the descriptions of servers you add. - Tool allowlists. Codex’s
enabled_toolsanddisabled_toolslimit what the model can see from a server. Claude Code permission rules can deny specific MCP tools. - Sandboxing. Run local servers in a container if they handle untrusted input. Note that Claude Code’s Bash sandbox does not cover MCP servers; they run outside it.
- The specification. OAuth 2.1 with audience-bound tokens, a ban on token passthrough,
Originvalidation and deterministic tool ordering are all in the 2026-07-28 revision. - Scanners. Tools such as Snyk’s
agent-scan(formerlymcp-scan) inspect installed servers’ tool descriptions for injection patterns and changes. They catch known patterns, not everything.
Checklist for using MCP servers
- Install servers only from sources you trust, and read their tool descriptions before enabling them.
- Pin versions (
@playwright/mcp@0.0.86, not@latest) and review changes before upgrading. - Give each session only the servers it needs. Do not leave a dozen enabled “just in case”.
- Check every session for the lethal trifecta. If an agent reads untrusted content and holds private data, remove its ability to communicate externally, or split the work across sessions.
- Grant OAuth scopes narrowly: read-only where possible, one repository or workspace rather than all.
- Never click “always allow” for tools that write, send or delete.
- Keep secrets out of committed MCP config; use environment variables.
- Run local servers that process untrusted input in a container.
- Revoke tokens (not just delete local config) when you remove a remote server.
Checklist for building MCP servers
- Use stdio for local servers; if you must use HTTP locally, bind to
127.0.0.1, validateOriginand require a token. - For remote servers, implement OAuth as the specification requires: protected resource metadata, audience validation, no token passthrough. Secure a remote MCP server with OAuth walks through it.
- Split scopes into read and write, and check scopes per tool.
- Bind any state handles to the authenticated user.
- Keep tool descriptions short and factual. Never include instructions about other tools.
- Mark or wrap third-party text in tool results so hosts can treat it as data, and return the minimum needed.
- Log tool calls with the caller’s identity.
Next steps
- Understand the underlying attack in Prompt injection basics.
- Build a server with proper authorisation in Secure a remote MCP server with OAuth.
- See where these risks sit in the OWASP Top 10 for LLM applications.
- Apply the same thinking to skills with Audit a skill before installing it.
- Get the roles and transports straight in what is MCP? The Model Context Protocol explained.
- Check the scopes in your own setup against the mcp.json cheat sheet.
- Choose servers with these risks in mind from the best MCP servers by job, each listed with the access it needs.
- See the same trifecta in AI browsers with agent modes in are AI browsers safe?
Covers
Related
- Secure a remote MCP server with OAuth
Protect a Streamable HTTP MCP server with OAuth 2.1 as the 2026-07-28 spec requires: resource metadata, audience checks, per-tool scopes and Inspector tests.
- Prompt injection basics for builders
How direct and indirect prompt injection work, why agents with tools raise the stakes, and the design choices that limit the damage when no complete fix exists.
- Connect MCP servers to Claude Code, Codex and Cursor
Add local and remote MCP servers to Claude Code, Codex and Cursor, choose the right scope, sign in with OAuth and check which tools actually loaded.
- Tool poisoning
Malicious instructions hidden in a tool's description, parameters or output that manipulate the agent using it without the user seeing them.
- Lethal trifecta
Access to private data, exposure to untrusted content and a way to send data out: together they make data theft by prompt injection possible.