> 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-via-fat-get-request.md).

# Web-Cache-Vergiftung über eine aufgeblähte GET-Anfrage

### Web-Cache-Poisoning über eine GET-Anfrage mit Body

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

**Erste Analyse**

Durch das Abfangen der Anfrage an die Startseite beobachten wir das Vorhandensein des folgenden Cookies

<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`**

Durch direkten Zugriff auf Folgendes\:/ `/js/geolocate.js?callback=setCountryCookie`

Der folgende 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 `callback` der Parameter verwendet wird, um die aufgerufene Funktion festzulegen.
* Der übergebene Wert wird dann auf der Client-Seite ausgeführt.

**Ausnutzung der Schwachstelle**

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

Indem wir die Tatsache ausnutzen, dass:

* Der Server akzeptiert GET-Anfragen mit einem Body.
* der Body nicht im Cache-Schlüssel enthalten ist.

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

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

Wir erzwingen einen **neuen Parameter `callback`** 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/web-cache-poisoning-via-fat-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.
