DOM-Based
Attackers can inject malicious scripts that execute within the user's browser, potentially leading to data theft, unauthorized actions, or site defacement.
Basic
The example below is based on TCM's Practical Bug Bounty course.
When an item is added to the below to-do application, no network traffic is generated (Figure 1).

If we try a common JavaScript payload, we get a prompt box back (Figure 2).
// the JavaScript payload used
<img src="x" onerror="prompt()">

We can also use the above attack to redirect the user to another location (Figure 3).
// the XSS payload used
<img src="x" onerror="window.location.href='https://x7331.gitbook.io/boxes'">

DOM Invader
The example below is based on PortSwigger's DOM XSS in
document.write
sink using sourcelocation.search
lab.
We can automatically enumerate Sinks using the DOM Invader extension within Burp's Chromium browser (Figure 4).

DOM Invader was able to identify a Sink associated with document.write
. We can find more about it when we click the Stack Trace
link (Figure 5.3) as well as exploit it by clicking on the Exploit
button (Figure 5.4).

Code Review
The example below is based on PortSwigger's DOM XSS in
document.write
sink using sourcelocation.search
inside a select element lab.
The response of the application's /product
directory contains an interesting piece of code (Figure 6).

If we manipulate the storeId
parameter, we notice that it ends up within a select
statement (Figure 7).

storeId
parameter.We can terminate the select
statement and then pass our payload to achieve XSS (Figure 8).
// the JavaScipt payload used
</select><img src=x on error=alert()>

Last updated
Was this helpful?