High, CVSS 7.4npmAmendedPublished
Path traversal in webpack-dev-middleware
CVE-2024-29180 · GHSA-wr3j-pwj9-hqq6
- Affected
- npm webpack-dev-middleware >= 7.0.0, < 7.1.0; >= 6.0.0, < 6.1.2; <= 5.3.3
- Fixed in
- 6.1.27.1.05.3.4· Vendor fix available
- Issue
- 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…
Recommended action: Upgrade to 7.1.0, 6.1.2 or 5.3.4 by release line, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.