DOM-based XSS
Cross-site scripting that happens entirely in the browser, when page JavaScript copies attacker-controlled data, such as part of the URL, into a dangerous sink.
It gives attackers script execution in your origin without any server bug.
In more detail
The server may never see the attack. Trusted Types stops it at the root by refusing plain strings at sinks such as innerHTML.
Related terms
- cross-site scripting — An attack in which someone gets their own script to run inside your page, where it can read data, act as the user or steal tokens.
- injection sink — A place in code where a string is interpreted as HTML or code, such as innerHTML, document.write or eval, and so can run an attack if the string is untrusted.
- Trusted Types — A browser security feature that makes dangerous DOM sinks such as innerHTML reject plain strings and accept only values produced by a policy you define.
- innerHTML — The DOM property that reads or replaces an element's contents as an HTML string, which the browser parses into nodes.
Taught in
- Content Security Policy (CSP), Trusted Types And XSS Defenses — Frontend Architecture & Web Platform