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

# Cache Poisoning with an Unkeyed Cookie

Cache Poisoning with an Unkeyed Cookie notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Web Cache Poisoning with an Unkeyed Cookie

This lab is vulnerable to web cache poisoning as cookies are not included in the cache key. A legitimate user regularly visits the home page. / The goal is to poison the cache with a response that executes `alert(1)` in the victim's browser.

#### Analysis of the Response

* The request is intercepted to the root (`/`).
* In the HTML response, we observe a JavaScript script containing dynamic data:

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

* The `frontend` field is the value of a cookie sent by the browser

#### Cookie Observation

* In the query, a cookie named `fehost` is present:

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

* This value is reused directly in the response without being integrated into the cache key.

<figure><img src="https://131707722-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>

#### Cookie Manipulation

* By changing the value of the `fehost` cookie, the answer immediately reflects the new value:

```bash
fehost=test
```

* This confirms that the cookie is **not indexed in the cache** and that it influences the cached content.

<figure><img src="https://131707722-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>

#### Payload Injection

* A malicious value is then injected into the cookie to break the JavaScript context and execute arbitrary code:

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

<figure><img src="https://131707722-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>

* Payload escapes from the JavaScript string and injects a call to `alert(1)`.

<figure><img src="https://131707722-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/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.
