> 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-with-unkeyed-cookie.md).

# Empoisonnement du cache avec un cookie non pris en compte par la clé

Notes sur l’empoisonnement du cache avec un cookie non pris en compte par la clé 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 avec un cookie non pris en compte dans la clé

Ce labo est vulnérable à l’empoisonnement du cache Web, car les cookies ne sont pas inclus dans la clé du cache. Un utilisateur légitime visite régulièrement la page d’accueil. / Le but est d’empoisonner le cache avec une réponse qui exécute `alert(1)` dans le navigateur de la victime.

#### Analyse de la réponse

* La requête est interceptée vers la racine (`/`).
* Dans la réponse HTML, nous observons un script JavaScript contenant des données dynamiques :

```javascript
<script>
  data = {
    "host":"0ab5006d03269ea785b94a9e000100c5.web-security-academy.net",
    "path":"/",
    "frontend":"prod-cache-01"
  }
</script>
```

* Le `frontend` le champ est la valeur d’un cookie envoyé par le navigateur

#### Observation du cookie

* Dans la requête, un cookie nommé `fehost` est présent :

```bash
fehost=prod-cache-01
```

* Cette valeur est réutilisée directement dans la réponse sans être intégrée à la clé du cache.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f606d58cda0aa54d4e7fa2704161bde87fe5b28%2F%7B07D90C20-F8F7-4821-95C8-7142DBB12738%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Manipulation du cookie

* En modifiant la valeur du `fehost` cookie, la réponse reflète immédiatement la nouvelle valeur :

```bash
fehost=test
```

* Cela confirme que le cookie est **non indexé dans le cache** et qu’il influence le contenu mis en cache.

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-60368e8982e1dd4fc8a3397f98ca295198775827%2F%7BBEF704EB-BEDE-42C4-8612-2C71E2DE82A2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Injection de charge utile

* Une valeur malveillante est ensuite injectée dans le cookie pour rompre le contexte JavaScript et exécuter du code arbitraire :

```javascript
test"-alert(1)-"efffe
```

<figure><img src="https://3840167291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df219aad398446f4943e7420b19e191dcb61332c%2F%7B27D4A359-AE55-4B4A-A5F7-7DF4E04072BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Le payload s’échappe de la chaîne JavaScript et injecte un 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-459468743afcc41527fbfc36e6fb0035c31bce09%2F%7BFC59DDFE-FF56-4E6A-AD69-C21EFF02B573%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/web-cache-poisoning-with-unkeyed-cookie.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.
