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

# Envenenamento de cache com um cookie sem chave

Notas sobre envenenamento de cache com um cookie sem chave para os laboratórios do PortSwigger Web Security Academy, incluindo fluxo de exploração, teste de payload, validação no Burp Suite e contexto de remediação.

### Envenenamento de cache web com um cookie não incluído na chave

Este laboratório é vulnerável a envenenamento de cache web, pois os cookies não são incluídos na chave do cache. Um usuário legítimo visita regularmente a página inicial. / O objetivo é envenenar o cache com uma resposta que execute `alert(1)` no navegador da vítima.

#### Análise da Resposta

* A requisição é interceptada para a raiz (`/`).
* Na resposta HTML, observamos um script JavaScript contendo dados dinâmicos:

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

* O `frontend` é o valor de um cookie enviado pelo navegador

#### Observação do Cookie

* Na requisição, um cookie chamado `fehost` está presente:

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

* Esse valor é reutilizado diretamente na resposta sem ser integrado à chave do cache.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f606d58cda0aa54d4e7fa2704161bde87fe5b28%2F%7B07D90C20-F8F7-4821-95C8-7142DBB12738%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Manipulação de Cookie

* Ao alterar o valor do `fehost` cookie, a resposta reflete imediatamente o novo valor:

```bash
fehost=test
```

* Isso confirma que o cookie é **não é indexado no cache** e que influencia o conteúdo em cache.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-60368e8982e1dd4fc8a3397f98ca295198775827%2F%7BBEF704EB-BEDE-42C4-8612-2C71E2DE82A2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Injeção de Payload

* Em seguida, um valor malicioso é injetado no cookie para quebrar o contexto do JavaScript e executar código arbitrário:

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

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df219aad398446f4943e7420b19e191dcb61332c%2F%7B27D4A359-AE55-4B4A-A5F7-7DF4E04072BA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* O payload sai da string JavaScript e injeta uma chamada para `alert(1)`.

<figure><img src="https://783634792-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-459468743afcc41527fbfc36e6fb0035c31bce09%2F%7BFC59DDFE-FF56-4E6A-AD69-C21EFF02B573%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/pt-br/web/cache-poisoning/web-cache-poisoning-with-unkeyed-cookie.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.
