Lab: DOM XSS in jQuery anchor href attribute sink using location.search source
Summary: PortSwigger's Web Security Academy lab describes a DOM-based cross-site scripting vulnerability on a submit feedback page, where the jQuery $ selector function finds an anchor element and changes its href attribute using data from location.search. The solution is to set the returnPath query parameter to javascript:alert(document.cookie), which places that value inside the a href attribute and executes when the back link is clicked.
What you should know: The sink is a single anchor href fed directly from location.search, so a crafted returnPath value turns an ordinary back link into script execution that can read document.cookie.
Read the original at PortSwigger Research ↗
- Topics
- Vulnerabilities & Patching
- Related
- Attackers Exploit UnrealIRCd Flaw That Enables Server-Level Command Injection Cyber Risks · Nov 14, 2026U.S. CISA adds Check Point and UnrealIRCd flaws to its Known Exploited Vulnerabilities catalog Cyber Risks · Nov 14, 2026PostgreSQL Patches 52 Flaws, Including 22-Year-Old Bug Enabling Authenticated RCE Cyber Risks · Nov 13, 2026