C/C++ scans run a git filter from the scanned tree's own .git/config
Description
When a scanned C/C++ tree has a .gitmodules file, cdxgen runs git submodule status --recursive in it. If the tree arrives with its own .git directory, git can run a clean filter defined in that tree's .git/config through sh -c, so the tree's author gets a command run as the user running cdxgen. This works with -t c, -t cpp, untyped scans and the server's /sbom?path=, also with --no-install-deps and --lifecycle pre-build.
Details
collectSubmoduleStatus() in lib/ecosystems/cmakeResolver.js runs the command through execGitCommand(). Its -c overrides fix core.fsmonitor, core.hooksPath and the gpg programs, but they cannot fix filter.<name>.clean, because the repository chooses the filter name in .gitattributes. Unlike cdxgen's other git calls, submodule status compares work-tree files with the index, and for entries git considers racily clean it hashes the file again through the configured clean filter.
The tree controls every condition, but three things narrow the attack:
- The tree must keep its
.gitdirectory and file modification times, for example an unpacked tar or zip archive, acp -acopy or a restored cache. Repositories obtained withgit cloneare not affected, so the server's git URL option and cdx-audit are not affected. - The tree must be owned by the scanning user or be covered by
safe.directory. - Secure mode skips the call, and
--dry-runblocks it.
Impact
Command execution with the privileges and environment of the cdxgen process for whoever supplies a source archive or directory that cdxgen scans, in configurations where nothing else in the scan runs project code.
Patches
Fixed in @cdxgen/cdxgen 13.8.0. Versions 13.0.0 through 13.7.0 of @cdxgen/cdxgen are affected. The 12.x line, published as @cyclonedx/cdxgen, does not contain the affected code.
Workarounds
- Use
CDXGEN_SECURE_MODE=true. - Remove the
.gitdirectory from untrusted archives before scanning, or scan a freshgit cloneinstead of an unpacked tree.
Credit
This issue was found by Anthropic's OSS Scanner (scan cdxgen-20261108-009) and reported as ANT-2026-9YVEQ257.