> 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/web-cache-deception/cheating-the-cache-by-manipulating-paths.md).

# Cheating the Cache by Manipulating Paths

Cheating the Cache by Manipulating Paths notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remediation context.

### Exploiting Path Mapping for Web Cache Deception

#### Objective of the Lab

Recover \*\* API key\*\* from user **carlos**. / Credentials provided: **wiener:peter**.

#### Observations

* In **My account** (my-account), the \*\* API key\*\* appears **in plain** for our own user.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-108b38e85bcc7723d3655ed256ab94e6d6ab23ed%2F%7B6D0C2C89-1F6B-48CA-B915-C9EDF0F5E9DE%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Initially, there is no direct indication (in the answer) that there is **caching**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-29183f864d0e6633e8eec334dd43f232517f9326%2F%7BA44A17EA-B46B-4E3B-89DF-96104A9B1F59%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* However, by adding segments to the URL, the application continues to display the **my-account** page, suggesting a **mapping logic of routes** potentially compatible with cache.

Examples tested:

* `/my-account/TESTTTTTT` → The application always treats this as **my-account**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2b3e00bdbf8e94e2755b444e3c6e8968ff9597eb%2F%7B3B320FBE-E2BE-43DB-8AEC-6223464C1F8E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* `/my-account/TESTTT.js` → extension **.js** is accepted and interpreted (useful to deceive cache rules)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b7e90f784764ff27fd8de94be4cbafb6aca535d%2Fimage%20(3133).png?alt=media" alt=""><figcaption></figcaption></figure>

From the**Exploit Server**, force a victim to load a URL of the type "static" pointing to my-account:

{% code overflow="wrap" %}

```javascript
<script>
    document.location="https://0afd005204a0683b803d1ce200320070.web-security-academy.net/my-account/jordan.js";
</script>
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5ee7d2cf564ad6368a92b92c410e95cc212a7ce5%2F%7B6ABD89DC-A971-48F3-8542-76823C922CFC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. By visiting:

* `/my-account/jordan.js`/ one gets an answer that displays the \*\* carlos API key\*\*.

#### Result

The API key for **carlos** is displayed via a camouflaged URL (with `.js` extension) which allows you to take advantage of the cache/routing behavior (`/my-account/<quelque_chose>.js`).

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7aed730f89d4e5583776766836cb14dca0d58b14%2F%7BA88CD920-5D43-48A2-834E-F59F2D901B5F%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/web-cache-deception/cheating-the-cache-by-manipulating-paths.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.
