> 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/pt-br/web/cache-poisoning/cache-poisoning-via-an-unindexed-query-string.md).

# Envenenamento de Cache via String de Consulta Não Indexada

### Envenenamento de cache da web por meio de uma string de consulta não incluída na chave

Este laboratório apresenta uma vulnerabilidade de envenenamento do cache da web devido ao fato de que a **string de consulta não é incluída na chave do cache**. Um usuário legítimo visita regularmente a página inicial do site usando **Google Chrome**.

O objetivo é envenenar a página inicial para que ela retorne uma resposta contendo um **JavaScript em execução `alert(1)`** no navegador da vítima.

***

**Etapa 1: Interceptação da página inicial**

A requisição para a raiz do site (`/`) é interceptada. / Na resposta, observamos a presença de uma tag canonical **link**, o que indica que alguns elementos da URL podem ser refletidos em HTML.

***

**Etapa 2: Teste da string de consulta**

Uma string de consulta arbitrária é adicionada à URL:

```bash
/?test
```

O valor é bem **recebido na resposta**, o que confirma que a string de consulta influencia o conteúdo retornado.

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

**Etapa 3: Injeção de HTML**

A string de consulta é então modificada para injetar HTML:

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

O `<h1>` a tag é interpretada corretamente pelo navegador, demonstrando uma \*\*injeção de HTML\*\* utilizável.

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

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

**Etapa 4: Injeção de JavaScript (envenenamento de cache)**

Substitua a injeção de HTML por uma carga útil de JavaScript:

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

A resposta agora contém o script, que é \*\*executado pelo navegador\*\*.

<figure><img src="/files/809e323b63732112286327d62c6fa99d182d1e8d" alt=""><figcaption></figcaption></figure>

**Resultado**

Como a string de consulta está **não incluída na chave do cache**, a resposta envenenada é armazenada e servida a outros usuários que visitarem a página inicial. / A vítima então aciona automaticamente a execução de `alert(1)` durante sua visita, o que valida o funcionamento do laboratório.

<figure><img src="/files/99cdaf8df7f623fa1edabb4b1e6b5a6237c9e087" 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/pt-br/web/cache-poisoning/cache-poisoning-via-an-unindexed-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.
