portswigger-all-labs

Complete PortSwigger Web Security Academy Lab Writeups Detailed, categorized solutions for every lab — from APPRENTICE to EXPERT — covering all 30 vulnerability types.

View on GitHub

Labs Covered

This write-up focuses on the following EXPERT-level lab from the PortSwigger Web Security Academy related to Web Cache Deception:

5 Exploiting exact-match cache rules for web cache deception

This lab demonstrates how attackers can abuse exact-match cache rules to trick caches into storing sensitive resources.

LAB 5 - Exploiting exact-match cache rules for web cache deception

Lab Description

image

Overview Exploiting File Name Cache Rules

Certain files such as robots.txt, index.html, and favicon.ico are common files found on web servers. They’re often cached due to their infrequent changes. Cache rules target these files by matching the exact file name string.

To identify whether there is a file name cache rule, send a GET request for a possible file and observe whether the response is cached.

🔬 Lab Focus: The following techniques target vulnerabilities in robots.txt, index.html, and favicon.ico.


Detecting Normalization Discrepancies

To test how the origin server normalizes the URL path:

To test how the cache normalizes the path:

Interpretation:


Exploiting Normalization Discrepancies

If the cache server resolves dot-segments but the origin does not, you can exploit this mismatch.

For example:


Exploiting Exact-Match Cache Rules for Web Cache Deception (Expert Lab)

🎯 Goal: Change the administrator’s email address using a CSRF exploit.


Solution

1. Identify a Target Endpoint

2. Investigate Path Delimiter Discrepancies

Test with Intruder

image

Unchecked Payload encoding

image

image

3. Test Delimiters in Path

Try:

image


4. Investigate Normalization Discrepancies

image

Next:


5. Exploit the Vulnerability

🧬 Extract Administrator’s CSRF Token

  1. Try /my-account?%2f%2e%2e%2frobots.txt → 200 but no cache

    image

    • Repeat this test using the ; delimiter instead of ?.
  2. Try /my-account;%2f%2e%2e%2frobots.txt → 200 with user data, X-Cache: miss image

  3. Resend → Now shows X-Cache: hit

    image

🛠️ Deliver Exploit to Victim

  1. Go to Go to exploit server
  2. Paste payload:
<img src="/my-account;%2f%2e%2e%2frobots.txt?wc" />
  1. Click Deliver exploit to victim image

  2. In Burp, send same request:

    • /my-account;%2f%2e%2e%2frobots.txt?wc
  3. Confirm the CSRF token for administrator appears

    image


6. Craft Final CSRF Exploit

  1. Right-click POST /my-account/change-email → Send to Repeater image

  2. In Repeater, replace the CSRF token with the administrator’s token.

    • Change the email address in your exploit so that it doesn’t match your own.
    • Right-click the request and select Engagement tools > Generate CSRF PoC.

    image

3 Click Copy html

image

  1. Paste HTML into exploit server’s Body field

image

  1. Click Deliver exploit to victim again to solve the lab

image