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

# Web Cache Poisoning via an Unkeyed Query Parameter

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

### Web Cache Poisoning via an Unkeyed Query Parameter

This lab is vulnerable to a web cache poisoning attack as a query parameter is not included in the cache key. / A user regularly visits the home page of the site using Chrome. / The goal is to poison the cache so that the home page serves a reply running `alert(1)` in the victim's browser.

**Initial analysis**

* By intercepting the root page response, a **canonical** link is observed.
* If you access the URL with an arbitrary parameter, for example `/?hello`, the value is well reflected in the answer

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1871d2fc701cc8b477a71d82641d280d6cb50a35%2F%7BF524D9FB-B23A-4150-81DA-8F20E7419FC7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Injecting a payload like:

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

* HTML code is interpreted in response, but no alerts run on victim side.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e4f554844d5146c3422aceb69e3dcced72fcb1fe%2F%7B734F33BC-EB04-480C-A19E-D18BE89A91C9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Identified problem**

The cache considers each variation of the `?test` parameter as a new input. / Thus, with each change in value, the cache is regenerated and poisoning does not persist.

However, some parameters are **totally ignored** by the cache key:

* Their name and value are not taken into account.
* The cached response remains the same, even if their value changes.

**Identification of the unindexed parameter**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-65505e828de6590eb1d67cb0861211ff661f7d53%2F%7B01DA2100-8C27-4CB0-BFF0-3EFE3043FE34%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Using **Param Miner** (function Guess query parameters ), the `utm_content` parameter is identified.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-20c44b2767ed05cc3d703e77327ef684da948c37%2F%7B05D74FEB-B745-45BE-B1A4-CC31B5C89F63%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* By testing different values for this parameter, we find that the cache remains unchanged, confirming that it is not included in the cache key.

<pre class="language-bash"><code class="lang-bash"><strong>/?utm_content=test
</strong></code></pre>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-58224d7a9841bc18b9b0c1d9e2da7bf5cd984cf2%2F%7B39C0B55B-4D1C-4D05-9E2F-10064DBBE52C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Exploitation**

The malicious payload is then injected into this unindexed parameter:

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

The poisoned response is stored in the cache and served to the following visitors.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-561c0564a9cc1ff15928ee60745fc1b1a454b91f%2F%7BB11F48CD-41CB-4DF8-8C99-A21C820C843B%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-via-unkeyed-query-parameter.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.
