window.parent.postMessage()で情報漏洩 (Information Disclosure via window.parent.postMessage())

4 years ago 525
BOOK THIS SPACE FOR AD
ARTICLE AD

window.parent.postMessage()で情報漏洩 (Information Disclosure via window.parent.postMessage())

Image for post

Image for post

例 (For example)

https://jsfiddle.net/raijp/2je6sbqc/2/ に遷移してdeveloper toolsのconsoleで次のコードを実行してください。実行後に個人情報を取得できるでしょう。単に子フレームから親フレームに送信しているだけですが…
Navigate to https://jsfiddle.net/raijp/2je6sbqc/2/ and
execute the following code on the console in developer tools and then you will get victim’s personal information. Well, just it is sent from the parent frame to child frame.

window.addEventListener("message", (event) => {console.log(event.data)}, false);

結果画像 (This image is the result)

Image for post

Image for post

どのように使われる? (How to be used?)

この記事のように子フレーム内のwindow.parent.postMessage()に何か脆弱性がある場合、上記のようなコードをインジェクションすることで被害者の個人情報を取得できる可能性があります。また、window.parent.postMessage()の第2引数に*を設定しているページであれば、攻撃者はそのページを攻撃者のページに埋め込むことで被害者の個人情報を取得できる可能性があります。
If a child frame has something vulnerability in window.parent.postMessage() like this article, attackers will be got victim's personal information by injecting like above code or if a page that is using window.parent.postMessage() with the 2nd argument is *, attackers can be possible to get victim's personal information by embedding the page to attacker's page.

window.parent.postMessage()について (About window.parent.postMessage())

window.parent.postMessage()の第2引数が*の場合、オリジンのURLを検証せずに全ての親フレームに第1引数を送信します。
window.parent.postMessage()の第2引数が例えば https://example.com のようなURLの場合、 Originがhttps://example.comを含む親フレームのみに第1引数は送信されます。
つまり、window.parent.postMessage()の第2引数が*の場合は少し危険です。
If the 2nd argument of window.parent.postMessage() is *, the 1st argument is sent to all parent frame without validating origin URL.
If the 2nd argument of window.parent.postMessage() is URL such as https://example.com, 1st argument is sent to only parent frame that the origin is including https://example.com.
So, if the 2nd argument of window.parent.postMessage() is *, it is danger little bit.

Read Entire Article