
DOM-based cross-site scripting (DOM XSS) is a type of XSS where the vulnerability is in the page's own client-side JavaScript. The script reads data from a source the attacker can control, such as the URL, and writes it into the page in an unsafe way.
Every HTML document has a Document Object Model (DOM): the browser's object representation of the page. In DOM XSS, the malicious data never has to appear in the server's response. The page's script modifies the DOM using attacker-controlled data, and the browser runs it.
The video below demonstrates DOM XSS using the Damn Vulnerable Web Application (DVWA), a deliberately vulnerable application for practice.
textContent or setAttribute instead of innerHTML or document.write.eval, setTimeout with a string, or similar functions.innerHTML, eval and string-based setTimeout.postMessage handling.In DOM XSS the vulnerable code runs in the browser: the page's own JavaScript writes untrusted data into the page, often without the server ever seeing the payload.
Use safe sinks such as textContent, avoid innerHTML and eval with untrusted data, and add a strict Content Security Policy.
Try Vooki Pro free for 7 days
Find DOM XSS that server-side testing misses. The trial unlocks every feature for 7 days, and scanning runs on your own machine.
Related: Cross-Site Scripting (XSS): reflected, stored and DOM-based · A practical guide to Content Security Policy (CSP)