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

# Contornando a validação por estado da conexão

Notas sobre contornando a validação por estado da conexão para os laboratórios do PortSwigger Web Security Academy, incluindo fluxo de exploração, teste de payload, validação no Burp Suite e contexto de remediação.

### Bypass da validação do host via ataque de estado da conexão

**Descrição da vulnerabilidade**

Este laboratório tem uma **vulnerabilidade do tipo SSRF baseada em roteamento via Host** cabeçalho, ligada ao gerenciamento inadequado do estado da conexão do lado do servidor.

Embora o servidor frontal pareça validar corretamente o `Host` cabeçalho, ele faz uma \*\*hipótese perigosa\*\*:

> Todas as solicitações enviadas na mesma conexão TCP são consideradas confiáveis se a **primeira solicitação** for válida.

Isso permite injetar uma solicitação maliciosa posterior na mesma conexão, contornando a validação inicial.

**Objetivo do laboratório**

* Acesse o painel de administração interno:/ `HTTP://192.168.0.1/admin`
* Excluir usuário **carlos**

**Observação inicial**

Uma solicitação direta para o IP interno é bloqueada:

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

O servidor rejeita esta solicitação, o que confirma que há uma `Host` validação em vigor **na primeira solicitação**.

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

**Operação: ataque de estado da conexão**

A ideia é enviar \*\* várias solicitações na mesma conexão TCP\*\*:

1. Uma primeira solicitação legítima para o host público (aceita).
2. Uma segunda solicitação maliciosa para o IP interno, enviada **na mesma conexão**.

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

No Burp Suite, isso é feito por:

* Agrupando solicitações
* Usando **Enviar grupo em uma única conexão**

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

**Acesso ao painel de administração**

Assim que a conexão é estabelecida com uma consulta válida, a solicitação seguinte ao admin interno é aceita:

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

O painel de administração interno então se torna acessível.

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

**Exclusão do usuário**

Remover o usuário requer uma consulta POST:

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

csrf=ppBVKn8wVrgZifEETHsn48Hykwiq8yFO&username=carlos
```

Resposta do servidor:

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