> 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 dans la clé

### Empoisonnement du cache web avec un cookie non utilisé dans la clé

Ce laboratoire est vulnérable à l’empoisonnement du cache web, car les cookies ne sont pas inclus dans la clé de cache. Un utilisateur légitime visite régulièrement la page d’accueil. / L’objectif 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 à 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` 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é de cache.

<figure><img src="/files/c30612902a5ae980546ba6cca514a8fec30dd195" 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 n’est **pas indexé dans le cache** et qu’il influence le contenu mis en cache.

<figure><img src="/files/1fd98e0c595a4e5de20be3d6776fbb0a1e1d7d01" alt=""><figcaption></figcaption></figure>

#### Injection de charge utile

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

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

<figure><img src="/files/6d1687aad5f8ce596429f2da7506047315627155" alt=""><figcaption></figcaption></figure>

* La charge utile s’échappe de la chaîne JavaScript et injecte un appel à `alert(1)`.

<figure><img src="/files/83cc67c6648b017bd710f919078d926c7495856c" 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-with-unkeyed-cookie.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.
