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?

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

Posted at

DOM XSS using web messages

概要

location.hrefに代入する文字列でスクリプトを実行させる

攻撃手順

  • 開発ツールで、scriptタグが存在しているか確認し、存在していたらスクリプトの中身を確認
  • messageイベントリスナーが存在していることを確認
  • location.hrefにmessageで受け取ったデータを代入していることを確認
  • location.hrefに代入する文字列でスクリプトを実行させるため、javascript:alert(1)を指定
    • 画面のスクリプトは、http又はhttpsが含まれている場合にlocation.hrefに代入するため、末尾にコメントアウトでhttpを追加する(例://http)
    • alert(1)だけだと/alert(1)へ遷移させるため、存在しないページへ遷移するだけの挙動となってしまう。javascript:を付与することでブラウザがjavascript:スキームとして認識し、スクリプトを実行する

メモ

  • 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?