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

chore(deps): update dependency webpack-dev-middleware to >= 5.3.4 [security] - autoclosed #677

Closed

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 22, 2024

Mend Renovate

This PR contains the following updates:

Package Change
webpack-dev-middleware [5.2.2 -> >= 5.3.4](https://renovatebot.com/diffs/npm/webpack-dev-middleware/5.2.2/>= 5.3.4)

GitHub Vulnerability Alerts

CVE-2024-29180

Summary

The webpack-dev-middleware middleware does not validate the supplied URL address sufficiently before returning the local file. It is possible to access any file on the developer's machine.

Details

The middleware can either work with the physical filesystem when reading the files or it can use a virtualized in-memory memfs filesystem.
If writeToDisk configuration option is set to true, the physical filesystem is used:
https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/setupOutputFileSystem.js#L21

The getFilenameFromUrl method is used to parse URL and build the local file path.
The public path prefix is stripped from the URL, and the unsecaped path suffix is appended to the outputPath:
https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/getFilenameFromUrl.js#L82
As the URL is not unescaped and normalized automatically before calling the midlleware, it is possible to use %2e and %2f sequences to perform path traversal attack.

PoC

A blank project can be created containing the following configuration file webpack.config.js:
module.exports = { devServer: { devMiddleware: { writeToDisk: true } } };

When started, it is possible to access any local file, e.g. /etc/passwd:
$ curl localhost:8080/public/..%2f..%2f..%2f..%2f../etc/passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin

Impact

The developers using webpack-dev-server or webpack-dev-middleware are affected by the issue. When the project is started, an attacker might access any file on the developer's machine and exfiltrate the content (e.g. password, configuration files, private source code, ...).

If the development server is listening on a public IP address (or 0.0.0.0), an attacker on the local network can access the local files without any interaction from the victim (direct connection to the port).

If the server allows access from third-party domains (CORS, Allow-Access-Origin: * ), an attacker can send a malicious link to the victim. When visited, the client side script can connect to the local server and exfiltrate the local files.

Recommendation

The URL should be unescaped and normalized before any further processing.


Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link
Contributor Author

renovate bot commented Mar 22, 2024

⚠ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: .build/package-lock.json
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @webpack-cli/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/@webpack-cli/configtest/node_modules/webpack
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer webpack@"4.x.x || 5.x.x" from @webpack-cli/[email protected]
npm WARN node_modules/@webpack-cli/configtest
npm WARN   @webpack-cli/configtest@"^1.1.0" from [email protected]
npm WARN   node_modules/webpack-cli
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/ajv-keywords/node_modules/ajv
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer ajv@"^6.9.1" from [email protected]
npm WARN node_modules/ajv-keywords
npm WARN   ajv-keywords@"^3.5.2" from [email protected]
npm WARN   node_modules/schema-utils
npm WARN   1 more (schema-utils)
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/ajv
npm WARN   peer ajv@"^6.9.1" from [email protected]
npm WARN   node_modules/ajv-keywords
npm WARN     ajv-keywords@"^3.5.2" from [email protected]
npm WARN     node_modules/schema-utils
npm WARN     1 more (schema-utils)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"5.51.1" from the root project
npm ERR!   peer webpack@">=5.0.0" from [email protected]
npm ERR!   node_modules/assets-webpack-plugin
npm ERR!     dev assets-webpack-plugin@"7.1.1" from the root project
npm ERR!   17 more (copy-webpack-plugin, css-loader, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/optimize-css-assets-webpack-plugin
npm ERR!   dev optimize-css-assets-webpack-plugin@"6.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.0.0" from [email protected]
npm ERR!   node_modules/optimize-css-assets-webpack-plugin
npm ERR!     dev optimize-css-assets-webpack-plugin@"6.0.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /tmp/renovate/cache/others/npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/renovate/cache/others/npm/_logs/2024-03-22T21_04_02_771Z-debug-0.log

@renovate renovate bot changed the title chore(deps): update dependency webpack-dev-middleware to 5.3.4 [security] chore(deps): update dependency webpack-dev-middleware to >= 5.3.4 [security] Jun 17, 2024
@renovate renovate bot changed the title chore(deps): update dependency webpack-dev-middleware to >= 5.3.4 [security] chore(deps): update dependency webpack-dev-middleware to >= 5.3.4 [security] - autoclosed Aug 6, 2024
@renovate renovate bot closed this Aug 6, 2024
@renovate renovate bot deleted the renovate/npm-webpack-dev-middleware-vulnerability branch August 6, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants