The MCP project publishes its own catalogue of attacks and mitigations, but it is long, versioned and written for protocol implementers, so many teams never turn it into controls. The Security Best Practices page that accompanies the MCP specification describes eleven attack patterns, from the confused deputy problem in OAuth proxies to state handle hijacking in the stateless protocol introduced in revision 2026-07-28. This guide explains each one in plain terms, says who has to act (client, server, proxy or authorisation server), lists the MUST and SHOULD requirements that matter, and shows how to test and monitor them. It is based on the version published alongside revision 2026-07-28, checked on 27 October 2026, and is for engineers, security architects and reviewers who own MCP deployments. The broader risk overview is in the MCP Security Guide.
Key takeaways
- Most attacks exploit trust in what a server says. SSRF, authorisation URL injection and mix-up all start with a client acting on URLs or metadata supplied by a server it should not trust.
- Proxies carry the heaviest obligations. An MCP server that fronts a third-party API with a static client ID MUST run its own per-client consent before forwarding users to the upstream authorisation server.
- Possession is never authentication. Neither a session ID (2025-11-25 and earlier) nor a state handle (2026-07-28) may stand in for verifying the token on every request.
- Local servers are a code execution problem. One-click installation MUST show the exact command and get explicit consent; sandboxing and minimal privileges are SHOULD-level but are where the real protection lies.
- Scope design is a security control. Minimal starting scopes and targeted step-up limit what a stolen token can do and keep audit trails readable.
The attack catalogue at a glance
The page is versioned with the specification. The 2026-07-28 edition replaced the earlier "Session Hijacking" section with "State Handle Hijacking", because protocol-level sessions and the Mcp-Session-Id header were removed, and added sections on mix-up attacks, localhost redirect URI impersonation and Client ID Metadata Document (CIMD) trust policies. Teams supporting older clients still need the 2025-11-25 session guidance.
| Attack | Primary actor who must fix it | Headline requirement |
|---|---|---|
| Confused deputy | MCP proxy server | MUST implement per-client consent before third-party authorisation |
| Token passthrough | MCP server | MUST NOT accept tokens not explicitly issued for it |
| Server-side request forgery | MCP client (and CIMD authorisation servers) | Clients deployed to a server MUST consider SSRF; SHOULD enforce HTTPS and block private ranges |
| State handle hijacking | MCP server | MUST NOT treat possession of a handle as authentication; SHOULD bind handles to the user |
| Local MCP server compromise | MCP client | MUST show the exact command and require consent for one-click installs |
| OAuth authorisation URL validation | MCP client | MUST allow only http/https and MUST NOT open URLs through a shell |
| stdio transport in proxy scenarios | Local proxy and client | SHOULD sandbox spawned processes and log all stdio usage |
| Mix-up attacks | Client and authorisation server | Validate RFC 9207 iss against the recorded issuer |
| Localhost redirect impersonation | Authorisation server | MUST clearly display the redirect URI hostname at consent |
| CIMD trust policies | Authorisation server | MAY apply domain allowlists, reputation or domain-age checks |
| Scope minimisation | Server and client | Minimal initial scopes, incremental elevation by challenge |
Confused deputy in MCP proxy servers
The setup: an MCP proxy server lets MCP clients register dynamically, but uses one static client ID with a third-party authorisation server that does not support dynamic registration. That third-party server sets a consent cookie after the first approval. If the proxy does not run its own per-client consent, all four vulnerable conditions in the specification are present.
The attack: a user legitimately connects once, so their browser holds a consent cookie for the proxy's static client ID. An attacker registers a new client with an attacker-controlled redirect_uri and sends the user a crafted link. The third-party server sees the cookie, skips consent, and the proxy delivers an MCP authorisation code to the attacker, who exchanges it for a token and acts as the user.
Required protections (MUST):
- Per-client consent storage: keep a registry of approved
client_idvalues per user and check it before starting the third-party flow. - Consent page content: name the requesting client, show the third-party scopes and the registered
redirect_uri, implement CSRF protection, and block framing withframe-ancestorsorX-Frame-Options: DENY. - Consent cookies: use the
__Host-prefix, setSecure,HttpOnlyandSameSite=Lax, sign them or use server-side sessions, and bind them to the specificclient_id. - Redirect URIs: exact string matching only; reject a changed URI without re-registration.
- State: generate a cryptographically random
stateper request, store it only after consent is approved and immediately before redirecting upstream, validate it exactly at the callback, make it single-use and short-lived (the page gives 10 minutes as an example).
The ordering rule is the one most often broken: setting the state cookie before consent approval makes the consent screen ineffective. See the Clickjacking Guide for framing controls.
Token passthrough
Token passthrough is an MCP server accepting a client's token without checking it was issued to the MCP server, then forwarding it downstream. The page lists four consequences: security controls that depend on token audience (rate limiting, validation, monitoring) are bypassed; the MCP server cannot tell clients apart and downstream logs show the wrong identity; a token accepted by several services lets an attacker who compromises one reach the others; and adding controls later becomes harder. The mitigation is a flat MUST NOT accept tokens not explicitly issued for the server. The authorisation specification adds that when the server calls upstream APIs it acts as an OAuth client with its own token. Detailed token rules are in the MCP Authorisation Specification Guide.
Server-side request forgery during discovery
An MCP client fetches URLs a server controls: the resource_metadata URL from WWW-Authenticate, the authorization_servers list and the endpoints in authorisation server metadata. A malicious server can point these at http://169.254.169.254/, internal admin panels, localhost:6379, a DNS rebinding domain or a redirect chain. Risks include cloud credential theft, network reconnaissance through error messages and state-changing POSTs to internal services.
| Control | Requirement level | Implementation detail |
|---|---|---|
| Enforce HTTPS | SHOULD | Reject http:// except loopback during development, with an explicit opt-out |
| Block private and reserved ranges | SHOULD | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, ::1, 169.254.0.0/16, fc00::/7, fe80::/10 |
| Validate redirect targets | SHOULD | Apply the same checks to each hop, or disable automatic redirects |
| Egress proxy | SHOULD consider (server-side clients) | Route discovery through a proxy that blocks internal destinations, such as Smokescreen |
| DNS pinning | Consider | Pin resolution between check and use to defeat time-of-check to time-of-use rebinding |
The page warns against hand-written IP validation because octal, hex and IPv4-mapped IPv6 encodings defeat naive parsers. In 2026-07-28 it also notes that authorisation servers fetching CIMD documents face the same SSRF risk and should apply the same controls. See the SSRF Prevention Guide.
State handle hijacking (and legacy session hijacking)
Revision 2026-07-28 made MCP stateless. Servers that need cross-call state mint a handle, such as a cart or workflow ID, and receive it back as an ordinary tool argument. If the server does not check the handle belongs to the caller, anyone who obtains or guesses it can operate on another user's state.
- MUST: servers that implement authorisation verify all inbound requests and do not treat possession of a handle as authentication.
- SHOULD: generate handles with a secure random number generator, avoid sequential identifiers, and expire them.
- SHOULD: key stored state as
<user_id>:<handle>, with the user ID taken from the verified token rather than from the client, and reject a handle presented by any other principal.
For 2025-11-25 and earlier, the equivalent rules apply to Mcp-Session-Id: servers MUST NOT use sessions for authentication and MUST use secure, non-deterministic session IDs, and the page describes a session hijack prompt injection variant in which an attacker injects events into a shared queue keyed only by session ID. Multi-instance deployments still on that revision should bind queue keys to the user.
Local MCP server compromise
Local servers are binaries downloaded and run on the user's machine. The page names three routes: a malicious startup command in client configuration, a malicious payload in the server itself, and an insecure local server reached through DNS rebinding. Its example startup commands chain npx with exfiltration of ~/.ssh/id_rsa.
- MUST (clients with one-click configuration): show the exact command without truncation, including arguments; identify it as potentially dangerous code execution; require explicit approval; allow cancellation. This comes from SEP-1024, which has Final status.
- SHOULD (clients): highlight dangerous patterns such as
sudo,rm -rfand network operations; warn on access to the home directory, SSH keys and system directories; warn that servers run with client privileges; run servers sandboxed with minimal default privileges and explicit grants for extra directories or network access. - SHOULD (servers meant to run locally): use stdio to limit access to the client; if HTTP is used, require an authorisation token or use Unix domain sockets or other restricted IPC.
The Amazon Q MCP config vulnerability shows why the consent rule exists: MCP server definitions in a repository file were loaded and launched, and the spawned processes inherited the developer's AWS credentials. Practical isolation steps are in the Local MCP Server Security Guide.
Authorisation URL validation and the stdio proxy escalation
Malicious servers can supply authorisation URLs that exploit how clients open them. A javascript: URL passed to window.open() gives script execution in the client; a URL passed to cmd.exe, PowerShell or sh can inject shell commands.
- Scheme allowlist (MUST): only
http://andhttps://, withhttponly for loopback during development; rejectjavascript:,data:,file:andvbscript:; prefer allowlists to blocklists. - No shell (MUST NOT): never open URLs through shell commands; use platform URL-opening APIs.
- CSP (SHOULD, web clients):
script-src 'self',default-src 'self', or nonces for required inline scripts. - Sanitise and log (MUST sanitise): strict parsing, reject shell metacharacters, and log suspicious URLs.
The page then describes how XSS in a client can escalate through a local MCP proxy that spawns stdio servers: the attacker steals the proxy's authentication token and asks it to spawn arbitrary commands. This applies only to proxy architectures, not to direct stdio use. Proxies SHOULD sandbox spawned processes, restrict their filesystem access, log all stdio usage and require extra authorisation for dangerous commands. See the Cross-Site Scripting (XSS) Prevention Guide.
Mix-up, localhost impersonation and CIMD trust
Mix-up: a client talks to many authorisation servers; one that is malicious tries to get the client to send it a code issued by an honest one. The fix is RFC 9207 response validation against the issuer recorded before redirecting. The page is explicit that PKCE does not stop this, because the client sends the code_verifier to the attacker's token endpoint, and that the protection only works if honest servers emit iss.
Localhost redirect impersonation: with CIMD, an attacker can present a legitimate client's metadata URL as their client_id, listen on any localhost port and receive the code; the user sees the genuine client name. Authorisation servers SHOULD warn on localhost-only redirect URIs, MAY require attestation and MUST clearly display the redirect URI hostname.
CIMD trust policies: authorisation servers decide which URL-based client IDs to accept, from an allowlist of trusted domains for protected servers to any HTTPS client_id for open ones, with reputation, domain-age or certificate checks in between.
Scope minimisation
The page's scenario is an attacker who obtains a token carrying files:*, db:* and admin:* because the server listed every scope in scopes_supported and the client requested them all. Mitigation is a progressive model: a minimal initial set (the example is mcp:tools-basic), elevation through targeted WWW-Authenticate challenges, and tolerance of down-scoped tokens. Servers should emit precise challenges and log elevation events with correlation IDs; clients should start with baseline scopes and cache recent denials to avoid loops. The common mistakes listed include wildcard or omnibus scopes, bundling unrelated privileges, silent changes to scope meaning without versioning, and treating token scopes as sufficient without server-side authorisation logic.
Applying the guidance: rollout and decisions
- Classify each component: client, server, proxy server (fronting a third-party API), local proxy spawning stdio servers, or authorisation server. The table above tells you which sections apply.
- Close the MUSTs first: audience validation and no passthrough, per-client consent in proxies, URL scheme allowlisting and no-shell URL opening, one-click install consent, handle-to-user binding.
- Then the SHOULDs with the biggest blast radius: SSRF egress controls for server-side clients, sandboxing for local servers, minimal scopes.
- Test with hostile fixtures: a test MCP server that returns
resource_metadatapointing at169.254.169.254, an authorisation endpoint using thejavascript:scheme, a wrongiss, a guessed handle from a second test user, and a dynamically registered client with a new redirect URI. Every case must fail safely. - Roll out in rings: enable checks for internal users first, monitor rejection logs for false positives, and roll back a specific check per client rather than globally.
Decision guidance: small teams consuming a handful of remote servers should concentrate on client-side items (URL validation, SSRF, install consent) and pick clients that implement them. Organisations publishing MCP servers carry the server and proxy items, and larger estates should place a gateway in front to enforce token validation and logging consistently. See the MCP Gateway and MCP Server Governance Guide.
Detection and measurement
- Consent bypass attempts: callbacks rejected for missing or mismatched
state, and authorisation requests from newly registered clients with unfamiliar redirect hosts. - SSRF blocks: discovery fetches blocked by the egress proxy, by destination; any attempt at a metadata address is a signal about the server that supplied it.
- Handle misuse: handles presented by a principal other than their owner (should be zero in normal operation).
- Rejected authorisation URLs: count and source servers of disallowed schemes.
- Scope elevation events: requested versus granted scopes per client, and the proportion of tokens issued with the minimal set.
- Local install consents: approvals and cancellations from managed endpoints, where the client can report them.
Framework mapping
| Best practice | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | ATT&CK / ATLAS |
|---|---|---|---|
| Confused deputy, consent | AC-3, SC-23 Session Authenticity | PR.AA-05 | T1528 Steal Application Access Token |
| Token passthrough | IA-9, AC-6 | PR.AA-03 | T1550.001 Application Access Token |
| SSRF | SC-7, SI-10 | PR.IR-01 | T1552.005 Cloud Instance Metadata API |
| Local server compromise | CM-11 User-installed Software, SC-39 Process Isolation | PR.PS-05 | T1195.002 Compromise Software Supply Chain, AML.T0010 AI Supply Chain Compromise |
| Authorisation URL validation | SI-10, SC-18 Mobile Code | PR.PS-06 | T1059 Command and Scripting Interpreter |
| Logging of elevation and rejections | AU-2, AU-12, SI-4 | DE.CM-09 | Supports detection across the catalogue |
The OWASP MCP Top 10 (2025 beta) overlaps heavily: MCP01 Token Mismanagement and Secret Exposure, MCP02 Privilege Escalation via Scope Creep, MCP05 Command Injection and Execution, and MCP07 Insufficient Authentication and Authorization.
Common failure patterns
- Consent cookie set too early: the proxy stores
statebefore the user approves, so a crafted link skips the MCP consent page. - Wildcard redirect matching: pattern-matched redirect URIs let an attacker register a lookalike path on an allowed host.
- Handles as bearer secrets: a workflow ID returned in a tool result is enough to resume another user's workflow because the server never checks ownership.
- Shell-based URL opening: a desktop client calls
openorstartthrough a shell with the server-supplied URL. - Consent without containment: a client shows the install command, the user approves, and the server then runs with full access to the home directory and inherited environment. In the postmark-mcp malicious MCP server case, versions worked normally until one added a hidden BCC to an attacker, which no install-time dialog could have revealed.
Practitioner checklist
- Map each MCP component to the attack table and record which revision of the best practices it follows.
- In OAuth proxies, implement per-client consent,
__Host-signed consent cookies and post-consentstatehandling. - Reject any token not issued for the server and never forward client tokens.
- Enforce HTTPS, private-range blocking and redirect validation on discovery, through an egress proxy for server-side clients.
- Bind state handles (or legacy session IDs) to the user ID from the verified token.
- Require exact-command consent for one-click local installs and run local servers sandboxed.
- Allowlist
http/httpsfor authorisation URLs and open them without a shell. - Validate
issper RFC 9207 and show redirect hostnames at consent. - Publish a minimal
scopes_supportedand log every elevation with a correlation ID.
Standards and references
- Model Context Protocol: Security Best Practices (revision 2026-07-28)
- Model Context Protocol: Security Best Practices (revision 2025-11-25)
- Model Context Protocol: Authorization Security Considerations
- Model Context Protocol: SEP-1024 MCP Client Security Requirements for Local Server Installation
- Model Context Protocol: Key Changes in revision 2026-07-28
- Model Context Protocol: Local Server Security
- Model Context Protocol: Streamable HTTP Transport (revision 2026-07-28)
- OWASP: MCP Top 10
Related NHI Mgmt Group resources: MCP Security Guide · MCP Authorisation Specification Guide · Local MCP Server Security Guide · MCP Security Testing Guide · OAuth Token Theft Incident Playbook