The vulnerability, CVE-2026-71538, describes a shell injection flaw in @cyclonedx/cyclonedx-npm on Windows when the --workspace argument is used. The root cause is identified as the CLI's fallback execution path on Windows, which constructed a shell command using untrusted input without proper sanitization. The provided patch (commit 15d3beb5bcd2b0b6eccfdf31192f5103b3f12c0f) clearly shows modifications in src/npmRunner.ts that directly address this issue.
Specifically, the NpmRunner.#makeNpmRunner function was identified as the vulnerable component. Before the patch, this function contained logic to execute npm commands. On Windows, if the determined execPath was a command script (e.g., .cmd or .bat), it would invoke execFileSync('cmd.exe', ['/c', execPath, ...args], options). The use of cmd.exe /c is critical here, as it instructs the command interpreter to execute the following string as a command. This allowed an attacker to inject arbitrary shell commands via the --workspace argument, which would become part of ...args or even execPath if influenced, and then be interpreted by `cmd.exe.
The patch mitigates this by:
- Removing the specific
cmd.exe /c execution path.
- Refactoring how the
npm executable path is determined to be more robust and less prone to shell interpretation.
- Explicitly setting
shell:false in the execFileSync calls, which prevents the command from being executed through a shell, thus eliminating the injection vector.
Therefore, NpmRunner.#makeNpmRunner is the function that directly facilitated the shell injection due to its unsafe command construction and execution on Windows prior to the fix.