fix: prevent open redirect in redirect_uri validation#542
Merged
lakhansamani merged 2 commits intomainfrom Apr 3, 2026
Merged
Conversation
When allowed_origins=* (the default), IsValidOrigin() accepted any URL as a valid redirect_uri, enabling attackers to steal password reset tokens, magic link tokens, and OAuth tokens by redirecting users to attacker-controlled domains. Add IsValidRedirectURI() that never accepts * as a blanket pass. When allowed_origins=*, only self-origin redirects are allowed. Also add redirect_uri validation to /logout and /authorize which had none. Fixes #540
Cover *.example.com patterns, port-specific wildcards, multi-origin with wildcards, and bypass attempts like example.com.attacker.com.
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.
Summary
IsValidRedirectURI()that never accepts*as a blanket pass for redirect URIs (unlikeIsValidOriginused for CORS)allowed_origins=*(default config), only self-origin redirects are permitted/logoutand/authorizewhich previously had noneIsValidOrigintoIsValidRedirectURIjavascript:,data:,ftp:) in redirect URIsAffected Endpoints (9 total)
forgot_passwordIsValidOrigin(bypassed with*)IsValidRedirectURImagic_link_loginIsValidOrigin(bypassed with*)IsValidRedirectURIsignupIsValidOrigin(bypassed with*)IsValidRedirectURIinvite_membersIsValidOrigin(bypassed with*)IsValidRedirectURI/verify_emailIsValidOrigin(bypassed with*)IsValidRedirectURI/oauth/loginIsValidOrigin(bypassed with*)IsValidRedirectURI/appIsValidOrigin(bypassed with*)IsValidRedirectURI/logoutIsValidRedirectURI/authorizeIsValidRedirectURITest plan
IsValidRedirectURI(wildcard, explicit origins, non-HTTP schemes, port matching)IsValidOrigintests unaffected (CORS behavior unchanged)Fixes #540