Crafted container images and root filesystems stall or crash image scans
Description
A crafted image archive, registry image or root filesystem makes cdxgen -t docker, -t oci or -t rootfs spend minutes to hours of CPU, or abort on heap exhaustion, from inputs as small as a few hundred bytes. Image scans run with installs off and in secure mode, so neither prevents this, and in cdxgen --server the work blocks or ends the server process.
Details
The image's own metadata and file layout drive the cost: archive index entries, the config's environment, tar entry names, directory nesting, OS release fields and package records, certificate files and runtime files. The causes are unbounded expansion of values, quadratic loops over package records and files, and backtracking regular expressions.
| Input | Code | First affected release |
|---|---|---|
Duplicate index.json entries in an OCI archive (1.6 kB is enough to exhaust the heap) | resolveArchiveManifest() in lib/managers/docker.js | 12.3.0 |
Replacement patterns in the image config's Env (910 bytes exhaust the heap) | extractPathEnv() in lib/core/env.js | 11.2.2 |
| Tar entry names made of long runs of slashes | stripAbsolutePath() in lib/managers/docker.js | 11.0.8 |
Nested site-packages, .cargo or .composer directories | getPkgPathList() in lib/managers/docker.js | 3.0.0 |
A long VERSION_ID in etc/os-release, copied into every OS package purl | getOSPackages() in lib/managers/binary.js | 9.6.1 |
| A crafted maintainer line in an OS package record (regular expression) | parseOrganizationalContact() in lib/managers/binary.js | 12.4.0 |
| One init script listed by many packages, parsed once per package | createOSPackageServices() in lib/managers/binary.js | 12.4.0 |
| Many package records whose service properties are deduplicated by rescanning | dedupeServices() in lib/managers/binary.js | 12.4.0 |
Thousands of small PEM files labelled TRUSTED CERTIFICATE | applyTrustMaterialEnhancements() in lib/managers/binary.js | 13.5.0 (not in 12.x) |
Deep directory names that repeat lib/php | collectNativeExtensions() in lib/inventory/osPackageResolver.js | 13.6.0 (not in 12.x) |
A crafted deps.json in a .NET runtime directory (regular expression) | runtimePackFromDepsJson() in lib/inventory/dotnetRuntime.js | 13.6.0 (not in 12.x) |
Many Ruby-named files beside large rbconfig.rb files in one install prefix | readRubyBuildVersion() in lib/inventory/rubyBuildInfo.js | 13.6.0 (not in 12.x) |
Impact
Loss of availability for pipelines and services that scan images built by others, including golden-image and registry scanning jobs and cdxgen --server. No data is disclosed or modified.
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, is also affected by some of the issues above from 3.0.0 through 12.9.1, and no 12.x release contains the fix. Users of 12.x should move to @cdxgen/cdxgen 13.8.0 or apply the workarounds below. File paths in this advisory refer to the 13.x source tree; in 12.x most of the same functions are under lib/helpers/ or in lib/cli/index.js. The first affected release of each issue is in the table above.
Workarounds
- Scan images from untrusted sources with time and memory limits, in a process that does no other work.
- Run
cdxgen --serverunder a supervisor that restarts it, behind a reverse proxy with authentication.
Credit
These issues were found by Anthropic's OSS Scanner (scan cdxgen-20261108-009) and reported as ANT-2026-KZ16AIOE, ANT-2026-4LACUDDU, ANT-2026-1TRG52HT, ANT-2026-BGM30I0P, ANT-2026-C5B96LS9, ANT-2026-E49A5S56, ANT-2026-YNSZZ5CY, ANT-2026-19GYYXE3, ANT-2026-PW2SZXIT, ANT-2026-BSOAS4V4, ANT-2026-Z4WEVOW0, ANT-2026-NSSVPQ0A.