Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#3,563 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
api, backend, security

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
24.3k
Forks
4k
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
30

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/python-sdk

Alle Issues in modelcontextprotocol/python-sdk

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.