fix(explorer): render dynamic HTML safely via DOM APIs (#7699)#7783
Conversation
FakerHideInBush
left a comment
There was a problem hiding this comment.
One concern before merging:
buildRow() still accepts {html: '...'} objects and passes them directly to td.innerHTML — the XSS escape hatch remains and the fix is incomplete for the multiplier cell
The new helper:
if (c && c.html) {
td.innerHTML = c.html;
}And the call site:
{html: '<span class="multiplier">x' + esc(miner.antiquity_multiplier || miner.multiplier || '1.0') + '</span>'},The multiplier value goes through esc() here, so this specific call is safe. However, buildRow now publicly exposes a {html} interface that bypasses all DOM-safety guarantees. Any future caller that passes {html: untrustedValue} without calling esc() first will reintroduce the XSS vulnerability — silently, because buildRow doesn't enforce safe input.
The multiplier cell can be rendered safely using the existing wrap() helper without touching innerHTML at all:
wrap('span', 'multiplier', 'x' + String(
miner.antiquity_multiplier || miner.multiplier || '1.0')),Please:
- Replace the
{html: ...}call for the multiplier cell with thewrap()approach above. - Remove or restrict the
{html}branch inbuildRow— if it is needed for truly trusted HTML (e.g. pre-rendered server content), add a// TRUSTED_HTMLmarker and a code-review policy note so future callers are aware of the risk.
6e59bd2 to
a56bf8d
Compare
jaxint
left a comment
There was a problem hiding this comment.
Review Summary
This PR fixes dynamic HTML rendering safety.
Changes:
- Uses DOM APIs for safe dynamic HTML rendering
- Prevents XSS vulnerabilities
Security Impact:
- Proper DOM-based rendering instead of string concatenation
- Safe handling of dynamic content
✅ APPROVED
RTC RewardThis merged PR earned 5 RTC — sent to |
Closes #7699
RTC wallet: RTCfe13452d122263caf633ab1876bd9631133b68b
Changes
innerHTMLtemplate literal assignments with safe DOM construction (createElement,textContent,appendChild) inexplorer/enhanced-explorer.htmlbuildRow(),txt(), andwrap()helper functions for safe DOM element creationtextContentto prevent DOM injectionTesting