Webpack Dev Middleware experienced a notable update moving from version 3.5.2 to 3.6.0. Both versions serve as development middleware for Webpack, streamlining the development workflow. A key difference lies in the updated memory-fs dependency. Version 3.5.2 utilizes ~0.4.1 which allows minor updates while version 3.6.0 uses ^0.4.1 allowing minor and patch updates. Furthermore, version 3.6.0 sees an increment in standard-version from 4.4.0 to 5.0.0 and mocha from 5.2.0 to 6.0.0, potentially introducing new features or addressing bugs related to versioning and testing respectively. The dist object reveals a size difference, with 3.6.0 having an unpackedSize of 36029 compared to 3.5.2's 34548, suggesting added code or assets. Finally, version 3.6.0 was released on February 19, 2019, while 3.5.2 was released on February 6, 2019.
For developers, upgrading to 3.6.0 offers the latest features of standard-version and mocha. The small increase in size may incorporate performance improvements or bug fixes. Developers should review the changes introduced by standard-version 5.0.0 and mocha 6.0.0 to ensure compatibility and leverage any new functionalities. Also, keep in mind that these versions were released in 2019, so consider using newer versions to take advantage of latest features and security fixes.
All the vulnerabilities related to the version 3.6.0 of the package
Path traversal in webpack-dev-middleware
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.
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.
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
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.
The URL should be unescaped and normalized before any further processing.