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

# Empoisonnement du cache via une requête GET anormale

Notes sur l’empoisonnement du cache via une requête GET anormale pour les laboratoires de la PortSwigger Web Security Academy, incluant le workflow d’exploitation, les tests de payloads, la validation dans Burp Suite et le contexte de remédiation.

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

Ce labo est vulnérable à l’empoisonnement du cache Web car il accepte **les 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="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bcbcc640c394fc2384de02c4fafc06bd30b9a89c%2F%7B37A0209B-9D6E-4FEF-BB1E-9D33093BCC00%7D.png?alt=media" 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` paramètre est utilisé pour définir la fonction appelée.
* La valeur passée 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 les requêtes GET avec un corps.
* Le corps n’est pas inclus dans la clé du cache.

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-56639cede1e2e7bc9edfb73ce61e8091963542f3%2F%7B772A3B06-9123-4953-BACB-06F8D08DABA6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2a056eac2d9d299e2e421dacd7ec919b83555923%2F%7BE92EC295-36D2-427D-8221-3BCC26B2A8BF%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0119b983ee06443632e146dfe72d0ee5e7c3bbdf%2F%7B234018E6-2202-4AE5-8C2D-E76CAC9D34C2%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/fr/web/cache-poisoning/cache-poisoning-via-abnormal-get-request.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
