Inappropriate implementation in HTML (CVE-2026-17674)
Blink's Scoped Custom Element Registry accessors lacked world-isolation checks, letting an isolated world obtain the main world's registry. A shared promise cache in whenDefined() then leaked a main-world constructor function to the isolated world, enabling script execution across the boundary and bypassing CSP.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 2 months
Project Fortify, an experimental security project, has identified the following potential security issue. If you're a feature owner CC-ed on this bug, please do your best to review these reports. Please see https://chromium.googlesource.com/chromium/src/+/main/docs/security/ai-generated-security-bugs-faq.md for more information.
Overview: A vulnerability in Blink's Scoped Custom Element Registry (SCER) allows isolated worlds to access the global custom element registry. Combined with a shared promise cache, this enables the leak of JavaScript constructor functions across world boundaries, potentially bypassing world isolation and CSP.
Affected files:
third_party/blink/renderer/core/html/custom/custom_element_registry.ccthird_party/blink/renderer/core/frame/local_dom_window.ccthird_party/blink/renderer/core/dom/tree_scope.ccthird_party/blink/renderer/core/dom/element.ccthird_party/blink/renderer/core/dom/document_or_shadow_root.idlthird_party/blink/renderer/core/dom/element.idl
Estimated timestamp from git blame: 2025-04-14
Summary
A potential vulnerability has been identified in the implementation of the Scoped Custom Element Registry (SCER) feature in Blink. The issue allows for a deterministic Cross-DOMWrapperWorld isolation bypass, enabling arbitrary JavaScript execution between the main world (the page) and isolated worlds (e.g., extension content scripts). This arises from missing world-isolation guards in new SCER accessors and the use of a world-shared promise cache in whenDefined().
Technical Details
Bug A: Missing Accessor Guard
By design, window.customElements is guarded to prevent access from isolated worlds by returning nullptr if the caller is not the main world (see LocalDOMWindow::customElements(ScriptState*) in third_party/blink/renderer/core/frame/local_dom_window.cc).
However, the SCER feature introduced a new customElementRegistry attribute on Document and Element (defined in third_party/blink/renderer/core/dom/document_or_shadow_root.idl). This accessor calls TreeScope::customElementRegistry(), which eventually invokes the no-argument overload of LocalDOMWindow::customElements(). This overload lacks the IsMainWorld() check, allowing an isolated world to obtain the global CustomElementRegistry instance used by the main world.
Bug B: Cross-World Constructor Leak
The CustomElementRegistry maintains a when_defined_promise_map_ to cache promises for custom element names. This map is shared across all DOMWrapperWorlds. When a world (e.g., an extension) calls whenDefined('my-element'), a ScriptPromiseResolver is created in that world and stored in the global registry's map.
When the element is subsequently defined (e.g., by the main page), the registry resolves the pending resolver using the defining world's constructor. The resolution process uses ToV8Traits<V8CustomElementConstructor>::ToV8, which in release builds lacks the necessary world-safety checks (the DCHECK in third_party/blink/renderer/bindings/core/v8/to_v8_traits.h is removed). This allows a raw JavaScript function (the constructor) from the main world to be leaked to the isolated world.
Potential Impact
An attacker who obtains a cross-world v8::Function (constructor) can access the target world's global Function constructor via the prototype chain (constructor.constructor). This enables:
- Page to Extension: A malicious site can execute code in an extension's context if the extension uses
document.customElementRegistry.whenDefined(). - Extension to Page: A content script can execute code in the main world, bypassing Content Security Policy (CSP).
Potential Steps to Reproduce
- From an extension content script, call
let p = document.customElementRegistry.whenDefined('x-target');. - From the main world page, define the element:
customElements.define('x-target', class extends HTMLElement {});. - In the content script, once
presolves, access the main world's context via the resolved constructor:p.then(ctor => ctor.constructor('alert(document.domain)')());.
Suggested Fix
- Update
DocumentOrShadowRoot.idlandElement.idlto include[CallWith=ScriptState]for thecustomElementRegistryattribute. - In
TreeScope::customElementRegistry(ScriptState*), enforce anIsMainWorld()check when returning the global registry. - Ensure
CustomElementRegistry::when_defined_promise_map_is world-isolated, or verify world compatibility before resolving promises inCustomElementRegistry::define.
Evaluated with Chrome root at commit: 1a8d40fc44df2088d5945c0bf53584038aa1614a
Results so far have been promising, but there can be wrong deductions. Feel free to adjust as follows:
- If you are familiar with the severity guidelines, you may adjust the severity.
- If this is a false positive, and there's no work to be done, please close as WAI.
- If there is work to do here but not a vulnerability, please change the issue type to Task/Bug/FR.
Data from false positives will be used to improve accuracy over time. And please feel free to reach out to me directly if you have concerns or feedback on the project.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the new customElementRegistry accessors omitted the IsMainWorld() guard used by window.customElements, and the whenDefined() promise map was shared across worlds without a world check when resolving.
Impact
A malicious page could execute code in an extension's context if the extension calls whenDefined, and a content script could execute code in the main world, bypassing CSP.
What the attacker needed
An extension content script using whenDefined; the page defines the matching element
The fix
The accessors should pass ScriptState and enforce an IsMainWorld() check, and the whenDefined promise map should be world-isolated or checked before resolving.
How it was found
- From an extension content script, call whenDefined on the document's custom element registry for a chosen name.
- From the main world page, define a custom element with that name.
- In the content script, when the promise resolves, use the returned constructor to reach the main world's Function constructor and run code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Browsers keep page scripts and extension scripts in separate 'worlds' so one cannot read the other's JavaScript objects. Here a new browser feature let an extension script reach into the page's world and receive a function object from it. With that function, the extension script could run its own code inside the page, and a malicious page could do the reverse inside an extension.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.