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

# Web Cache Poisoning via an Unkeyed Query String

Web Cache Poisoning via an Unkeyed Query String 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 String

This lab presents a vulnerability to poisoning of the web cache due to the fact that the **query string is not included in the cache key**. A legitimate user regularly visits the home page of the site using **Google Chrome**.

The objective is to poison the home page so that it returns a response containing a **JavaScript running `alert(1)`** in the victim's browser.

***

**Step 1: Home Page Interception**

The request to the site root (`/`) is intercepted. / In the response, we observe the presence of a canonical **link**, which indicates that some elements of the URL can be reflected in HTML.

***

**Step 2: Query string test**

An arbitrary query string is added to the URL:

```bash
/?test
```

The value is well **taken in the response**, which confirms that the query string influences the returned content.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2edac0238e60404a2095ff1a7ea707191fe84fe2%2F%7BF4380530-5577-4C17-81E1-72A4F44209FD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Step 3: HTML Injection**

The query string is then modified to inject HTML:

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

The `<h1>` tag is correctly interpreted by the browser, demonstrating a usable \*\* HTML injection\*\*.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-64a4c271dcfb6dfdeb1a04038b3df9236e5a187b%2F%7BB9746F67-1733-44BE-9C4D-DE7C12128D48%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d9db563f4e632385fbdec7d98601a459dbb8f8ed%2F%7BA8006643-5C60-46F6-959E-A7C7195FB8BD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Step 4: JavaScript Injection (Cache poisoning)**

Replace the HTML injection with a JavaScript payload:

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

The answer now contains the script, which is \*\* run by the browser\*\*.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c1d50621264ed9b43341def8b6f65030f5987a0b%2F%7B789452C2-9E94-4AC9-B846-69E03388E23A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Result**

Since the query string is **not included in the cache key**, the poisoned response is stored and served to other users visiting the home page. / The victim then automatically triggers the execution of `alert(1)` during his visit, which validates the operation of the lab.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-188a11ff05f7fa2c605133ed854079e5cec26ff1%2F%7B42C67203-FBC2-45CF-8CC8-6502A3A33DD4%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-string.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.
