In this post, we’re going to be solving the lab: “Reflected DOM XSS”:

Reflected DOM XSS lab start screen

In this case, we’re told that the server processes request data and displays the response data. Subsequently, a page script processes the reflected data in an insecure way. To solve the lab, we must execute the alert function.

That said, the first thing to do is access the lab:

Lab main page with search form

Once accessed, we can observe a form that allows us to search the blog. To better analyze the behavior of this functionality, we open Burp Suite and activate the proxy in the browser:

Proxy configuration in the browser

Burp Suite interceptor activated and waiting

With this done, we try to perform any search:

Search form with test term

Intercepted GET request with search parameter

When we click Search, the request shown above is generated. There isn’t much information, and since the statement spoils that the vulnerability is in an insecure script, we can assume that the first search request doesn’t have much to it, so we simply send it.

When we send the first search request, if we keep Burp Suite’s intercept on, we’ll intercept the following request:

Second intercepted JSON request generated by the frontend

This looks like it was generated by the frontend of the resource requested in the first request (/?search=test). To better analyze its response, we send it to the repeater:

JSON response in Burp Suite Repeater showing search term

The server returns a response in JSON format, where at the bottom we can observe the search term we entered.

We can try to escape from the JSON context in this case, for example, try to inject an alert:

Test payload injected in the search parameter

In the response, we can observe that apparently we can inject and escape from the JSON without problems, since there’s no sanitization whatsoever, so using the payload above, we place it in the request we left in the proxy and send it:

Request with XSS payload sent from the proxy

Successful alert execution showing XSS

This way, we successfully obtain an XSS and solve the lab:

Lab solved successfully message

Final confirmation of lab success