Skip to content

fix: Mitigate Reflected XSS in HTML routes#16

Open
LSUDOKO wants to merge 1 commit intoc2siorg:mainfrom
LSUDOKO:fix/xss-html-routes
Open

fix: Mitigate Reflected XSS in HTML routes#16
LSUDOKO wants to merge 1 commit intoc2siorg:mainfrom
LSUDOKO:fix/xss-html-routes

Conversation

@LSUDOKO
Copy link
Copy Markdown

@LSUDOKO LSUDOKO commented Mar 15, 2026

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_id parameter 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 escapeHtml Utility

Implemented a robust HTML escaping function in server.js to sanitize user-controlled input before rendering it inside HTML.

2. Sanitized Routes

Applied context-aware sanitization to all instances where claim_id is rendered in HTML, including:

  • /verify/:claim_id → 404 page
  • /verify/:claim_id → subtitle and buttons
  • /claim/:claim_id → 404 page
  • Footer links
  • Client-side script templates

Proof of Fix

Before the fix, certain characters could be used to inject HTML/JS.
After applying the escapeHtml function, they are properly converted into safe HTML entities.

XSS Test Request

curl -s "http://localhost:5005/verify/test%27xss%22"

Sanitized Response (Safe)

image

Characters such as < and > are also escaped if they reach the handler.
While browsers or the server routing layer may block some payloads, the escapeHtml function ensures consistent protection regardless of the delivery method.

fixes #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reflected Cross-Site Scripting (XSS) in HTML Routes

1 participant