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

# Engañar a la caché manipulando rutas

### Explotando el mapeo de rutas para el engaño de caché web

#### Objetivo del laboratorio

Recuperar la \*\*clave API\*\* del usuario **carlos**. / Credenciales proporcionadas: **wiener:peter**.

#### Observaciones

* En **Mi cuenta** (my-account), aparece la \*\*clave API\*\* **en texto plano** para nuestro propio usuario.

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

* Inicialmente, no hay una indicación directa (en la respuesta) de que haya **caché**.

<figure><img src="/files/88391f16a6b9c092277cfec73290dd2d4551cade" alt=""><figcaption></figcaption></figure>

* Sin embargo, al añadir segmentos a la URL, la aplicación sigue mostrando la **my-account** página, lo que sugiere una **lógica de mapeo de rutas** potencialmente compatible con la caché.

Ejemplos probados:

* `/my-account/TESTTTTTT` → La aplicación siempre trata esto como **my-account**

<figure><img src="/files/42eedd8fc0056426c62df3dde90f50563060c3a0" alt=""><figcaption></figcaption></figure>

* `/my-account/TESTTT.js` → extensión **.js** se acepta e interpreta (útil para engañar las reglas de caché)

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

Desde el**servidor de explotación**, obliga a una víctima a cargar una URL del tipo "static" que apunta a 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/9e54019a1c619e3b0a40b3f445234aea50f89e42" alt=""><figcaption></figcaption></figure>

1. Al visitar:

* `/my-account/jordan.js`/ se obtiene una respuesta que muestra la \*\*clave API de carlos\*\*.

#### Resultado

La clave API de **carlos** se muestra a través de una URL camuflada (con `.js` extensión), lo que permite aprovechar el comportamiento de caché/enrutamiento (`/my-account/<algo>.js`).

<figure><img src="/files/5f28aa909bdbc7d69496b822a830b8e044f6674d" 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/es/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.
