Create sfsd.html#30
Conversation
⏭️ Hacktron Security Check — SkippedReason: PR review limit reached for this billing period. Spillover billing is available for this org but is not enabled.
|
There was a problem hiding this comment.
🔴 High: DOM-based Cross-Site Scripting (XSS) via insecure postMessage listener in sfsd.html
The sfsd.html file implements a window.addEventListener('message', ...) listener that fails to validate the event.origin of incoming messages. It then takes the event.data and directly assigns it to the innerHTML of the div#output element. This allows any malicious website to send a crafted postMessage to this page, leading to arbitrary JavaScript execution in the context of the page's origin. This is a clear DOM-based XSS vulnerability.
Steps to Reproduce
Fix with AI
Fix the following security vulnerability found by Hacktron.
File: sfsd.html
Severity: high
Vulnerability: DOM-based Cross-Site Scripting (XSS) via insecure postMessage listener in sfsd.html
Description:
The `sfsd.html` file implements a `window.addEventListener('message', ...)` listener that fails to validate the `event.origin` of incoming messages. It then takes the `event.data` and directly assigns it to the `innerHTML` of the `div#output` element. This allows any malicious website to send a crafted `postMessage` to this page, leading to arbitrary JavaScript execution in the context of the page's origin. This is a clear DOM-based XSS vulnerability.
Proof of Concept:
1. Open `sfsd.html` in a browser.
2. In the console of a different origin (e.g., `example.com`), execute:
window.opener.postMessage('<img src=x onerror=alert(document.domain)>', '*');
3. The alert will execute on the `sfsd.html` page.
Fix this vulnerability. Only change what's necessary - don't modify unrelated code.
Triage: Reply !fp <reason> (false positive), !valid (confirmed), or !accepted_risk <reason>. Reason is optional but improves future scans — e.g. !fp internal endpoint, not user-facing. Any other reply is saved as a triage note.
No description provided.