PortSwigger

Description :
Make the “back” link execute alert(document.cookie) by exploiting a DOM-based XSS vulnerability in the jQuery $ selector function that changes an anchor element’s href attribute using data from location.search.
Solution Steps
- Access the lab and navigate to the Submit feedback page.

-
- Look for the “back” link on the page.
- Modify the URL by changing the
returnPathquery parameter.
Start by testing with a random alphanumeric string:
https://YOUR-LAB-ID.web-security-academy.net/feedback?returnPath=/test123

-
Right-click and inspect the “back” link to verify your input appears inside an
a hrefattribute. -
Change the
returnPathparameter to ajavascript:pseudo-protocol payload:
javascript:alert(document.cookie)

Full URL Example:

-
Press Enter to load the modified URL.
-
Click the “back” link on the page.
-
The alert fires showing the document cookie, and the lab is marked as Solved.

Solved
