Skip to content

fix(mcp): redirect-URI laxity probe false positives and unbounded recursion - #8

Merged
hackwither merged 2 commits into
hackwither:mainfrom
hannanmax:fix/redirect-uri
Sep 6, 2026
Merged

hackwither merged 2 commits into
hackwither:mainfrom
hannanmax:fix/redirect-uri

Conversation

@hannanmax

@hannanmax hannanmax commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Two bugs in mcp-redirect-uri-laxity

1. False positives on valid native-app redirect URIs

isBroadRedirectURI flagged any non-https URI as broad. This produced false positives for:

  • Custom URI schemes (myapp://callback, urn:ietf:wg:oauth:2.0:oob) — explicitly permitted by RFC 8252 for native apps
  • Loopback HTTP (http://localhost/callback, http://127.0.0.1/...) — permitted by RFC 8252 §8.3

At the same time, dangerous code-injection schemes (javascript:, data:, vbscript:) were silently allowed through the default branch.

Fix:

https://              -> flag if host empty or path is "/" or empty (unchanged)
http://               -> allow only localhost/127.0.0.1/::1 (RFC 8252 §8.3)
javascript:/data:/vbscript: -> always flag (injection vectors)
everything else       -> allow (native-app custom URI schemes per RFC 8252)
empty scheme          -> flag (malformed)

2. Unbounded recursion on deeply nested JSON

findRedirectURIs recursed 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.

… 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.
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.

2 participants