fix(mcp): redirect-URI laxity probe false positives and unbounded recursion - #8
Merged
Merged
Conversation
… risk Two bugs in the mcp-redirect-uri-laxity check: 1. isBroadRedirectURI flagged any non-https URI, including native-app custom URI schemes (myapp://callback) and RFC 8252 §8.3 loopback http://localhost — both are legitimate and explicitly allowed by the OAuth for Native Apps spec. Fix: allow custom schemes (anything other than http/https) and loopback http:// hosts. 2. findRedirectURIs was unbounded on deeply nested JSON: a response with 11+ levels of nesting would grow the call stack indefinitely. Fix: cap recursion at 10 levels via a depth counter.
The previous fix allowed any non-http/https scheme as a native-app custom URI (RFC 8252). javascript:, data:, and vbscript: are code injection vectors that OAuth servers should never accept as redirect URIs; flag them explicitly before reaching the RFC 8252 allowance.
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.
Two bugs in
mcp-redirect-uri-laxity1. False positives on valid native-app redirect URIs
isBroadRedirectURIflagged any non-httpsURI as broad. This produced false positives for:myapp://callback,urn:ietf:wg:oauth:2.0:oob) — explicitly permitted by RFC 8252 for native appshttp://localhost/callback,http://127.0.0.1/...) — permitted by RFC 8252 §8.3At the same time, dangerous code-injection schemes (
javascript:,data:,vbscript:) were silently allowed through the default branch.Fix:
2. Unbounded recursion on deeply nested JSON
findRedirectURIsrecursed without a depth limit. An adversarially crafted (or just unusually nested) OAuth metadata document could overflow the stack.Fix: Cap recursion at 10 levels via a depth counter passed through
findRedirectURIsAt.