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

# Engañar a la caché mediante normalización del lado del servidor de caché

Notas sobre Engañar a la caché mediante normalización del lado del servidor de caché para los laboratorios de PortSwigger Web Security Academy, incluyendo flujo de explotación, pruebas de payload, validación con Burp Suite y contexto de remediación

### Explotando la normalización del servidor de caché para el engaño de caché web

#### Objetivo del laboratorio

Recuperar la \*\*clave API\*\* del usuario **carlos** aprovechando una **comportamiento de normalización de URL** (diferencia de interpretación entre la aplicación y el servidor de caché). / Conexión disponible: **wiener:peter**.

#### Observación inicial

Probamos sufijos estáticos para activar una caché:

* Solicitud de prueba:

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

Hay diferentes respuestas según ciertos caracteres, y el servidor acepta:

* `#`
* `?`
* `%23` (codificación URL para `#`)
* `%3f` (codificación URL para `?`)

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a38c5ce69d9bc648b78a40c5607f5d556141d116%2F%7B7EA33773-EA97-4E65-8E3C-9B67B911E404%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### También se almacena en caché el endpoint interesante

El directorio de recursos también parece estar oculto:

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

Esto es útil porque intentaremos apuntar la caché a `/resources` mientras mantenemos una ruta interpretada en la aplicación como `/my-account`.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1ac3925cf24690577209520d320448b896ba6500%2F%7B7F170BB2-692C-4C03-AFDB-A93F867CD2FC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Técnica: Fragmento + Cruce (con normalización)

Se construye una URL donde la aplicación continúa procesando **/my-account**, pero donde la caché normaliza/interpreta la secuencia para dar como resultado **/resources**.

Pruebas:

```bash
GET /my-account#/../resources
# Versión codificada (la que “pasa” mejor aquí)
GET /my-account%23%2f%2e%2e%2fresources
```

El punto clave: **El servidor de caché acepta la versión codificada en URL**, lo que desencadena el comportamiento esperado.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c8a3b989034d2126928f920b56b0210cbfcb6cb%2F%7B32BEC397-C36D-4B08-80BA-C8669DA6BD40%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Explotación: forzar a la víctima a almacenar la página en caché

Desde el servidor de explotación, la víctima es redirigida a la URL trampa:

{% code overflow="wrap" %}

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

{% endcode %}

#### Resultado

Una vez que la víctima ha pasado por esta URL, se recupera el recurso servido desde la caché y se obtiene la \*\*clave API de carlos\*\*, lo que valida el laboratorio.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4c1cb865be0c727f07377cd7c213a274615e27e5%2F%7B894F3806-E4A6-4A0C-8C5E-266C61681C7D%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/es/web/web-cache-deception/cheating-the-cache-via-cache-server-side-normalization.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.
