Confused deputy, token passthrough, SSRF

Model Context Protocol (MCP) · Expert · 15 min

Remote servers sit between users, AI clients and third-party APIs, which is exactly where authorization bugs hide.

Remote MCP servers often call other APIs on the user's behalf. Three classic mistakes:

Confused deputy. A deputy is a program acting with more authority than its caller. Imagine your MCP server is an OAuth proxy to a third-party API and uses one fixed client ID with that API. If the user already consented to that client ID once, a malicious MCP client can trick the flow into skipping consent and receive a code for the user's account. Mitigation: the MCP server must obtain its own per-client user consent before forwarding to the third party, and strictly validate redirect URIs and state values.

Token passthrough. Accepting a token from the client and forwarding it unchanged to a downstream API (or accepting tokens issued for some other service) breaks audience checks, audit trails and rate limits, and lets stolen tokens be replayed. The spec forbids it: accept only tokens issued for your server, and get separate tokens for downstream calls (for example via token exchange).

SSRF (server-side request forgery). During discovery, a client fetches URLs supplied by servers (metadata, authorization endpoints). A malicious server can point those at internal addresses such as cloud metadata services or localhost. Clients and servers that fetch URLs should require HTTPS, block private and link-local ranges, and not follow redirects blindly.

Also in the security guide: scope minimization (start with minimal scopes, step up when needed), session/state hijacking (never trust unverified handles for identity; bind state to the authenticated user), and mix-up attacks (check the iss value so one authorization server can't impersonate another).

Remember

  • OAuth-proxy servers must collect their own per-client consent
  • Never pass client tokens through; only accept tokens issued for your server
  • Guard every server-supplied URL fetch against SSRF
  • Minimize scopes and validate iss to prevent mix-up attacks

Check yourself

  1. Your MCP server forwards the user's incoming bearer token straight to GitHub's API. What's the problem?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices

Builds on

Unlocks

Nothing builds on this yet.