OAuth discovery drops explicit default ports from advertised issuer identifiers
Les mainteneurs répondent en général sous 2 jours
@gocamille y travaille déjà.
Depuis le 31/10/2026.
Évaluation
Cette issue n'a pas encore été évaluée.
Description
Summary
OAuth discovery rejects internally consistent metadata when the advertised authorization-server issuer contains an explicit default port, such as https://auth.example.com:443/tenant1.
The original identifier is parsed into a Url, which removes :443. The serialized URL is then used as the expected issuer, while AuthorizationMetadata.issuer retains the original JSON string.
Reproduced against main at c742b5536724ec376b14b7ddcbbd024b7d6ae163 (rmcp 3.8.0). The same code is present at 98a54789b80110ad210495c4ad845c89e1980471, the rmcp revision pinned by Codex 0.166.0.
Reproduction with simulated metadata
Using the existing RecordingOAuthHttpClient test helper, return these responses during AuthorizationManager::resolve_metadata():
- An initial
401for the MCP resourcehttps://mcp.example.com/. - Protected resource metadata:
{
"resource": "https://mcp.example.com/",
"authorization_servers": ["https://auth.example.com:443/tenant1"]
}
- Authorization-server metadata:
{
"issuer": "https://auth.example.com:443/tenant1",
"authorization_endpoint": "https://auth.example.com/tenant1/authorize",
"token_endpoint": "https://auth.example.com/tenant1/token"
}
No real OAuth credentials or external service are needed.
Expected: discovery accepts the metadata because its issuer exactly matches the identifier advertised by protected resource metadata.
Actual:
Authorization server issuer mismatch: expected https://auth.example.com/tenant1, received https://auth.example.com:443/tenant1
Root cause
In crates/rmcp/src/transport/auth.rs, authorization_metadata_from_resource_metadata() parses the candidate with Url::parse(candidate), then calls:
.try_discover_oauth_server(&candidate_url, Some(candidate_url.as_str()))
candidate_url.as_str() has already lost the explicit default port. Parsing is appropriate for transport, but its normalized output no longer represents the original OAuth identifier.
This also creates an asymmetric check: an advertised issuer containing :443 can incorrectly match metadata that omits it, because the expected value has been normalized first.
Relation to #1144 / #1145
#1145 preserves the issuer through discovery to address the trailing-slash problem in #1144, but retains the parsed URL representation. That preserves a tenant's trailing slash while still losing an explicit default port and host casing.
I did not find an existing issue specifically covering this default-port case. #1268 concerns HTTP Origin validation and is a separate problem.
Proposed approach
Preserve the advertised absolute issuer string for identity validation, separately from the parsed URL used to construct discovery requests. Keep the existing resolved-URL behavior for legacy relative references.
The fix should not normalize both issuers or treat identifiers with and without :443 as interchangeable. RFC 8414 sections 3.3 and 4 require validation against the original issuer identifier.
Local validation and question
A local candidate fix has mocked regression coverage for matching and mismatched default ports, nonstandard ports, host casing, tenant paths and trailing slashes, including the complete metadata discovery path. A before/after comparison of OAuth and HTTP tests found no new failures; full upstream CI has not been run.
Would preserving the original advertised identifier be an appropriate follow-up to #1145 before submitting a PR?
AI assistance was used for the investigation and local regression tests. All examples above use fictional domains and tenants.
- Langage dominant
- Rust
- Étoiles
- 4.1k
- Forks
- 694
- Merge moyen
- 3 j 14 h
- PR mergées (30 j)
- 39
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/rust-sdk
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopePeut-être pris @jstar0 l’a pris il y a 24 jours. Ouvertebug P1 ready for work T-security T-transport
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
modelcontextprotocol/rust-sdk#1330 ·
Les mainteneurs répondent en général sous 2 jours
-
`register_client` drops `client_secret_expires_at` from the registration responsePeut-être pris @gocamille l’a pris il y a 3 jours. Ouvertebug P2 ready for work T-security
modelcontextprotocol/rust-sdk#1416 · 1 commentaire · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
Typed client calls drop the parse error when a reply misses a required fieldPeut-être pris @gocamille l’a pris il y a 3 jours. Ouverteenhancement P2 ready for work T-core T-service
modelcontextprotocol/rust-sdk#1415 · 1 commentaire · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
Return merged cache hints from list_all_* client methodsPeut-être pris @gocamille l’a pris il y a 4 jours. Ouverteenhancement P2 ready for work T-service
modelcontextprotocol/rust-sdk#1411 · 1 commentaire · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
-
auth: refresh_token() always sends `scope`, so refresh fails against Salesforce ("scope parameter not supported")Peut-être pris @gocamille l’a pris il y a 4 jours. Ouvertebug P2 ready for work T-security T-transport
modelcontextprotocol/rust-sdk#1408 · 3 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de modelcontextprotocol/rust-sdk
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 70/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
limitlessprojects/Go-Hybrid#3342 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
librespeed/speedtest-rust#52 · 1 commentaire ·
-
enhancement needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
bherbruck/solvecraft#11246 · 1 commentaire · 1 réaction ·
-
example
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
rust-lang-nursery/rust-cookbook#954 ·
Les mainteneurs répondent en général sous 1 jour