Security: Escape HTML in testcase event history to prevent stored XSS#5306
Security: Escape HTML in testcase event history to prevent stored XSS#5306Ashutosh0x wants to merge 1 commit into
Conversation
The _formatEvent() method in testcase-event-history.html interpolates event data (including user-controlled fields like fuzzer name) into HTML strings assigned via inner-h-t-m-l without escaping. An attacker with testcase upload permissions can inject arbitrary HTML/JavaScript via the fuzzer name field, which executes when any user views the testcase detail page. Add _escapeHtml() helper to escape &, <, >, quote, and apostrophe characters before interpolating event keys and JSON-stringified values into the HTML string. Fixes google#5257
|
This PR fixes the stored XSS vulnerability reported in #5257. The fix adds HTML entity escaping to the The patch is minimal (14 lines added, 3 changed) and follows the exact approach suggested in the issue report. Happy to address any feedback! |
|
Hi @jonathanmetzman — this fixes a stored XSS in the testcase event history view (issue #5257). The The fix adds an |
Summary
Fix stored XSS vulnerability in the testcase event history component where attacker-controlled event data (e.g., fuzzer name from testcase uploads) is rendered as HTML without escaping.
Problem
The
_formatEvent()method intestcase-event-history.htmlconstructs an HTML string from event data and assigns it via Polymer'sinner-h-t-m-lbinding. WhileJSON.stringify()is called on values, the resulting string still contains raw<and>characters that are parsed as HTML when assigned throughinner-h-t-m-l.Attack vector: A user with testcase upload permissions injects a payload like
<img src=x onerror='...'>in thefuzzerform field. This value flows through:testcase.fuzzer_name(stored in datastore)BaseTestcaseEvent.__post_init__()→event.fuzzer(copied from testcase)_format_event_for_history()→ event dict (returned to frontend)_formatEvent()→ HTML string (rendered viainner-h-t-m-l)When any user views the testcase detail page, the stored payload executes in their browser session, enabling cross-user data theft.
Fix
Add an
_escapeHtml()helper that replaces&,<,>,", and'with their HTML entity equivalents. Both event keys and JSON-stringified values are escaped before interpolation into the HTML string.Impact
A limited ClusterFuzz user who can upload testcases can execute arbitrary JavaScript in the browser session of any user (including admins) who views the uploaded testcase's detail page. The demonstrated impact includes reading data from other testcases that the attacker cannot directly access.
Fixes #5257