Skip to content

fix(auth)!: prevent fail-open bypass on generic auth errors#3078

Closed
Deeven-Seru wants to merge 1 commit intogoogleapis:mainfrom
Deeven-Seru:fix/auth-bypass-clean
Closed

fix(auth)!: prevent fail-open bypass on generic auth errors#3078
Deeven-Seru wants to merge 1 commit intogoogleapis:mainfrom
Deeven-Seru:fix/auth-bypass-clean

Conversation

@Deeven-Seru
Copy link
Copy Markdown
Contributor

@Deeven-Seru Deeven-Seru commented Apr 16, 2026

Description

Fixes a critical vulnerability where MCP server middleware failed to safely handle validation errors with http.StatusInternalServerError codes, leading to unauthorized actors bypassing the authentication layer if the external OIDC Authorization Server experiences an outage or DoS.

PR Checklist

  • Make sure to open an issue as a bug/issue before writing your code!
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involves a breaking change

Fixes #3076

@Deeven-Seru Deeven-Seru requested a review from a team as a code owner April 16, 2026 07:14
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the mcpAuthMiddleware in internal/server/server.go to handle a wider range of authentication errors by adding a default case for MCPAuthError and a catch-all for unexpected error types. The review identifies a security risk where sensitive internal details could be exposed in 500-level error messages and suggests implementing server-side logging for unexpected errors to improve observability and debugging.

Comment thread internal/server/server.go
Comment thread internal/server/server.go
Fixes a critical vulnerability where MCP server middleware failed to safely
handle validation errors with http.StatusInternalServerError codes, leading
to unauthorized actors bypassing the authentication layer if the external
OIDC Authorization Server experiences downtime.

Includes:
- Fail-closed error handling for all authentication failure codes.
- Sanitization of 5xx errors to prevent leaking internal details to clients.
- Observability logging for all authentication failures.
- Injection of logger into context before middleware execution.

Fixes googleapis#3076 🦕
@Deeven-Seru Deeven-Seru force-pushed the fix/auth-bypass-clean branch from 616f61b to 4f74f13 Compare April 16, 2026 07:20
@duwenxin99
Copy link
Copy Markdown
Contributor

Hi @Deeven-Seru, closing as it's a duplicate of #3067. Feel free to comment on that PR if you have any feedback/suggestions. Thanks!

@duwenxin99 duwenxin99 closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open authentication bypass in MCP middleware

2 participants