The lab
here is how portswigger describes it
This lab contains an XSS vulnerability that is not directly exploitable due to browser URL-encoding. To solve the lab, take advantage of the cache's normalization process to exploit this vulnerability. Find the XSS vulnerability and inject a payload that will execute
alert(1)in the victim's browser. Then, deliver the malicious URL to the victim.
there is a reflected xss in the path, but a browser will url-encode the payload before sending it, so the special characters arrive as harmless % escapes and the script never runs. the trick is that the cache normalizes the url before keying it, decoding those escapes. so we send the raw, decoded payload once through Repeater to seed the cache with an unescaped, executing response, and then when the victim's browser sends the encoded version it normalizes to the same cache key and gets served our stored, decoded payload. the cache's own normalization bridges the gap the browser encoding created.
why normalization is the hole#
a browser does not send <script> in a url, it encodes it to %3Cscript%3E, and the app reflects those literal escaped characters, which do not execute. so the xss is real but unreachable straight from a browser. the cache sits in between and canonicalizes urls before computing the key, and part of that is percent-decoding. so the cache treats the browser's encoded request and our raw request as the same url, the same key. if we poison that key with a request whose payload is already decoded, the stored response contains live <script>, and the victim's encoded request normalizes onto that entry and is handed the executing copy. we exploit the mismatch between the browser encoding and the cache decoding.
Step 1 - find the reflection#
we browse to any non-existent path, such as GET /logicbreaker, and notice the path we requested is reflected back in the error message. that reflection in the path is our xss sink.

Step 2 - Inject the payload in the request line#
we add a reflected xss payload to the path in the request line:
GET /logicbreaker</p><script>alert(1)</script><p>foo
the </p> closes the surrounding element, the <script>alert(1)</script> runs, and the trailing <p>foo keeps the markup tidy.

Step 3 - see the browser-encoding problem and solve it via the cache#
if we request this url straight from the browser the payload does not execute, the browser url-encodes the special characters so the app reflects inert %3C... escapes.
the way around it is the cache's normalization. in Repeater we poison the cache with the raw, decoded payload, then immediately load the url in the browser. this time alert() fires, because the browser's encoded request was url-decoded by the cache during normalization and matched the same key as our earlier request, so it was served our stored, executing response.

Step 4 - Deliver to the victim#
we re-poison the cache and then immediately go to the lab and click Deliver link to victim, submitting our malicious url. when the victim visits the link their browser's encoded request normalizes onto our poisoned entry and runs alert(1).

with this, the lab is solved!
