Reflected XSS into a JavaScript string with single quote and backslash escaped


The website in this lab contains a reflected cross-site scripting vulnerability in the search query tracking functionality. The reflection occurs inside a JavaScript string with single quotes and backslashes escaped.

Reproduction and proof of concept

  1. Enter a random alphanumeric string in the search box, then use Burp to intercept the search request and send it to Burp Repeater.

  2. Note the random string has been reflected inside a JavaScript string.

  3. Try sending the payload test'payload and observe that your single quote gets backslash-escaped, preventing you from breaking out of the string.

  4. Replace the input with the following payload to break out of the script block and inject a new script:

  1. Verify the technique worked by right-clicking, selecting “Copy URL”, and pasting the URL in the browser. When you load the page it should trigger an alert.