Exfiltrating Data from Sandboxed Documents
A custom JavaScript widget feature used postMessage without origin checks, allowing an attacker to send arbitrary JavaScript to a sandboxed iframe. The attacker could then use the message event's source property to exfiltrate data (such as credentials entered into a phishing page) back to their own domain, bypassing the sandbox's CSP.
This is a writeup of a vulnerability I found with doomerhunter, that allowed us to exfiltrate data from an extremely limited Javascript environment.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The postMessage listener lacked origin validation, allowing any origin to send messages containing arbitrary JavaScript to the sandboxed document.
Impact
An attacker could exfiltrate data from the sandboxed document, such as credentials entered into a phishing page, despite the sandbox and CSP restrictions.
What the attacker needed
Victim visits attacker's site; attacker can open the iframe page; victim interacts with phishing form
How it was found
- Open the iframed document in a new tab using window.open from the attacker's domain.
- Send a postMessage containing malicious JavaScript to the opened window.
- The malicious JavaScript sets up an event listener to capture the source property from a subsequent message.
- Send another postMessage with bogus data to store the WindowProxy reference.
- Use the stored WindowProxy to send exfiltrated data (e.g., credentials from a phishing form) back to the attacker's domain via postMessage.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A website let users add custom JavaScript that ran inside a restricted iframe. The page that received this code did not check who sent it, so an attacker could open that page and send their own malicious code. The attacker then used a built-in browser feature to send stolen data back to themselves, even though the iframe was supposed to be locked down.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.