0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【24個目】【DOM XSS】DOM XSS using web messages

Last updated at Posted at 2025-11-06

DOM XSS using web messages

概要

iframeでスクリプトを埋め込む攻撃を実施

攻撃手順

  • 開発ツールで、scriptタグが存在しているか確認し、存在していたらスクリプトの中身を確認
  • messageイベントリスナーが存在していることを確認
  • エクスプロイトサーバで<iframe src="https://YOUR-LAB-ID.web-security-academy.net/" onload="this.contentWindow.postMessage('<img src=1 onerror=print()>','*')">を作成
  • 被害者がエクスプロイトサーバを訪問すると、iframeが読み込まれ、messageイベントが発火し、スクリプトが実行される
    • this.contentWindowでiframe中のwindowを指定
    • postMessageでiframe中のwindowにメッセージを送り、messageイベントを発火させる
    • messageイベントによって、指定されたスクリプトがiframe中のwindowで実行される

メモ

  • postMessageの第2引数は、メッセージを送信する相手のオリジンを指定する
    • *を指定すると、全てのオリジンにメッセージを送信できる
  • 通常、複数のページでのスクリプトは同一オリジンである場合にお互いにアクセスできる(同一オリジンポリシー)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?