fix: render user-controlled names via textContent instead of innerHTM…#251
Open
Tamcodes4 wants to merge 1 commit into
Open
fix: render user-controlled names via textContent instead of innerHTM…#251Tamcodes4 wants to merge 1 commit into
Tamcodes4 wants to merge 1 commit into
Conversation
Contributor
|
Thank you for submitting a pull request. Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully. Formatting and Branching
|
Contributor
Author
|
Hey @jagdish-15, kindly review this pr.. |
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
This PR fixes a DOM-based XSS vulnerability caused by rendering user-controlled display names with
innerHTMLin the leaderboard.The vulnerable rendering paths have been replaced with safe DOM construction using
textContent,createTextNode, andcreateElement, preventing HTML or JavaScript supplied through user names from being interpreted by the browser.As a defense-in-depth measure, a
maxlength="100"attribute has also been added to the Full Name field on the registration form.Linked Issue
Fixes #237
Changes Made
innerHTMLinterpolation in the floating compare bar with safe DOM node construction.createElementandtextContentinstead of generating HTML strings.DocumentFragment.maxlength="100"to the registration form's Full Name field as an additional client-side safeguard.Type of Change
Testing
Manual verification
Verified locally using HTML/JavaScript payloads such as:
<img src=x onerror=alert("XSS")><script>alert("XSS")</script><b>Bold User</b>Confirmed that these payloads are rendered as plain text (not interpreted as HTML) in:
No JavaScript execution or alert dialogs occurred.
Checklist
npx prettier --write .before submittingfeature/*branch, not themainbranchScreenshots
Not applicable.