Skip to main content
Menu
Advisories

Crafted ASAR archive makes cdxgen write files outside the extraction directory

GHSA-72JC-54PR-QQ5WPublished Updated GitHub

Description

When cdxgen scans an Electron ASAR archive, a crafted archive header can make extractAsarArchive() create or overwrite any file the cdxgen process can write, anywhere on disk, with content and executable bit chosen by the archive. With formulation on (--include-formulation, or by default under CI=true from 13.7.0) and a user-writable directory ahead of the real git on PATH, as on common hosted CI runners, cdxgen later runs a planted file in the same scan.

Details

extractAsarArchive() in lib/ecosystems/asarutils.js checks that each destination is inside the temporary extraction directory with isPathWithin(), which compares path strings. It then calls mkdirSync() with recursive, symlinkSync(), writeFileSync() and chmodSync() without looking at what already exists at that path.

Header names that contain lone UTF-16 surrogates are distinct keys while the header is validated, but Node.js writes every lone surrogate as U+FFFD, so two such names refer to the same file on disk. A link entry creates a symbolic link under one name, a later directory entry with the colliding name succeeds on that link, and entries below it are created through the link. A second link whose relative target was computed for the intended location then points outside the extraction root.

The ASAR project type must be selected (-t asar, or an input path that ends in .asar). In server mode the same code is reached with /sbom?type=asar, for a path or for a git URL, so no file on the server is needed.

Impact

Arbitrary file creation and overwrite as the user running cdxgen, which leads to code execution through planted executables, shell start-up files or tool directories on PATH. Command-line and CI scans of untrusted .asar files are affected, as is any client that can reach cdxgen --server. --no-install-deps and CDXGEN_SECURE_MODE=true without the Node.js permission flags do not prevent it. --dry-run and the Node.js permission model (as configured in the cdxgen-secure image, which only allows writes to temporary and output directories) do.

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 affected from 12.4.0 through 12.9.1 and is fixed in @cyclonedx/cdxgen 12.9.2, which backports the same change to lib/helpers/asarutils.js (pull request #4791). 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.

Workarounds

  • Scan untrusted Electron applications only with --dry-run, or under the Node.js permission model with --allow-fs-write limited to the temporary and output directories, for example with the cdxgen-secure image.
  • Do not allow type=asar on servers reachable by untrusted clients.
  • Run such scans as a user that cannot write to directories on PATH.

Credit

This issue was found by Anthropic's OSS Scanner (scan cdxgen-20261108-009) and reported as ANT-2026-ZVECAU47.

References

Affected versions

References

GitHub · cdxgen/cdxgen