Document Object Model (DOM)

The Document Object Model (DOM) is a web browser's hierarchical representation of the elements on the page. Websites can use JavaScript to manipulate the nodes and objects of the DOM, as well as their properties. DOM manipulation in itself is not a problem. In fact, it is an integral part of how modern websites work. However, JavaScript that handles data insecurely can enable various attacks. DOM-based vulnerabilities arise when a website contains JavaScript that takes an attacker-controllable value, known as a source, and passes it into a dangerous function, known as a sink.

DOM-based vulnerabilityExample sink

DOM XSS LABS

document.write()

window.location

document.cookie

eval()

document.domain

WebSocket()

element.src

postMessage()

setRequestHeader()

FileReader.readAsText()

ExecuteSql()

sessionStorage.setItem()

document.evaluate()

JSON.parse()

element.setAttribute()

RegExp()

Resources

Last updated