> 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/web-cache-poisoning-with-unkeyed-cookie.md).

# キーに含まれないCookieによるキャッシュ・ポイズニング

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

### キー化されていない Cookie を用いた Web キャッシュ汚染

このラボは、Cookie がキャッシュキーに含まれていないため、Web キャッシュ汚染の脆弱性があります。正当なユーザーが定期的にホームページを訪れます。/ 目的は、実行するレスポンスでキャッシュを汚染することです `alert(1)` 被害者のブラウザ上で。

#### レスポンスの解析

* リクエストはルート（`/`).
* HTML レスポンス内で、動的データを含む JavaScript スクリプトが確認できます：

```javascript
<script>
  data = {
    "host":"0ab5006d03269ea785b94a9e000100c5.web-security-academy.net",
    "path":"/",
    "frontend":"prod-cache-01"
  }
</script>
```

* その `フロントエンド` フィールドは、ブラウザから送信された Cookie の値です

#### Cookie の観察

* クエリには、という名前の Cookie が `fehost` 含まれています:

```bash
fehost=prod-cache-01
```

* この値はキャッシュキーに組み込まれず、そのままレスポンスで再利用されます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f606d58cda0aa54d4e7fa2704161bde87fe5b28%2F%7B07D90C20-F8F7-4821-95C8-7142DBB12738%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Cookie の操作

* の値を変更することで `fehost` Cookie、応答にはすぐに新しい値が反映されます:

```bash
fehost=test
```

* これにより、Cookie が **キャッシュにインデックスされていない** こと、およびそれがキャッシュ済みコンテンツに影響していることが確認できます。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-60368e8982e1dd4fc8a3397f98ca295198775827%2F%7BBEF704EB-BEDE-42C4-8612-2C71E2DE82A2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### ペイロードの注入

* その後、JavaScript コンテキストを壊して任意コードを実行するために、悪意のある値が Cookie に注入されます:

```javascript
test"-alert(1)-"efffe
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df219aad398446f4943e7420b19e191dcb61332c%2F%7B27D4A359-AE55-4B4A-A5F7-7DF4E04072BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* ペイロードは JavaScript 文字列から脱出し、呼び出しを注入します `alert(1)`.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-459468743afcc41527fbfc36e6fb0035c31bce09%2F%7BFC59DDFE-FF56-4E6A-AD69-C21EFF02B573%7D.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/cache-poisoning/web-cache-poisoning-with-unkeyed-cookie.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.
