fix(auth): accept any port on loopback redirect URIs (RFC 8252 §7.3) #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "oauth-loopback-port"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
RFC 8252 §7.3 requires the authorization server to allow any port on a loopback redirect URI.
is_allowed_redirect_uridemanded exact string equality, so the deployedhttp://localhost:8787/callbackentry could never match Claude Code CLI's randomly chosen loopback port and DCR rejected every attempt withunregistered redirect_uri.Change
loopback_matches_ignoring_portcompares scheme, host, path and query and ignores the port, and it fires only when the allowlist entry is a cleartext loopbackhttpURI. Everything else keeps full string equality, so anhttpsor private-use-scheme entry still pins its port:https://claude.ai/api/mcp/auth_callbackdoes not admithttps://claude.ai:8443/api/mcp/auth_callback.Host is not relaxed either.
localhostand127.0.0.1remain distinct, per RFC 8252, which relaxes the port alone.Tests
Three new tests, and each was watched failing against a deliberately broken matcher:
entry_host == uri_hostloopback_entry_matches_any_port,loopback_relaxation_does_not_widen_hostsentry.path() == uri.path()loopback_entry_matches_any_portentry.query() == uri.query()loopback_entry_matches_any_portnon_loopback_entries_keep_exact_port_matchingloopback_entry_matches_any_port,loopback_relaxation_does_not_widen_hostsGates
cargo fmt --all --checkclean,cargo clippy --all-targets --all-features --locked -- -D warningsclean,cargo test --all-features --locked99 passed / 0 failed,cargo auditexit 0,cargo deny check bans licenses sourcesbans ok / licenses ok / sources ok.Codex reviewed the matcher read-only and confirmed no non-loopback URI, and no loopback URI with a different host, path or query, can reach acceptance through the new branch.
The same defect is in
carddav-mcp,jmap-mcp,typst-mcpandm365-mcp; they are being fixed separately.Closes #2