> 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/cache-poisoning-via-abnormal-get-request.md).

# Cache-Vergiftung über eine ungewöhnliche GET-Anfrage

### Web-Cache-Poisoning über eine fette GET-Anfrage

Dieses Labor ist anfällig für die Vergiftung des Web-Caches, weil es **GET-Anfragen mit einem Body**, aber **der Body nicht im Cache-Key enthalten ist**. / Ein Benutzer besucht regelmäßig die Startseite der Website mit Chrome. / Das Ziel ist es, den Cache zu vergiften, sodass die Antwort `alert(1)` im Browser des Opfers ausführt.

**Erste Analyse**

Durch das Abfangen der Anfrage an die Startseite stellen wir die Existenz des folgenden Cookies fest

<pre class="language-http"><code class="lang-http"><strong>Cookie: country=[object Object]
</strong></code></pre>

Dieses Cookie wird aus der von der Seite geladenen JavaScript-Datei generiert:

```bash
/js/geolocate.js
```

<figure><img src="/files/8efe666b87fa6ea22e435d9cc79d282efb5f8455" alt=""><figcaption></figcaption></figure>

**Analyse von `geolocate.js`**

Direktes Aufrufen des Folgenden:/ `/js/geolocate.js?callback=setCountryCookie`

Folgender Code wird erhalten:

{% code overflow="wrap" %}

```javascript
const setCountryCookie = (country) => {
    document.cookie = 'country=' + country;
};
const setLangCookie = (lang) => {
    document.cookie = 'lang=' + lang;
};
setCountryCookie"({"country":"United Kingdom"});
```

{% endcode %}

Wir beobachten, dass:

* Das `Rückruffunktion` Parameter wird verwendet, um die aufgerufene Funktion zu definieren.
* Der übergebene Wert wird dann clientseitig ausgeführt.

**Ausnutzung der Schwachstelle**

Beim Laden der Startseite ruft die Website automatisch Folgendes auf:/ `/js/geolocate.js?callback=setCountryCookie`

Durch Ausnutzen der Tatsache, dass:

* Der Server akzeptiert GET-Anfragen mit einem Body.
* Der Body nicht im Cache-Key enthalten ist.

```bash
callback=alert(1)
```

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

Wir erzwingen einen **neuen Parameter `Rückruffunktion`** im Body der GET-Anfrage und geben ihm den folgenden Wert:

<figure><img src="/files/127cb4fe28c6ee0ef82c440780882cad30b28794" alt=""><figcaption></figcaption></figure>

Die zwischengespeicherte Antwort enthält nun den Aufruf von `alert(1)`.

<figure><img src="/files/b4be1a60b23d47e9bfba6ec931c9cb773d1564ad" 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/cache-poisoning-via-abnormal-get-request.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.
