> 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-via-unkeyed-query-string.md).

# Envenenamiento de caché web mediante una cadena de consulta no incluida en la clave

### Envenenamiento de la caché web mediante una cadena de consulta no incluida en la clave

Este laboratorio presenta una vulnerabilidad de envenenamiento de la caché web debido al hecho de que la **cadena de consulta no se incluye en la clave de caché**. Un usuario legítimo visita regularmente la página de inicio del sitio usando **Google Chrome**.

El objetivo es envenenar la página de inicio para que devuelva una respuesta que contenga un **JavaScript en ejecución `alert(1)`** en el navegador de la víctima.

***

**Paso 1: Interceptación de la página de inicio**

La solicitud a la raíz del sitio (`/`) se intercepta. / En la respuesta, observamos la presencia de una etiqueta canónica **enlace**, lo que indica que algunos elementos de la URL pueden reflejarse en HTML.

***

**Paso 2: Prueba de la cadena de consulta**

Se añade una cadena de consulta arbitraria a la URL:

```bash
/?test
```

El valor se refleja correctamente **en la respuesta**, lo que confirma que la cadena de consulta influye en el contenido devuelto.

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

**Paso 3: Inyección de HTML**

La cadena de consulta se modifica entonces para inyectar HTML:

```bash
/?test'/><h1>JORDAN</h1>
```

El `<h1>` la etiqueta se interpreta correctamente en el navegador, demostrando una \*\*inyección de HTML\*\* aprovechable.

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

<figure><img src="/files/724b6e29214401389025f0ffae111421bee5cc3f" alt=""><figcaption></figcaption></figure>

**Paso 4: Inyección de JavaScript (envenenamiento de caché)**

Reemplace la inyección de HTML con un payload de JavaScript:

```bash
/?test'/><script>alert(1)</script>
```

La respuesta ahora contiene el script, que \*\*es ejecutado por el navegador\*\*.

<figure><img src="/files/72f02d06acdd7422562ded610dec78a4089e5065" alt=""><figcaption></figcaption></figure>

**Resultado**

Como la cadena de consulta **no se incluye en la clave de caché**, la respuesta envenenada se almacena y se sirve a otros usuarios que visitan la página de inicio. / La víctima entonces desencadena automáticamente la ejecución de `alert(1)` durante su visita, lo que valida el funcionamiento del laboratorio.

<figure><img src="/files/26863a7aad69eb961a53e2567f1406ed8904e763" 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-via-unkeyed-query-string.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.
