CVE-2024-29180 is a high-severity (CVSS 7.4) Path Traversal vulnerability in webpack-dev-middleware. A fix is available for webpack-dev-middleware — see the affected versions and patch details below.
webpack-dev-middleware Path Traversal vulnerability
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
Exploitation and automatability from CISA’s SSVC triage for CVE-2024-29180.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
webpack-dev-middlewarenpmDescription
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | webpack-dev-middleware | ≥ 7.0.0&&< 7.1.0 | 7.1.0npm install webpack-dev-middleware@7.1.0 |
| 📦npm | webpack-dev-middleware | ≥ 6.0.0&&< 6.1.2 | 6.1.2npm install webpack-dev-middleware@6.1.2 |
| 📦npm | webpack-dev-middleware | all versions | 5.3.4npm install webpack-dev-middleware@5.3.4 |
Affected Products
webpack-dev-middlewarewebpack.jsDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for webpack-dev-middleware, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update webpack-dev-middleware to 7.1.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2024-29180 is resolved across your whole dependency graph.
Workarounds
Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
The vulnerability in webpack-dev represents a important security issue due to its potential to expose sensitive files and compromise developer machines. By failing to validate URLs and normalize paths effectively, the middleware allows attackers to craft malicious requests that can retrieve arbitrary local files or…
Mitigation for this issue is either not available or the currently available options don't meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.Source: Red Hat security advisory for CVE-2024-29180 (CC BY 4.0)
| Product | Fixed in | Advisory |
|---|---|---|
| Migration Toolkit for Runtimes 1 on RHEL 8 | webpack-dev-middleware | RHSA-2024:3920 |
| MTA-6.2-RHEL-9 | mta/mta-ui-rhel9:6.2.3-2 | RHSA-2024:3989 |
| MTA-7.0-RHEL-9 | mta/mta-cli-rhel9:7.0.3-16 | RHSA-2024:3316 |
| NETWORK-OBSERVABILITY-1.6.0-RHEL-9 | network-observability/network-observability-cli-rhel9:v1.6.0-66 | RHSA-2024:3868 |
| OpenShift-Pipelines-1.16-RHEL-8 | openshift-pipelines/pipelines-chains-controller-rhel8:v1.16.0-6 | RHEA-2024:7870 |
| Red Hat Advanced Cluster Security 4.4 | advanced-cluster-security/rhacs-central-db-rhel8:4.4.2-4 | RHSA-2024:2941 |
| Red Hat build of Apicurio Registry 2.6.1 GA | webpack-dev-middleware | RHSA-2024:4873 |
| Red Hat Data Grid | webpack-dev-middleware | RHSA-2024:4460 |
Frequently Asked Questions
Is CVE-2024-29180 in your dependencies?
Find it across npm, including transitive dependencies.