Skip to content

Validate DCR redirect_uris with HTTPS-or-loopback policy#2860

Open
KirtiRamchandani wants to merge 8 commits into
modelcontextprotocol:mainfrom
KirtiRamchandani:fix/dcr-redirect-uri-validation
Open

Validate DCR redirect_uris with HTTPS-or-loopback policy#2860
KirtiRamchandani wants to merge 8 commits into
modelcontextprotocol:mainfrom
KirtiRamchandani:fix/dcr-redirect-uri-validation

Conversation

@KirtiRamchandani

Copy link
Copy Markdown

Problem

Dynamic client registration accepts dangerous redirect_uris such as javascript:, data:, file:, cleartext non-loopback http://, and URIs with fragments. The SDK already enforces an HTTPS-or-loopback policy for issuer URLs, but DCR did not apply the same checks.

Root cause

RegistrationHandler passed client-submitted redirect_uris straight through after Pydantic URL parsing. AnyUrl accepts any syntactically valid scheme.

Fix

  • Add validate_registered_redirect_uri() alongside the existing issuer URL validator
  • Reject unsafe schemes, non-loopback HTTP, and fragment-bearing redirect URIs during /register
  • Return invalid_client_metadata when validation fails

Testing

  • Extended tests/server/auth/test_routes.py
  • python3 -m pytest tests/server/auth/test_routes.py -q --confcutdir=tests/server/auth

Fixes #2629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DCR registration accepts redirect_uris with non-HTTPS / non-loopback / fragmented schemes

1 participant