> 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/web-cache-deception/cheating-the-cache-by-manipulating-paths.md).

# Tromper le cache en manipulant les chemins

### Exploitation du mappage de chemin pour la tromperie du cache web

#### Objectif du laboratoire

Récupérer la \*\*clé API\*\* de l'utilisateur **carlos**. / Identifiants fournis : **wiener:peter**.

#### Observations

* Dans **Mon compte** (my-account), la \*\*clé API\*\* apparaît **en clair** pour notre propre utilisateur.

<figure><img src="/files/02f88b0c93ba4c1a75a543de3e762906e0d39c7d" alt=""><figcaption></figcaption></figure>

* Initialement, il n'y a aucune indication directe (dans la réponse) qu'il y ait **mise en cache**.

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

* Cependant, en ajoutant des segments à l'URL, l'application continue d'afficher la **my-account** page, ce qui suggère un **logique de mappage des routes** potentiellement compatible avec le cache.

Exemples testés :

* `/my-account/TESTTTTTT` → L'application le traite toujours comme **my-account**

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

* `/my-account/TESTTT.js` → extension **.js** est accepté et interprété (utile pour tromper les règles de cache)

<figure><img src="/files/33db2660203a36f1392764bb87583dde5b7ffb5e" alt=""><figcaption></figcaption></figure>

Depuis le**Serveur d’exploitation**, forcez une victime à charger une URL de type « statique » pointant vers my-account :

{% code overflow="wrap" %}

```javascript
<script>
    document.location="https://0afd005204a0683b803d1ce200320070.web-security-academy.net/my-account/jordan.js";
</script>
```

{% endcode %}

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

1. En visitant :

* `/my-account/jordan.js`/ on obtient une réponse qui affiche la \*\*clé API de Carlos\*\*.

#### Résultat

La clé API de **carlos** est affichée via une URL déguisée (avec `.js` extension) qui vous permet de tirer parti du comportement de cache/routage (`/my-account/<quelque_chose>.js`).

<figure><img src="/files/38807872f5329c78158ba08cfd3b4efd99119a33" 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/web-cache-deception/cheating-the-cache-by-manipulating-paths.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.
