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

# Empoisonnement du cache web via une requête GET volumineuse

### Empoisonnement du cache Web via une requête GET volumineuse

Ce laboratoire est vulnérable à l’empoisonnement du cache web car il accepte **des requêtes GET avec un corps**, mais **le corps n’est pas inclus dans la clé du cache**. / Un utilisateur visite régulièrement la page d’accueil du site avec Chrome. / L’objectif est d’empoisonner le cache afin que la réponse exécute `alert(1)` dans le navigateur de la victime.

**Analyse initiale**

En interceptant la requête vers la page d’accueil, nous observons la présence du cookie suivant

<pre class="language-http"><code class="lang-http"><strong>Cookie: country=[object Object]
</strong></code></pre>

Ce cookie est généré à partir du fichier JavaScript chargé par la page :

```bash
/js/geolocate.js
```

<figure><img src="/files/433c91f3bd6b032f0dd135bc23905773b5e8c4e8" alt=""><figcaption></figcaption></figure>

**Analyse de `geolocate.js`**

En accédant directement à ce qui suit :/ `/js/geolocate.js?callback=setCountryCookie`

Le code suivant est obtenu :

{% code overflow="wrap" %}

```javascript
const setCountryCookie = (country) => {
    document.cookie = 'country=' + country;
};
const setLangCookie = (lang) => {
    document.cookie = 'lang=' + lang;
};
setCountryCookie"({"country":"United Kingdom"});
```

{% endcode %}

Nous observons que :

* Le `callback` le paramètre est utilisé pour définir la fonction appelée.
* La valeur transmise est ensuite exécutée côté client.

**Exploitation de la vulnérabilité**

Lors du chargement de la page d’accueil, le site appelle automatiquement :/ `/js/geolocate.js?callback=setCountryCookie`

En exploitant le fait que :

* Le serveur accepte des requêtes GET avec un corps.
* Le corps n’est pas inclus dans la clé du cache.

```bash
callback=alert(1)
```

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

Nous imposons un **nouveau paramètre `callback`** dans le corps de la requête GET, en lui donnant la valeur suivante :

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

La réponse mise en cache contient maintenant l’appel à `alert(1)`.

<figure><img src="/files/8f7d96d1d77223463d403a06fa0e4491e8262f4f" 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/fr/web/cache-poisoning/web-cache-poisoning-via-fat-get-request.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.
