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

# Bypassing Validation by Connection State

Bypassing Validation by Connection State notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Host Validation Bypass via Connection State Attack

**Description of vulnerability**

This lab has a **SSRF-type vulnerability based on routing via Host** header, linked to poor status management of the server-side connection.

Although the front server seems to properly validate the `Host` header, it makes a dangerous \*\* hypothesis\*\*:

> All requests sent on the same TCP connection are considered reliable if the **first request** is valid.

This allows to inject a later malicious request on the same connection, bypassing the initial validation.

**Lab objective**

* Access the internal administration panel:/ `HTTP://192.168.0.1/admin`
* Delete user **carlos**

**Observation initiale**

A direct request to internal IP is blocked:

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

The server rejects this request, which confirms that a `Host` validation is in place **at the first request**.

<figure><img src="https://131707722-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>

**Operation: connection state attack**

The idea is to send \*\* several requests on the same TCP connection\*\*:

1. A legitimate first request to the public host (accepted).
2. A second malicious request to internal IP, sent **on the same connection**.

<figure><img src="https://131707722-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>

In Burp Suite, this is done by:

* Grouping requests
* Using **Send group in single connection**

<figure><img src="https://131707722-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>

**Access to the administration panel**

Once the connection is established with a valid query, the following request to the internal admin is accepted:

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

The internal administration panel then becomes accessible.

<figure><img src="https://131707722-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>

**Deletion of the user**

Removing the user requires a POST query:

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

csrf=ppBVKn8wVrgZifEETHsn48Hykwiq8yFO&username=carlos
```

Server response:

<figure><img src="https://131707722-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/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.
