> 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/web-cache-poisoning-with-unkeyed-cookie.md).

# Envenenamiento de caché con una cookie no incluida en la clave

### Envenenamiento de caché web con una cookie no incluida en la clave

Este laboratorio es vulnerable al envenenamiento de caché web, ya que las cookies no se incluyen en la clave de caché. Un usuario legítimo visita regularmente la página de inicio. / El objetivo es envenenar la caché con una respuesta que ejecute `alert(1)` en el navegador de la víctima.

#### Análisis de la respuesta

* La solicitud se intercepta a la raíz (`/`).
* En la respuesta HTML, observamos un script de JavaScript que contiene datos dinámicos:

```javascript
<script>
  data = {
    "host":"0ab5006d03269ea785b94a9e000100c5.web-security-academy.net",
    "path":"/",
    "frontend":"prod-cache-01"
  }
</script>
```

* El `frontend` es el valor de una cookie enviada por el navegador

#### Observación de la cookie

* En la solicitud, aparece una cookie llamada `fehost` presente:

```bash
fehost=prod-cache-01
```

* Este valor se reutiliza directamente en la respuesta sin integrarse en la clave de caché.

<figure><img src="/files/3afaa7bd374ed6e8457035398cf0333cd2e7ccb4" alt=""><figcaption></figcaption></figure>

#### Manipulación de la cookie

* Al cambiar el valor de la `fehost` cookie, la respuesta refleja inmediatamente el nuevo valor:

```bash
fehost=test
```

* Esto confirma que la cookie **no está indexada en la caché** y que influye en el contenido almacenado en caché.

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

#### Inyección de la carga útil

* A continuación, se inyecta un valor malicioso en la cookie para romper el contexto de JavaScript y ejecutar código arbitrario:

```javascript
test"-alert(1)-"efffe
```

<figure><img src="/files/0be2b3a1f8c0c48da66e73ecfd71efa7791b79a1" alt=""><figcaption></figcaption></figure>

* La carga útil sale de la cadena de JavaScript e inyecta una llamada a `alert(1)`.

<figure><img src="/files/a92981977a0cd61473d54588d9ffc7b3a859202a" 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/cache-poisoning/web-cache-poisoning-with-unkeyed-cookie.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.
