Описание
webcrack has an Arbitrary File Write Vulnerability on Windows when Parsing and Saving a Malicious Bundle
Summary
An arbitrary file write vulnerability exists in the webcrack module when processing specifically crafted malicious code on Windows systems. This vulnerability is triggered when using the unpack bundles feature in conjunction with the saving feature. If a module name includes a path traversal sequence with Windows path separators, an attacker can exploit this to overwrite files on the host system.
Details
Source: packages/webcrack/src/unpack/bundle.ts#L79
In this code, the application explicitly relies on the POSIX version of path utilities (dirname, join, normalize) from Node.js. However, the vulnerability arises because the POSIX version of the normalize function does not recognize \ as a path separator. As a result, on Windows systems, the path traversal check fails, allowing an attacker to write files to unintended locations.
PoC
The following proof of concept demonstrates how this vulnerability can be exploited to overwrite and hijack the debug module in Node.js:
Malicious Script (what.js):
Webcrack Script (index.js):
Execution:
Running the above script with node index.js twice results in the following output being printed to the terminal:
This demonstrates that the debug module was successfully overwritten and hijacked to print pwned to the console, confirming the arbitrary file write vulnerability has lead to code execution.
Impact
This vulnerability allows an attacker to write arbitrary .js files to the host system, which can be leveraged to hijack legitimate Node.js modules to gain arbitrary code execution.
Ссылки
- https://github.com/j4k0xb/webcrack/security/advisories/GHSA-ccqh-278p-xq6w
- https://nvd.nist.gov/vuln/detail/CVE-2024-43373
- https://github.com/j4k0xb/webcrack/commit/4bc5c6f353012ee7edc2cb39d01a728ab7426999
- https://github.com/j4k0xb/webcrack/blob/241f9469e6401f3dabc6373233d85a5e76966b54/packages/webcrack/src/unpack/bundle.ts#L79
Пакеты
webcrack
<= 2.14.0
2.14.1
Связанные уязвимости
webcrack is a tool for reverse engineering javascript. An arbitrary file write vulnerability exists in the webcrack module when processing specifically crafted malicious code on Windows systems. This vulnerability is triggered when using the unpack bundles feature in conjunction with the saving feature. If a module name includes a path traversal sequence with Windows path separators, an attacker can exploit this to overwrite files on the host system. This vulnerability allows an attacker to write arbitrary `.js` files to the host system, which can be leveraged to hijack legitimate Node.js modules to gain arbitrary code execution. This vulnerability has been patched in version 2.14.1.