feat(auth): support distinct redirect URIs for OAuth mix-up defense (… - #2782
Open
guptamilind0099 wants to merge 1 commit into
Open
feat(auth): support distinct redirect URIs for OAuth mix-up defense (…#2782guptamilind0099 wants to merge 1 commit into
guptamilind0099 wants to merge 1 commit into
Conversation
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.
feat(auth): support distinct redirect URIs for OAuth mix-up defense (#2474)
What kind of change does this PR introduce?
Feature / Security Enhancement & Documentation Update
What is the current behavior?
All external OAuth providers share the single redirect URI endpoint (
/auth/v1/callback).As outlined in RFC 9700 § 4.4.2.2 (OAuth 2.0 Security Best Current Practice), using a single shared redirect URI across multiple identity providers presents potential risks for OAuth Mix-Up attacks if an attacker compromises a provider or operates a malicious custom OAuth provider.
Fixes #2474
What is the new behavior?
Distinct Redirect URIs per Provider:
/auth/v1/callback/{provider})./auth/v1/callback/{provider}, GoTrue verifies that{provider}in the URL path matches theflow_stateprovider saved in the database. If there is a mismatch, the request is rejected with400 Bad Request(ErrorCodeBadOAuthCallback) and an explicit OAuth mix-up error.Configuration Setting:
GOTRUE_EXTERNAL_USE_DISTINCT_REDIRECT_URISsetting toProviderConfiguration(defaultfalse). When set totrue, outgoing/authorizerequests append/{provider}to the redirect URI sent to external identity providers.100% Backward Compatibility:
/auth/v1/callbackcontinue to work without modification.GOTRUE_EXTERNAL_USE_DISTINCT_REDIRECT_URISdefaults tofalse, keeping existing default behavior unchanged unless explicitly enabled.Environment & Testing:
GOTRUE_EXTERNAL_USE_DISTINCT_REDIRECT_URISinexample.env.Additional context
Verification Tests