fix: prevent account enumeration on recover endpoint for invalid emai… - #2723
Open
guptamilind0099 wants to merge 3 commits into
Open
fix: prevent account enumeration on recover endpoint for invalid emai…#2723guptamilind0099 wants to merge 3 commits into
guptamilind0099 wants to merge 3 commits 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.
(#2702)
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Fixes #2702.
On
POST /auth/v1/recover, attempting password recovery for an existing user on an invalid or reserved email domain (such as@example.com) returnsHTTP 400 email_address_invalid, whereas a missing user returnsHTTP 200 OK. This response discrepancy creates an account enumeration vector.Please link any relevant issues here.
What is the new behavior?
Intercepts
ErrorCodeEmailAddressInvalidinside theRecoverhandler and responds withHTTP 200 OK, matching the missing user response and eliminating the account enumeration leak.Added unit test
TestRecover_EmailAddressInvalidNoLeakininternal/api/recover_test.goto ensure both existing and missing users on invalid domains returnHTTP 200 OK.Additional context
Verified locally against PostgreSQL test suite.