Description
better-npm-audit through 3.11.0, and the 4.0.0-rc.2 prerelease, builds its npm audit command by interpolating the user-supplied --registry option into a command string in src/handlers/handleInput.ts without validation or quoting, then passes that string to child_process.exec() in index.ts, which spawns a shell. A registry value containing shell metacharacters such as a semicolon, pipe, or command substitution executes arbitrary operating system commands with the privileges of the process running the audit.
Affected products
| Vendor | Product | Affected | Fixed |
|---|---|---|---|
| jeemok | better-npm-audit | ≤ 3.11.0, 4.0.0-rc.2 | — |
References
- GitHub Issue #119 issue-tracking
- https://github.com/jeemok/better-npm-audit product
- https://github.com/jeemok/better-npm-audit/blob/fd99a0f41ff4342b8a0a6fdbe5a17261de3d0544/src/handlers/handleInput.ts#L30-L37 technical-description
- https://github.com/jeemok/better-npm-audit/blob/fd99a0f41ff4342b8a0a6fdbe5a17261de3d0544/index.ts#L34 technical-description
- https://github.com/jeemok/better-npm-audit/pull/120 issue-tracking patch
- VulnCheck Advisory: better-npm-audit OS Command Injection via registry flag third-party-advisory