fix(leaderboard): prevent stored XSS via unsanitized innerHTML on leaderboard page#73
Open
rishab11250 wants to merge 2 commits into
Open
fix(leaderboard): prevent stored XSS via unsanitized innerHTML on leaderboard page#73rishab11250 wants to merge 2 commits into
rishab11250 wants to merge 2 commits into
Conversation
Replace innerHTML with safe DOM methods (createTextNode + textContent) to prevent stored XSS via crafted username in the registration success flow. Also add prettier as devDependency for CI formatting compliance. Closes codepvg#57
Replace innerHTML with safe DOM methods (createElement + textContent + createTextNode) for all user-controlled data (user.name, user.id) in both desktop rows and mobile cards. Rank privilege tags ([ROOT]/[SUDO]/[EXEC]) use insertAdjacentHTML since they are hardcoded safe strings. Closes codepvg#58
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.
Description
Fix a stored XSS vulnerability on the leaderboard page. User-controlled
user.nameanduser.idfields from remote JSON were interpolateddirectly into
innerHTML, allowing arbitrary HTML/JavaScript executionin every visitor's browser.
Fixes #58
Changes Made
row.innerHTMLwith safe DOM methods(
createElement+textContent+createTextNode).leetcodeUrlvariable removed.[ROOT]/[SUDO]/[EXEC]) useinsertAdjacentHTMLsince they are hardcoded safe strings.
Type of Change
Testing
Checklist