hermes-control-interface icon indicating copy to clipboard operation
hermes-control-interface copied to clipboard

[BUG] XSS via escapeHtml Function

Open stamandster opened this issue 7 months ago • 1 comments

Vulnerability Description The escapeHtml() function used for sanitizing user input before rendering did not escape quote characters, allowing attribute-based XSS attacks.

Affected Code Location
server.js — the escapeHtml() utility function

Risk Assessment
- Severity: High
- Impact: Injection of malicious scripts into HTML pages viewed by other users

Original Vulnerable Code
javascript
function escapeHtml(str) {
  return String(str)
    .replace(/&/g, '&')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    // Missing quote escaping!
    ;
}


Fix Applied (v3.3.0)
Added quote escaping to prevent attribute injection:
javascript
function escapeHtml(str) {
  return String(str)
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;')
    .replace(/'/g, '&#39;')
    ;
}

stamandster avatar Apr 23 '26 14:04 stamandster

✅ RESOLVED in v3.5.0

Fix applied: All 15+ error handler locations where e.message/err.message was rendered with innerHTML without escaping have been wrapped with escapeHtml().

Commit: 0da4883

This was part of the XSS hardening sprint alongside dead code removal (D1+D2). All error displays throughout the admin UI now properly escape HTML entities.

Release: https://github.com/xaspx/hermes-control-interface/releases/tag/v3.5.0

xaspx avatar Apr 27 '26 11:04 xaspx