Solving Portswigger Academy: Reflected XSS into a JavaScript string with single quote and backslash escaped

Vishal
Oct 1, 2024

--

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.

To solve this lab, perform a cross-site scripting attack that breaks out of the JavaScript string and calls the alert function.

When you access the lab, you will see a search box. To test the behavior I used a string ‘abcd12345’ in a search box.After that view the page source.

In script tag, you will find your input.

Now we need to trigger an alert box using XSS. First we need to close the script tag using </script> and then use payload such as <img src=x onerror=alert(1)>

</script><img src=x onerror=alert(1)>

Once you use above payload an alert will pop-up.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response