Summary
A flawed authentication fallback in LiteLLM's MCP Streamable HTTP endpoint lets attackers bypass LiteLLM key validation by crafting a specific Authorization header.
When this OAuth2 passthrough path is triggered, requests can reach MCP tooling without a valid gateway key, exposing backend tools to unauthenticated access.
Affected context
The vulnerability occurs in LiteLLM deployments that expose the MCP Streamable HTTP endpoint and rely on LiteLLM key-based authentication to protect access to MCP tools.
It becomes relevant when the gateway is configured to accept Authorization headers and includes an OAuth2 passthrough or fallback mechanism.
In such configurations, mis-handled error paths in key validation can result in requests being treated as authenticated even when they do not present a valid LiteLLM key.
Exploit preconditions
- Attack surface: Public or internal LiteLLM MCP Streamable HTTP endpoint over HTTP(S)
- Required access: Network reachability to the LiteLLM gateway; no valid LiteLLM key is required
- Trigger point: Submission of requests with a crafted or fabricated Authorization header that causes LiteLLM key validation to fail and invoke the OAuth2 passthrough fallback
- Why exploitation is possible: The fallback path replaces failed key validation with an empty
UserAPIKeyAuth()object, which is treated as a successful authentication state, allowing requests to proceed to MCP tooling without enforcing key checks
Why this happens
This issue stems from incorrect handling of authentication failures within a multi-path auth flow combining LiteLLM key validation and OAuth2 passthrough.
Instead of treating failed key validation as a hard deny, the code constructs an empty UserAPIKeyAuth() object in a fallback path, effectively representing a user context with no associated key.
That empty context is still treated as authenticated, creating a classic CWE-287: Improper Authentication condition and overlapping with CWE-306: Missing Authentication for Critical Function, since sensitive MCP tooling is reachable without proof of identity.
Abstractly, the bug class is an insecure error-handling pattern where authentication failures fall back to permissive defaults instead of explicit rejection.
Potential impact
- Attackers can make unauthenticated calls to MCP tooling exposed through LiteLLM
- MCP tools may be used to invoke privileged backend actions (e.g., data access, system commands, integrations) without a valid gateway key
- Abuse of AI gateway resources, including quota exhaustion or cost escalation
- Potential exposure of sensitive data processed by tools attached to MCP
- Expansion of an attacker's capabilities within internal automation pipelines that trust LiteLLM-authenticated requests
General mitigation guidance
Mitigation generally involves tightening authentication flows and ensuring that failure states cannot degrade into implicit success.
Pattern-based defensive measures include:
- Treat all key validation and OAuth2 token checks as fail-closed: if any mandatory credential check fails, the request should be rejected with a clear error rather than passed through.
- Centralize authentication logic so that there is a single, explicit decision point determining whether a request is authenticated, instead of scattered fallbacks.
- Avoid constructing "empty" or default auth context objects that can be misinterpreted as valid credentials; require explicit user identity or key association.
- Separate transport-level Authorization header parsing from internal auth decisions, and ensure passthrough mechanisms do not override gateway access controls.
- Apply least privilege to MCP tooling and avoid assuming the gateway has already robustly authenticated the caller; tools can implement additional checks or scope limitations.
How teams detect issues like this
Detection involves both code-level and behavior-level strategies:
- Static analysis and code review: Look for authentication code paths that create default or empty auth objects after failed checks, and for conditional branches where a failure is converted into a permissive state. Pay attention to combined key and OAuth2 validation flows.
- Policy enforcement: Enforce development policies requiring fail-closed behavior in authentication functions and disallow "best-effort" fallbacks that treat missing or invalid credentials as partial success.
- Runtime monitoring: Instrument the gateway to log authentication decisions, including reasons for fallback paths; alert on requests that reach MCP tooling without a validated LiteLLM key or associated user context.
- Security testing: Use automated tests or tooling to send malformed or fabricated Authorization headers to the MCP endpoint and verify that access is consistently denied when credentials are invalid or absent.

