> 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/bypassing-validation-by-connection-state.md).

# 接続状態による検証のバイパス

接続状態による検証のバイパスの PortSwigger Web Security Academy ラボ向けノート。攻撃フロー、ペイロードテスト、Burp Suite による検証、および是正策の文脈を含みます。

### 接続状態攻撃によるホスト検証のバイパス

**脆弱性の説明**

このラボには **Host 経由のルーティングに基づくSSRF型の脆弱性が** あり、サーバー側接続の状態管理が不十分なことに関連しています。

フロントサーバーは適切に `Host` ヘッダーを検証しているように見えますが、危険な\*\*仮定\*\*をしています:

> 同じTCP接続で送信されたすべてのリクエストは、 **最初のリクエスト** が有効であれば信頼できると見なされます。

これにより、後続の悪意あるリクエストを同じ接続上に挿入し、最初の検証をバイパスできます。

**ラボの目的**

* 内部管理パネルにアクセスする: / `HTTP://192.168.0.1/admin`
* ユーザーを削除 **carlos**

**初期観察**

内部IPへの直接リクエストはブロックされます:

```http
GET / HTTP/1.1
Host: 192.168.0.1
```

サーバーはこのリクエストを拒否します。これは `Host` 検証が行われている **ことを最初のリクエストで**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-716cd678495ba9f257aeef4663599d1781bb752d%2F%7B66EAD875-C290-48AB-86B2-6054CF9ECE86%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**操作: 接続状態攻撃**

考え方は、\*\*同じTCP接続で複数のリクエストを送信する\*\*ことです:

1. 公開ホストへの正当な最初のリクエスト（受理される）。
2. 内部IPへの2つ目の悪意あるリクエストを **同じ接続上で送信する。**.

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c156f1764638d2ba4d002f1dd9ec42c8cc7b1aed%2F%7B7C1D0937-5E3E-4E83-8F29-42F59338EF12%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Burp Suite では、これは次のように行います:

* リクエストをグループ化する
* を使用する **Send group in single connection**

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-00d3a64b47a7ce1463445cb3ee7908241bb2af19%2F%7BE961F29C-9FAA-4C08-A8CE-75A3D270193E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**管理パネルへのアクセス**

有効なクエリで接続が確立されると、内部管理者宛ての次のリクエストは受理されます:

```http
GET /admin HTTP/1.1
Host: 192.168.0.1
```

その後、内部管理パネルにアクセス可能になります。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-62e690af215289aa04969d98c4420d8f1d2616fa%2F%7BC76FC4FB-52F9-4BFD-B3F9-CE9040DB5411%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**ユーザーの削除**

ユーザーを削除するにはPOSTクエリが必要です:

```http
POST /admin/delete HTTP/1.1
Host: 192.168.0.1

csrf=ppBVKn8wVrgZifEETHsn48Hykwiq8yFO&username=carlos
```

サーバー応答:

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-586b97aeff5349a4a728d8a02e94a919b03e31eb%2F%7B2A1D959A-10BF-4B0A-A3FF-6907C0A91CD6%7D.png?alt=media" alt="" width="446"><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/bypassing-validation-by-connection-state.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.
