> 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, не учитываемым в ключе

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

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

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

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

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

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

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

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

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

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

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

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

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

```bash
fehost=test
```

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

<figure><img src="/files/34b0cd5b271ba50065154f23e3b6da41d898d371" alt=""><figcaption></figcaption></figure>

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

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

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

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

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

<figure><img src="/files/079afdddcdc5d502c6114e0a1bff33ec3f22f74f" 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-with-unkeyed-cookie.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.
