DOM-XSS via postMessage API

Vulnerable Receiver Example

  • Listens for messages with addEventListener('message')

  • Updates the paragraph content with the message without sanitization

Messages identification

  • Hook messages in your web application copying the following JS code in your Browser console:

  • Analyze the postMessage IN messages identified by the previous Javascript code to understand which data are processed by the Web page listener

Exploitation

  • Create the attacker web page with the XSS in the message of sent using the postMessage function. To do it, open the target URL and perform postMessage with 5 seconds delay, to be sure that the web application loads completely and starts all the workers

  • The user visits the attacker web page and the target site will be opened by the script, allowing the execution of the DOM XSS

Last updated