Network-path URLs keep their credentials in BOM text such as recorded CI commands
Description
cdxgen removes the userinfo, query string and fragment of URLs in text it copies into a BOM, such as the commands of CI workflow steps. The fix that makes it do so in 13.8.0 (GHSA-4cc7-jx94-rr7r) recognised only URLs written as scheme://. A network-path reference without a scheme (RFC 3986 section 4.2), such as //user:password@host/path, kept its credentials. The gap was found and reported before 13.8.0 was released, and 13.8.0 contains the fix for both forms.
Details
stripUrlCredentials() in lib/core/propertySanitizer.js looked for :// and returned any text without it unchanged. It is the function behind sanitizeBomText() and sanitizeBomPropertyValue(), so every component property and every formulation command went through it. sanitizeBomUrl() and sanitizeBomReferenceUrl() did not treat a value starting with // as a URL either.
A GitHub Actions workflow with this step shows the effect when the repository is scanned with formulation, which cdxgen collects by default in CI (CI=true), with --bom-audit, and with --include-formulation:
- run: npm publish --registry=//deploy:s3cr3t@pkgs.internal/npm/The password appeared in the component property cdx:github:step:command and in formulation[].workflows[].tasks[].steps[].commands[].executed. The same step written with https://deploy:s3cr3t@pkgs.internal/npm/ was redacted.
Releases before 13.8.0 record these commands without removing the credentials of any URL, whatever its form. That is GHSA-4cc7-jx94-rr7r, and the ranges below are the same releases of the 12.x and 13.x lines that record step commands. This advisory records that the network-path form needed its own handling and credits the report.
Impact
A credential written literally into a committed CI file, in the network-path form, is copied into the BOM, so anyone who receives the BOM can read it even if they cannot read the repository. Most tools do not accept a registry or index URL without a scheme, so such lines are uncommon, and credentials that are passed through CI secrets or variables, as in ${{ secrets.TOKEN }}, are not affected.
Patches
Fixed in @cdxgen/cdxgen 13.8.0 by commit a559f449a187402311d9ec926244540fe27fc539 (#4790). Two slashes are now read as the start of a URL when they begin the text or follow white space, =, a quote, (, , or <, and the userinfo before @ holds a :. Comments such as // see user@example.com, regular expressions and a bare //name@host are left as written. A value that is a whole network-path reference loses its userinfo, query and fragment in sanitizeBomUrl() and sanitizeBomReferenceUrl(), also when the userinfo has no :. The scan stays linear in the length of the text.
The 12.x line, published as @cyclonedx/cdxgen, gets no fix. Users of 12.x should move to @cdxgen/cdxgen 13.8.0.
Workarounds
- Keep credentials out of committed CI files and pass them through the CI system's secrets.
- Pass
--no-include-formulationwhen the BOM is shared outside the team that owns the repository. - Review the formulation section of a BOM before sharing it.