Short answer: secure an MCP server by accepting only tokens issued for it, giving each tool the smallest scope, blocking private network ranges during OAuth discovery, sandboxing local servers and logging every call. The MCP specification's security best practices (version 2026-07-28, checked November 24, 2026) name eleven attacks and risks. Use the list below at review time.
What are the main MCP security risks?
The specification covers the risks below. The table lists them all.
| Threat | What goes wrong |
|---|---|
| Token passthrough | A server forwards a token that was issued for another service. Audit trails blur and rate limits are bypassed. |
| Confused deputy | A proxy with a static client ID and open client registration lets an attacker skip consent and steal a code. |
| SSRF | Discovery URLs point at internal addresses or the cloud metadata endpoint. |
| Scope inflation | One token carries scopes for every tool. |
| State handle hijacking | A guessed handle gives access to another user's state. |
| Local server compromise | A one-click local server runs a malicious start-up command. |
| Authorization URL abuse | A malicious server supplies a javascript: or shell-injection URL that the client opens. |
| stdio proxy escalation | In a proxy design, script injection in the client reaches a proxy that spawns local processes. |
| Mix-up attacks | A client is tricked into sending a code from one authorization server to another. |
| Localhost redirect impersonation | A local process claims a real client's identity and receives the code on a localhost port. |
| Client ID metadata trust | An authorization server fetches an attacker-chosen URL, or trusts any domain. |
Controls at the gateway
- Reject any token whose audience is not the MCP server.
- Exchange tokens for downstream calls. Never forward the client's token.
- Map each tool to one scope and use insufficient-scope challenges to raise it.
- Block private, loopback and link-local ranges with a tested library, validate redirects and use an egress proxy.
- Write agent, user, server, tool, scope and decision to the log for every call.
How do we stop SSRF during OAuth discovery?
A client fetches the resource metadata URL, the authorization server URLs and the token endpoint, and a malicious server controls those values. The specification asks for these controls, and they apply equally to an authorization server that fetches client ID metadata documents:
| Control | Detail from the specification |
|---|---|
| Require HTTPS | Reject http:// URLs except loopback addresses during development |
| Block private ranges | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, loopback, 169.254.0.0/16 (cloud metadata) and the private IPv6 ranges |
| Use a library | Do not parse addresses by hand. Octal, hex and IPv4-mapped IPv6 forms defeat custom checks |
| Validate redirects | Apply the same checks to every hop, or turn off automatic redirects |
| Egress proxy | Route discovery through a proxy that blocks internal destinations |
| DNS rebinding | Pin the resolved address between check and use |
Credentials
- Tokens go in the Authorization header, never in the URL.
- Keep refresh tokens confidential in storage and in transit.
- Servers that use stdio take credentials from the environment, not from OAuth.
What should a proxy do to avoid the confused deputy problem?
The specification says an MCP proxy server must keep a registry of approved client IDs for each user and check it before it sends anyone to the third-party authorization server. Its own consent page must name the client, list the scopes being requested and show the redirect URI. Other requirements:
- Match the redirect URI exactly against the registered value, with no patterns or wildcards.
- Use a random state value for each request, single use and short lived, and set the state cookie only after the user approves.
- If consent is tracked in a cookie, use the __Host- prefix with Secure, HttpOnly and SameSite=Lax, and bind it to the specific client ID.
- Stop the consent page being framed, with a frame-ancestors directive or X-Frame-Options.
Local servers
A client with one-click setup must show the exact command, without truncation, and get approval before it runs. Run servers in a sandbox with minimal file and network access. A server meant to run locally should use stdio, or require a token or a restricted channel if it uses HTTP.
Review checklist
- Is every MCP server in a register with an owner?
- Does each server check the token audience?
- Does any proxy use one client ID for many clients, and does it ask for consent per client?
- Is the allow-list of agent, server and tool triples written down?
- Have tool descriptions been reviewed, and does a change raise an alert?
- Are local servers sandboxed?
- Are state handles random, expiring and tied to the user in the verified token?
- Can you show a log for one call?
Questions we hear
Does the gateway replace server review? No. A gateway enforces identity, audience, scope and logging in one place, but a badly written server still needs its own review.
Is holding a handle enough to prove who someone is? No. The specification says servers must not treat possession of a state handle as authentication.
For the token flow itself, see MCP authentication with OAuth.
A first engagement
Duczer East offers an MCP security review: we take your register of servers, test the controls above on a sample and hand back a ranked list of fixes.



