Repository navigation
auth: reject userinfo, fragments, and dot segments in client ID URLs - #1362
Merged
guglielmo-san merged 2 commits intoOct 9, 2026
Merged
guglielmo-san merged 2 commits into
guglielmo-san merged 2 commits into
Conversation
NewAuthorizationCodeHandler accepted a client ID metadata document URL with a username, a fragment, or a "." or ".." path segment. draft-ietf-oauth-client-id-metadata-document-00 section 3, which ClientIDMetadataDocumentConfig.URL cites, says those MUST NOT appear. A query is still accepted, because that draft only says SHOULD NOT. Fixes modelcontextprotocol#1361 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
guglielmo-san
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While reading
NewAuthorizationCodeHandlerI checkedClientIDMetadataDocumentConfig.URLagainst draft-ietf-oauth-client-id-metadata-document-00 section 3, which that field cites. The check only required HTTPS and a non-empty path, so a URL with a username, a fragment, or a.or..path segment was accepted and later sent as theclient_id. Repro is in #1361.Those three are MUST NOT in that section. I reject them in
validateClientIDMetadataDocumentURL. An empty fragment is included:url.Parsedrops it, so the check looks for#in the raw URL.%2e%2eis caught after the path is decoded. A query is still accepted, because the draft says SHOULD NOT, not MUST NOT.https://example.com/is still accepted, because/is a path.No API change. The old "non-root HTTPS URL" error is unchanged for a missing path or a non-HTTPS scheme.
Tested with go1.27.1 on darwin/arm64, on
mainat 8dd5d6a:TestClientIDMetadataDocumentURLfails before the fix: the userinfo, fragment, and dot-segment cases return a nil error. It passes after.gofmt -lon the two auth files is clean,go vet ./auth/is clean, andgo test -count=1 -race ./auth/passes../auth/(run withGOTOOLCHAIN=go1.26.0, since v0.6.1 can't read Go 1.27 export data).Fixes #1361
AI disclosure: this PR, including the patch and the tests, was written primarily by Claude Opus 5.5 in Cursor.