OAuth HTTP routes set `CORSMiddleware(allow_origins="*")` on token/register/metadata endpoints |
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 24.3k
- Fork
- 4k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 30
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/python-sdk#3566 ·
-
Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE) Đang mởv1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/python-sdk#3546 · 5 bình luận ·
-
v1 v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/python-sdk#3545 · 1 bình luận ·
-
v1 v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
modelcontextprotocol/python-sdk#3508 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
modelcontextprotocol/python-sdk#3504 ·
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·