fix: Mitigate Reflected XSS in HTML routes#16
Open
LSUDOKO wants to merge 1 commit intoc2siorg:mainfrom
Open
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.
Fix: Reflected Cross-Site Scripting (XSS) in HTML Routes
Description
This Pull Request mitigates a Reflected Cross-Site Scripting (XSS) vulnerability in the HTML routes of
lensmint-public-server.Previously, the
claim_idparameter was injected directly into 404 error pages and other HTML templates without sanitization.An attacker could craft a malicious URL containing a
<script>tag that would execute in the victim's browser.Changes Made
1. Added
escapeHtmlUtilityImplemented a robust HTML escaping function in
server.jsto sanitize user-controlled input before rendering it inside HTML.2. Sanitized Routes
Applied context-aware sanitization to all instances where
claim_idis rendered in HTML, including:/verify/:claim_id→ 404 page/verify/:claim_id→ subtitle and buttons/claim/:claim_id→ 404 pageProof of Fix
Before the fix, certain characters could be used to inject HTML/JS.
After applying the
escapeHtmlfunction, they are properly converted into safe HTML entities.XSS Test Request
curl -s "http://localhost:5005/verify/test%27xss%22"Sanitized Response (Safe)
Characters such as
<and>are also escaped if they reach the handler.While browsers or the server routing layer may block some payloads, the
escapeHtmlfunction ensures consistent protection regardless of the delivery method.fixes #12