npm · @cyclonedx/cdxgen
@cyclonedx/cdxgen: Maven project scanning may allow shell command injection through repository-controlled module paths
A command injection vulnerability existed in the Maven scanning flow of cdxgen before version 12.4.3.
When cdxgen scanned an attacker-controlled Maven project, repository-controlled paths could be used in the Maven command construction. In affected versions, some Maven invocations were executed with shell: true. A directory name containing shell metacharacters could therefore be interpreted by the shell instead of being treated only as a filesystem path.
This could allow an attacker who controls a scanned repository to execute commands in the cdxgen process context.
The issue affected both the CLI and server mode. The issue is patched in 12.4.3.
POST /sbomVersion 12.4.3 includes hardening for this issue with PR #4059
The patch adds multiple mitigations:
shell: isWin where needed.safeSpawnSync now blocks shell: true invocations when the command or direct argument values contain shell metacharacters.The recommended remediation is to upgrade to 12.4.3 or later.
If immediate upgrade is not possible:
Use cdxgen secure/dry-run modes where suitable to inspect planned operations before performing scans. Configure host and command allowlists where applicable, such as:
These mitigations reduce exposure but do not fully address the vulnerable command construction in affected versions.
The mitigation added in 12.4.3 applies to the cdxgen process boundary. Specifically, cdxgen now hardens command, option, and path values that cdxgen itself passes to external processes through safeSpawnSync.
This does not mean cdxgen sanitizes every nested path, module name, generated path, or project-controlled value that an external build tool later discovers and interprets inside its own process. Once cdxgen safely invokes Maven, Gradle, Bazel, SBT, or another build tool, that tool’s internal behavior remains a separate trust boundary.
This residual risk is documented in the cdxgen threat model and is why untrusted project scans should still be run in sandboxed, least-privileged environments.
Possible indicators of exploitation or probing include:
;
&
|
<
>
$
backticks
newlines
Example suspicious path pattern:
evil;cd${IFS}..;cd${IFS}..;printf${IFS}...>...;#
Reported-By: @aleff-github
Is your project exposed to this? Stateward checks every dependency on every pull request and flags it only if your code actually reaches it.
Check my repoSources: CISA KEV (public domain), OSV.dev & GitHub Advisory Database (CC-BY-4.0), FIRST EPSS, NVD/CWE (public domain). Served live from the Stateward advisory database.