-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open authentication bypass in MCP middleware #3076
Copy link
Copy link
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: help wantedStatus: Unplanned work open to contributions from the community.Status: Unplanned work open to contributions from the community.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: help wantedStatus: Unplanned work open to contributions from the community.Status: Unplanned work open to contributions from the community.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
A critical authentication bypass exists in
internal/server/server.gowithinmcpAuthMiddleware. If an external Authorization Server using generic opaque tokens experiences an outage, timeout, or DNS failure (Code: 500), the middleware fails open, granting an unauthenticated attacker full access to the MCP SSE session and backend tools.Technical Details
In
internal/server/server.go:mcpAuthMiddleware, the authorization error is handled using a switch statement overmcpErr.Code:If an attacker deliberately sends a fake opaque token and the external introspection endpoint fails or times out,
ValidateMCPAuthreturns an*MCPAuthErrorwithCode: http.StatusInternalServerError. Theswitchstatement misses the500HTTP status code, exits the error block, and immediately callsnext.ServeHTTP(w, r). This completely bypasses authentication and allows the unauthenticated request to proceed.Impact
500introspection error, and subsequently unlocking the Toolbox framework.Recommended Mitigation
Change
mcpAuthMiddlewareto fail-closed immediately by applying adefaultcase in the switch block, and a catch-allhttp.Errorfor any non-MCPAuthError standard errors:CC: @averikitsch @Yuan325