All guides

What does the MCP spec say about security, and what does it leave to you?

Updated

Short answer

The MCP spec's security best practices cover protocol-level attacks: confused deputy, token passthrough, SSRF, session and state handle hijacking, local server compromise and scope minimization. Most of those duties fall on server authors and client vendors. The spec also says MCP can't enforce its own security principles at the protocol level. Two things stay with you: which server you install, and whether each tool call fits the task.

What the spec covers#

The MCP security best practices page is written for people who implement authorization flows, run MCP servers or evaluate MCP systems. It lists attacks, and each one comes with a mitigation.

In plain words:

  • Confused deputy. An MCP proxy server that uses one static OAuth client ID can be tricked into handing an authorization code to an attacker. A consent cookie from an earlier login lets the attacker skip the consent screen. The spec says proxy servers must get consent per client and validate redirect URIs exactly.
  • Token passthrough. A server accepts a token that wasn't issued to it and forwards it downstream. The spec says MCP servers MUST NOT accept tokens that weren't explicitly issued for the MCP server.
  • SSRF. A malicious server can point a client's OAuth discovery at internal addresses, like a cloud metadata endpoint. Clients should block private address ranges.
  • Session and state handle hijacking. Holding a session ID or a handle the server issued must never count as authentication. Bind state to the authenticated user. The exact framing depends on your protocol version, so check the page for the one you run.
  • Local server compromise. This covers a malicious startup command in a config, or a malicious payload inside a server you downloaded. Clients that offer one-click local server setup must show the exact command and get explicit approval.
  • Client-side OAuth hygiene. Validate URLs before opening them, and don't let one client pass itself off as another.
  • Scope minimization. Start with low-risk scopes and ask for more only when a task needs them. Don't publish a wildcard scope.

Who owns what#

Spec concernWho mostly handles itWhat's left for you
Confused deputy, token passthroughServer authorsDon't deploy a server that accepts tokens issued for something else
SSRF, URL validationClient vendorsKeep clients patched; route server-side clients through controlled egress
Session and state handle hijackingServer authorsPrefer servers that bind state to the authenticated user
Local server compromiseClient vendor (consent) and you (what you approve)Decide which commands you're willing to run
Scope minimizationServer and clientIssue narrow credentials, whatever the server asks for

Most of that table is about wiring the protocol correctly. Almost none of it tells you whether the server is honest.

What the spec says it can't do#

The spec's overview is blunt here. It says tools represent arbitrary code execution and must be treated with caution, and that tool descriptions should be treated as untrusted unless they come from a trusted server.

It also says: "MCP itself cannot enforce these security principles at the protocol level." Implementors are asked to build their own consent and authorization flows.

So the spec assumes you've already decided to trust the server you connected. It doesn't say how to make that decision. It also can't tell you whether a given call, in a given session, is the right one.

A malicious server the spec can't stop#

In November 2026, Corgea reported a malicious PyPI package named dynamic-mcp. Per Corgea, it opens a public Cloudflare Quick Tunnel to an unauthenticated bash -c endpoint on 0.0.0.0:8080. That's one vendor's research, so verify it before you act on it.

A client could implement every mitigation in the spec and this package would still run. Nobody forged a token. A developer, or an agent, installed a server, and the server was the attack. It runs on a laptop that holds that developer's credentials.

The spec's consent rule for local servers helps when the startup command is visibly odd. It does much less for a package that looks like a normal tool and misbehaves after install.

Integration patterns that hold up#

  • Approve servers by the actual command or endpoint, not by name, and keep an inventory. See our guide to securing MCP servers.
  • Scope credentials per server. If a server's token is stolen, the damage should stop at one narrow resource, not reach the developer's whole account.
  • Reject token passthrough in anything you build or buy. Ask vendors whether they check that each token was issued for their server.
  • Run local servers sandboxed where you can, with limited filesystem and network reach.
  • Keep clients patched. The spec's client duties only help if your client version actually implements them.
  • Review authorization on its own. Our MCP authorization guide covers HTTP auth and stdio credentials.

Check each tool call, not just each server#

You approve a server once, but the agent keeps calling it. In our own use, an agent session averages 145 actions, and long sessions go past 1,000. A server you approved can be updated later. A tool you approved can be steered by a poisoned README or ticket.

Consent prompts don't scale to that volume. Anthropic reports that people approve 93% of permission prompts anyway.

Harden Agentic Integrity Foundation (AIF) runs on the developer laptop, outside the agent, at the agent's pre-execution hook. It checks each action the agent proposes against the session's intent before it runs. That includes commands, file edits, pushes, the install that pulls a server in, and MCP tool calls where the agent's hook exposes them. Decisions are made locally in about 28 ms, under one policy across agents, and it starts watch-only.

AIF is one layer. It doesn't contain a server process that's already running and malicious, and it doesn't replace scoped credentials, approved servers or egress policy. To see how the control categories compare, read MCP security tools.

The spec secures the protocol. The server you picked, and what it does next, are still yours to own.

FAQ

Related questions

Does the MCP spec require user consent for tool calls?

Its principles say hosts must get explicit user consent before invoking any tool. The spec also says MCP can't enforce that at the protocol level, so enforcement depends on each client.

Does the MCP spec cover session hijacking?

Yes. It treats session IDs and server-issued state handles as things an attacker can steal, so servers must not use them for authentication. The exact framing depends on your protocol version.

What is token passthrough in MCP?

Token passthrough is when a server accepts a token that wasn't issued to it and forwards it to a downstream API. The spec forbids it: MCP servers must not accept tokens that weren't explicitly issued for the MCP server.

Does the MCP spec protect me from a malicious MCP server?

Only in part. It asks clients to show the exact local startup command and get approval, and to treat tool descriptions as untrusted. It can't tell you whether a server you chose to install is honest.

Do I need to sandbox local MCP servers?

The spec recommends running local servers with minimal default privileges. Make a sandbox the default for any server you didn't write.

Sources

  1. Security Best Practices - Model Context Protocol
  2. Specification - Model Context Protocol
  3. dynamic-mcp: malicious PyPI package (Corgea research, November 2026)

Start free at harden.run

Full Enterprise access, free for 60 days: unlimited developers, custom policies, centralized visibility, no commitment.