Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#3,563 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
api, backend, security

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Python
Étoiles
24.3k
Forks
4k
Merge moyen
1 j 11 h
PR mergées (30 j)
30

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/python-sdk

Toutes les issues de modelcontextprotocol/python-sdk

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.