Arbitrary node_modules Directory Deletion in Google zx
Google zx
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| zx npm |
|
|
Original description
When zx is invoked with --prefer-local=<path>, the CLI creates a symlink named ./node_modules pointing to <path>/node_modules. Due to a logic error in src/cli.ts (linkNodeModules / cleanup), the function returns the target path instead of the alias (symlink path). The later cleanup routine removes what it received, which deletes the target directory itself. Result: zx can delete an external <path>/node_modules outside the current working directory.
From the CVE record · Google