> 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/cache-poisoning/web-cache-poisoning-via-fat-get-request.md).

# Отравление веб-кэша через толстый GET-запрос

### Отравление веб-кэша через «толстый» GET-запрос

Эта лаборатория уязвима к отравлению веб-кэша, потому что она принимает **GET-запросы с телом**, но **тело не включается в ключ кеша**. / Пользователь регулярно посещает главную страницу сайта в Chrome. / Цель — отравить кеш так, чтобы ответ выполнял `alert(1)` в браузере жертвы.

**Первичный анализ**

Перехватив запрос к главной странице, мы замечаем наличие следующего cookie

<pre class="language-http"><code class="lang-http"><strong>Cookie: country=[object Object]
</strong></code></pre>

Этот cookie генерируется из JavaScript-файла, загружаемого страницей:

```bash
/js/geolocate.js
```

<figure><img src="/files/25edf7ae9de2bca2f4d5e5f9d0f67aa8a18f4c93" alt=""><figcaption></figcaption></figure>

**Анализ `geolocate.js`**

Прямой доступ к следующему:/ `/js/geolocate.js?callback=setCountryCookie`

Получаем следующий код:

{% code overflow="wrap" %}

```javascript
const setCountryCookie = (country) => {
    document.cookie = 'country=' + country;
};
const setLangCookie = (lang) => {
    document.cookie = 'lang=' + lang;
};
setCountryCookie"({"country":"United Kingdom"});
```

{% endcode %}

Мы видим, что:

* У `параметр callback` используется для определения вызываемой функции.
* Затем переданное значение выполняется на стороне клиента.

**Эксплуатация уязвимости**

При загрузке главной страницы сайт автоматически вызывает:/ `/js/geolocate.js?callback=setCountryCookie`

Используя тот факт, что:

* Сервер принимает GET-запросы с телом.
* Тело не включается в ключ кеша.

```bash
callback=alert(1)
```

<figure><img src="/files/836980fa8bf7fa522b3f6d0e4986ecced2110c3d" alt=""><figcaption></figcaption></figure>

Мы заставляем **новый параметр `параметр callback`** в теле GET-запроса, задав ему следующее значение:

<figure><img src="/files/62a6c163e22e9d027c31c99ec3cf8ef85e6954a2" alt=""><figcaption></figcaption></figure>

Теперь кэшированный ответ содержит вызов `alert(1)`.

<figure><img src="/files/dacd00e125d8522618a4ed2a73b6ec6634756ec1" 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/cache-poisoning/web-cache-poisoning-via-fat-get-request.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.
