Status: Patched
This vulnerability has been verified as resolved and deployed.
Authentication bypass on FastMCP custom routes
Summary
Broken Access Control in FastMCP custom routes
FastMCP.custom_route() allows developers to mount arbitrary HTTP handlers intended for sensitive use cases such as OAuth callbacks or admin APIs, but it never applies RequireAuthMiddleware even when the server is configured with a token verifier. Only the built-in SSE and StreamableHTTP endpoints are wrapped; custom routes are appended to the Starlette app as-is while Starlette’s AuthenticationMiddleware merely records credentials without rejecting unauthenticated requests. As a result any HTTP endpoint registered through @server.custom_route() remains publicly accessible despite OAuth or token-based authentication being enabled for the server. Attackers can directly invoke privileged administration handlers over the network without presenting credentials.
CVSS Score
Vulnerability Location
Sink-to-Source Analysis
Custom Starlette routes registered via custom_route() are appended to the SSE app without additional middleware.
custom_route() stores the developer handler as-is with no authentication enforcement even though docstring suggests admin usage.
Even when auth is enabled only AuthenticationMiddleware is added globally; it does not reject unauthenticated requests, so custom routes remain open.
Attacker-controlled HTTP request reaches privileged handler without proving identity, enabling arbitrary admin operations.
Impact Analysis
Critical Impact
Whatever privileged operations the route performs (e.g., issuing OAuth tokens, modifying server state) happen with attacker input. Confidentiality, integrity, and availability of the server are compromised.
Attack Surface
Any MCP deployment that calls FastMCP(..., token_verifier=..., auth=AuthSettings(...)) and registers routes via @server.custom_route().
Preconditions
None; attacker only needs network access. Authentication is enabled but not enforced on custom routes.
Proof of Concept
Environment Setup
Requirements: Ubuntu 22.04+, Python 3.10+, uv package manager.
Install dependencies:
Target Configuration
Create a minimal FastMCP server that enables OAuth-style auth but exposes an admin route:
Run the vulnerable server:
Exploit Delivery
Unauthenticated attack:
Outcome
An Internet attacker can trigger any custom admin route without valid tokens (resetting state, altering configuration, dumping data, etc.), fully bypassing the configured OAuth/token protections.
Expected Response:
No Authorization header is required even though the server advertises admin scope enforcement.
