> 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-with-unkeyed-cookie.md).

# Отравление кэша через неучитываемый cookie

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

### Отравление веб-кэша с cookie, не входящей в ключ

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

#### Анализ ответа

* Запрос перехватывается к корню (`/`).
* В HTML-ответе мы замечаем JavaScript-скрипт, содержащий динамические данные:

```javascript
<script>
  data = {
    "host":"0ab5006d03269ea785b94a9e000100c5.web-security-academy.net",
    "path":"/",
    "frontend":"prod-cache-01"
  }
</script>
```

* Эта `фронтенд` поле является значением cookie, отправляемой браузером

#### Наблюдение за cookie

* В запросе присутствует cookie под названием `fehost` присутствует:

```bash
fehost=prod-cache-01
```

* Это значение используется повторно напрямую в ответе без включения в ключ кэша.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f606d58cda0aa54d4e7fa2704161bde87fe5b28%2F%7B07D90C20-F8F7-4821-95C8-7142DBB12738%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Манипуляция cookie

* Изменяя значение `fehost` cookie, ответ сразу отражает новое значение:

```bash
fehost=test
```

* Это подтверждает, что cookie **не индексируется в кэше** и что она влияет на кэшируемое содержимое.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-60368e8982e1dd4fc8a3397f98ca295198775827%2F%7BBEF704EB-BEDE-42C4-8612-2C71E2DE82A2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Внедрение полезной нагрузки

* Затем в cookie внедряется вредоносное значение, чтобы нарушить контекст JavaScript и выполнить произвольный код:

```javascript
test"-alert(1)-"efffe
```

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df219aad398446f4943e7420b19e191dcb61332c%2F%7B27D4A359-AE55-4B4A-A5F7-7DF4E04072BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Полезная нагрузка выходит из строки JavaScript и внедряет вызов `alert(1)`.

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-459468743afcc41527fbfc36e6fb0035c31bce09%2F%7BFC59DDFE-FF56-4E6A-AD69-C21EFF02B573%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/cache-poisoning/web-cache-poisoning-with-unkeyed-cookie.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.
