Created
November 10, 2022 13:03
-
-
Save PinkDraconian/75c63905c27cd8eabecfe3a609e3aa88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<title>Login Frame</title> | |
<script type="text/JavaScript"> | |
const allowed = [ | |
window.location.host, "localhost" | |
]; | |
window.addEventListener('message', (event) => { | |
const anchor = document.createElement('a'); | |
anchor.href = event.data.domain; | |
const isAllowed = allowed.filter(d => { | |
return d === anchor.host | |
}).length > 0; | |
if (isAllowed) { | |
const data = { | |
token: localStorage.getItem('accessToken') | |
}; | |
window.parent.postMessage( | |
data, event.data.domain | |
); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
an attacker can append his domain address to allowed list.
Then send a window.postMessage() from his domain address