OAuth HTTP routes set `CORSMiddleware(allow_origins="*")` on token/register/metadata endpoints |
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 explicitallowed_originslist (or reuseTransportSecuritySettings.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.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 11h
- PR unite (30g)
- 30
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/python-sdk
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/python-sdk#3566 ·
-
v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
modelcontextprotocol/python-sdk#3546 · 5 commenti ·
-
v1 v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
modelcontextprotocol/python-sdk#3545 · 1 commento ·
-
v1 v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
modelcontextprotocol/python-sdk#3508 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
modelcontextprotocol/python-sdk#3504 ·
Tutte le issue di modelcontextprotocol/python-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anthropics/skills#1811 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
speaches-ai/speaches#678 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
datalayer/mcp-compose#42 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
UKGovernmentBEIS/inspect_evals#2523 ·