fix: add input validation for check_type in duplicate check#3967
Open
Nixxx19 wants to merge 1 commit intoprocessing:developfrom
Open
fix: add input validation for check_type in duplicate check#3967Nixxx19 wants to merge 1 commit intoprocessing:developfrom
Nixxx19 wants to merge 1 commit intoprocessing:developfrom
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.
Issue:
Fixes #3906
The
duplicateUserCheckendpoint was usingreq.query.check_typedirectly without validation, allowing it to be used as both a property key (req.query[checkType]) and asvalueTypeforfindByEmailOrUsername. This vulnerability could lead to prototype pollution attacks if malicious values likecheck_type=__proto__orcheck_type=constructorwere sent, potentially causing unexpected behavior or security issues.Changes:
Added input validation for
check_type:['email', 'username']check_typeis exactly one of the allowed values before processingcheckTypeas a property keyAdded value validation:
emailorusername) exists in the querySecurity improvements:
as constfor type safetyFiles changed:
server/controllers/user.controller/signup.ts: Added validation logic toduplicateUserCheckfunctionI have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #3906