CVE-2026-71538: @cyclonedx/cyclonedx-npm Windows Shell Injection via --workspace
The cyclonedx-npm CLI passes the --workspace argument directly into a Windows shell command without escaping, letting anyone who controls that value run arbitrary OS commands on the host.
The problem
The @cyclonedx/cyclonedx-npm tool generates CycloneDX SBOMs from npm projects. All versions before 6.0.0 contain a Windows-specific OS command injection flaw.
When npm_execpath is not set to a valid npm CLI path, src/npmRunner.ts falls back to constructing a shell command string and passing it to cmd.exe. The --workspace value is interpolated into that string raw, with no escaping or sanitization. Shell metacharacters in the workspace name are executed by the shell with the privileges of the invoking user.
Proof of concept
A working proof-of-concept for CVE-2026-71538 in @cyclonedx/cyclonedx-npm, with the exact payload below.
npx @cyclonedx/cyclonedx-npm --workspace "foo & calc.exe" .The root cause is in src/npmRunner.ts. The Windows fallback code path builds a shell command string by concatenating the raw --workspace value into it, then passes the whole string to cmd.exe /c. On Windows, & and && are command separators recognized by cmd.exe, so a crafted workspace name like foo & calc.exe causes the shell to execute calc.exe (or any other command) as a second token.
The fix in PR #1489 removes the shell-string construction entirely. npm is now invoked directly as a child process with arguments passed as an array, so metacharacters in the workspace value are never interpreted by a shell. This matches the standard mitigation for CWE-78: avoid shell interpolation and use argument arrays instead.
The fix
Upgrade to @cyclonedx/cyclonedx-npm version 6.0.0 or later. As a short-term workaround on older versions, set the npm_execpath environment variable to the path of npm-cli.js before invoking the tool; this bypasses the vulnerable Windows fallback path. Do not pass untrusted or user-controlled values to --workspace.
Reported by jkowalleck (Jan Kowalleck, CycloneDX maintainer).
Related research
- high · 7.5CVE-2026-59960CVE-2026-59960: @argos-ci/core CI Branch Name OS Command Injection
- high · 8.8CVE-2026-73222CVE-2026-73222: claude-code-templates Unauthenticated OS Command Injection (RCE) in Studio Server
- high · 8.4CVE-2026-55157CVE-2026-55157: @ooples/token-optimizer-mcp OS Command Injection via smart_user username
- high · 7.8CVE-2026-15895CVE-2026-15895: jsii-diff OS Command Injection via npm: Package Argument