Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

OAuth HTTP routes set `CORSMiddleware(allow_origins="*")` on token/register/metadata endpoints |

Abierto
#3,563 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api, backend, security

Línea de trabajo

The issue is in src/mcp/server/auth/routes.py, focusing on the _cors function and its usage. First, understand how OAuth endpoints are configured and where TransportSecuritySettings.allowed_origins is defined. The task is to modify the CORS configuration for specific endpoints, ensuring the metadata handlers keep the wildcard while sensitive endpoints use an explicit allowlist. Run existing tests related to authentication and CORS to verify changes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

v1 v2

Static review of public source at commit 6affe5c0d358. No traffic was sent to any MCP environment.

OAuth route helpers wrap several endpoints with Starlette CORSMiddleware and a wildcard origin:

src/mcp/server/auth/routes.py:

def _cors(app: ASGIApp, allow_methods: list[str]) -> ASGIApp:
    return CORSMiddleware(
        app=app,
        allow_origins="*",
        allow_methods=allow_methods,
        allow_headers=[MCP_PROTOCOL_VERSION_HEADER],
    )

That wrapper is used for /.well-known/oauth-authorization-server, /token, and (when enabled) /register and /revoke. Wildcard ACAO is intentional for browser-based inspectors, and allow_credentials is not set here (browsers will not attach cookies under the * + credentials rule). Still, token and dynamic-registration endpoints are sensitive: a wildcard makes any future “reflect Origin + credentials” change, or a non-browser client that ignores CORS, easier to misuse.

Suggested change:

  • Keep * only on public metadata handlers.
  • For /token, /register, and /revoke, take an explicit allowed_origins list (or reuse TransportSecuritySettings.allowed_origins) and document the Inspector origin as an example allowlist entry.
  • Add a one-line comment that credentials must stay off while * remains.

Severity: low / configuration clarity and defense-in-depth. Not reported as an exploitable CORS bypass with the current header pair. No proof-of-concept.

Happy to send a focused PR if useful.

Lenguaje dominante
Python
Estrellas
24.3k
Forks
4k
Merge medio
1 d 11 h
PR fusionados (30 d)
30

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/python-sdk

Todos los issues de modelcontextprotocol/python-sdk

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.