Exploiting xdLocalStorage (localStorage and postMessage)
The xdLocalStorage library failed to validate the origin of incoming postMessage events and used a wildcard targetOrigin when sending them, so a malicious site could read and manipulate the cross-domain local storage data of a victim. An attacker could therefore obtain sensitive values stored by the library or inject data the client page would trust.
grimhacker.com
Published on grimhacker.com
Published by GrimHacker on 2 April 2020
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 library's message handlers did not verify the sender's origin, and outgoing messages were sent with a wildcard targetOrigin so any origin could receive them.
Impact
A malicious site could read and manipulate the cross-domain local storage data held by the library, potentially exposing sensitive information stored there.
What the attacker needed
Victim visits attacker-controlled page; target site uses xdLocalStorage
The fix
The library should validate the origin of every received message and specify an exact targetOrigin when sending messages.
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.
Websites can talk to each other inside a browser using a messaging feature called postMessage. Each message carries a label saying which site sent it, and the receiving site is supposed to check that label before trusting the message. This library never checked the label, so any website could send it messages and read or change the stored data.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.