fix(auth): remove email enumeration leak from signup duplicate check#283
Open
anshul23102 wants to merge 1 commit into
Open
fix(auth): remove email enumeration leak from signup duplicate check#283anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
Fixes omkarhole#280 When a signup attempt used an already-registered email, the endpoint returned res.json({ email: existing.email }) with HTTP 200. This echoed the verified email back in the response body, allowing any caller to enumerate which addresses are registered by attempting signup and checking whether the response includes an email field. Changed to res.status(409).json({ error: 'An account with this email already exists' }). HTTP 409 Conflict is the correct status for a resource creation attempt that fails due to a uniqueness constraint. The response body no longer includes any data derived from the existing user document.
|
@anshul23102 is attempting to deploy a commit to the omkarhole's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Related Issue
Closes #280
Problem
When a signup used an already-registered email, the endpoint echoed the existing user's email and returned HTTP 200:
This let any caller enumerate registered addresses by attempting signup and checking whether the response body contained an
emailfield. The response also used the wrong HTTP status code.Fix
Files Changed
backend/controllers/auth.controller.jsres.json({ email: existing.email })withres.status(409).json({ error: '...' })Could you please add appropriate labels to this PR? It would help with tracking. Thank you!