PortSwigger

Lab Description
This lab exploits a path mapping discrepancy between the cache and the origin server to access a user’s sensitive API key.
Objective: Find the API key for the user carlos.
Credentials: wiener:peter
Step 1: Identify the Target Endpoint
- Log in as
wiener:peter - Open
GET /my-accountin Burp Proxy - Notice the response contains your API key

Step 2: Identify the Path Mapping Discrepancy
-
Send
GET /my-accountto Repeater -
Add an arbitrary segment:
/my-account/abc- Still returns your account page → origin abstracts the path to
/my-account 
- Still returns your account page → origin abstracts the path to
-
Add a static extension:
/my-account/abc.js- Response contains
X-Cache: missandCache-Control: max-age=30 
- Response contains
-
Resend within 30 seconds
X-Cachechanges tohit→ Cache treats this as a static.jsfile
Step 3: Craft the Exploit
- Go to the Exploit server
- In the Body section, paste:
<script>
document.location = "https://YOUR-LAB-ID.web-security-academy.net/my-account/wcd.js"
</script>

Why wcd.js:
- The arbitrary path segment should be unique (prevents receiving your own cached response)
.jsextension triggers the cache rule
Step 4: Deliver the Exploit
- Click Deliver exploit to victim
- The victim visits the exploit → navigates to
/my-account/wcd.js - Origin server returns Carlos’s account page (with API key)
- Cache stores the response for 30 seconds

Step 5: Retrieve the Cached Response
- In your browser, visit:
https://YOUR-LAB-ID.web-security-academy.net/my-account/wcd.js
- Copy Carlos’s API key from the response

Step 6: Submit the Solution
- Go back to the lab page
- Click Submit solution
- Paste Carlos’s API key
- Click Submit

Step 7: Lab Solved
