fix: clear email change token when token hash is used#1240
Closed
J0 wants to merge 1 commit into
Closed
Conversation
1 task
Contributor
Author
|
Let's close this and use #1241 |
J0
added a commit
that referenced
this pull request
Sep 6, 2023
## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in #1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
uxodb
pushed a commit
to uxodb/auth
that referenced
this pull request
Nov 13, 2024
…abase#1241) ## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in supabase#1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 13, 2024
…abase#1241) ## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in supabase#1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 15, 2024
…abase#1241) ## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in supabase#1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
cemalkilic
pushed a commit
that referenced
this pull request
Aug 7, 2025
## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in #1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
xeladotbe
pushed a commit
to xeladotbe/supabase-auth
that referenced
this pull request
Sep 27, 2025
…abase#1241) ## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in supabase#1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
fadymak
pushed a commit
that referenced
this pull request
Sep 30, 2025
## What kind of change does this PR introduce? There are two issues the PR aims to resolve: 1. Currently, a Token Hash can be re-used twice in place of using the token hash send to the new email and a token has in the current mail. A solve attempt was originally made in #1240 but a test was added in this branch. 2. Currently, the single confirmation response is slightly misformed and has an additional null param <img width="1062" alt="CleanShot 2023-09-04 at 15 47 04@2x" src="https://github.com/supabase/gotrue/assets/8011761/69da91e5-e646-4970-8e80-1659e2e3fd41"> This stems from the return in the transaction. sendJSON doesn't return an error. Consequently, he error returned by the transaction will be nil. This leads to <img width="755" alt="CleanShot 2023-09-04 at 15 47 41@2x" src="https://github.com/supabase/gotrue/assets/8011761/af583492-1aac-4cbd-aaad-856282cce808"> `sendJSON(w, http.StatusOK, token)` being run after `sendJSON` is callled which will write the `token` (`nil` in this case) to the existing singleConfirmationResponse. This in turn affects returned response for the first confirmation as the client library is unable to unpack the returned JSON with extra null leading to an error. ## What is the new behavior? Returns response <img width="617" alt="CleanShot 2023-09-04 at 15 50 07@2x" src="https://github.com/supabase/gotrue/assets/8011761/e27db0ab-0489-4cda-a25f-8a650db5cab1"> ## Additional context TODO - [x] Need to complete a test for the SecureEmailChange TokenHash to prevent a regression --------- Co-authored-by: joel@joellee.org <joel@joellee.org>
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.
What kind of change does this PR introduce?
Currently, it is possible to use the same
TokenHashtwice during Secure Email Change. This could potentially lead to malicious users requesting an email to a given email and then completing the flow with the token they receive in their email.This is not too major as it's not possible to do an email change to an existing account which blocks potential account takeover attempts. The main downside we aim to guard against would be devs blocked from signing up because someone is squatting on their name similar to what happens when a signup is made but confirmation is not completed.