> 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/de/web/cache-poisoning/web-cache-poisoning-with-unkeyed-cookie.md).

# Cache-Vergiftung mit einem unkeyed Cookie

### Web-Cache-Poisoning mit einem nicht im Cache-Schlüssel berücksichtigten Cookie

Dieses Labor ist anfällig für Web-Cache-Poisoning, da Cookies nicht in den Cache-Schlüssel einbezogen werden. Ein legitimer Nutzer besucht regelmäßig die Startseite. / Das Ziel ist es, den Cache mit einer Antwort zu vergiften, die ausführt `alert(1)` im Browser des Opfers ausführt.

#### Analyse der Antwort

* Die Anfrage wird zum Root-Pfad (`/`).
* In der HTML-Antwort beobachten wir ein JavaScript-Skript mit dynamischen Daten:

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

* Das `frontend` Feld ist der Wert eines vom Browser gesendeten Cookies

#### Cookie-Beobachtung

* In der Anfrage befindet sich ein Cookie namens `fehost` ist vorhanden:

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

* Dieser Wert wird direkt in der Antwort wiederverwendet, ohne in den Cache-Schlüssel integriert zu werden.

<figure><img src="/files/838959eda8849733919b84a0c97de5b3964c5d14" alt=""><figcaption></figcaption></figure>

#### Cookie-Manipulation

* Durch Ändern des Werts des `fehost` Cookies spiegelt die Antwort den neuen Wert sofort wider:

```bash
fehost=test
```

* Dies bestätigt, dass der Cookie **nicht im Cache indiziert ist** und dass er den zwischengespeicherten Inhalt beeinflusst.

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

#### Payload-Injektion

* Anschließend wird ein bösartiger Wert in das Cookie injiziert, um den JavaScript-Kontext zu durchbrechen und beliebigen Code auszuführen:

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

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

* Payload entkommt aus dem JavaScript-String und injiziert einen Aufruf von `alert(1)`.

<figure><img src="/files/574c12e906a9097f75d0ef6a1ea9b7a752d8ee15" 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/de/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.
