Skip to main content
Menu
Advisories

Command injection through atom when generating evidence for an untrusted repository

GHSA-MH5C-4CV8-GH6CPublished Updated GitHub

Description

To generate evidence, cdxgen runs the bundled atom analyzer on the scanned directory. Values that come from the scanned repository reach shell command strings that atom builds and runs with sh -c, so the repository's author can run commands as the user running cdxgen. This works with --no-install-deps, in secure mode, and with a CDXGEN_ALLOWED_COMMANDS list, because the shell is started by atom and not by cdxgen. The scan exits 0 and writes a normal BOM.

Details

There are two routes.

Config file in the working directory. A .cdxgen.json (or .cdxgenrc, .cdxgen.yml, .cdxgen.yaml) may set evidence, usages-slices-file, openapi-spec-file and output, and cdxgen only checks that the paths stay inside the config file's directory. createSlice() in lib/evinser/evinser.js asks atom for --extract-endpoints, and atom then runs atom-tools convert through sh -c with the slices file name pasted in unquoted, so shell syntax in a file name inside the repository is executed. For Ruby scans the config file's exclude entries are copied by buildAtomCommandEnv() into CHEN_IGNORE_DIRS, which atom pastes into another shell string. The only screen on these values, UNSAFE_SHELL_CHARS_RE in lib/inventory/atomUtils.js, is written for the Windows shell. Config files are read from the working directory, so this route needs cdxgen to be started inside the checkout; the config file can turn evidence on by itself.

atom's own project configuration. cdxgen does not pass --config to atom, so atom loads atom.json, .atom/atom.json or .atom/config.json from the directory it analyzes and merges its frontend.<language> options. The JavaScript frontend appends its astgen-out value unquoted to an sh -c command line, and the Ruby frontend does the same with exclude-regex. Both functions that start atom for evidence, createSlice() in lib/evinser/evinser.js and findAppModules() in lib/inventory/atomUtils.js, are affected.

The shell strings themselves belong to atom. cdxgen's part is passing repository-controlled values to atom without checking them, and letting atom read configuration from the scanned tree.

Impact

Any path that turns on evidence generation is affected: --evidence, the research, threat-modeling and ml-deep profiles, the cbom and saasbom commands, and evinse. The author of a scanned repository or pull request can run commands with the scanning job's privileges and environment, for example to read CI secrets. cdxgen --server does not run this step and is not affected.

Versions of the 12.x line bundle @appthreat/atom 2.5.6. That release runs atom-tools convert and rbastgen through sh -c in the same way, and the config-file route was reproduced against @cyclonedx/cdxgen 12.9.1. atom 2.5.6 has no project configuration loader and reads no atom.json, so the second route does not apply to releases that bundle it.

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 9.5.0 through 12.9.1 and is fixed in @cyclonedx/cdxgen 12.9.2 (pull request #4791). Because 12.x bundles atom 2.5.6, the backport differs from the 13.x fix: before cdxgen asks atom for --extract-endpoints, it checks that the slices file, language, OpenAPI format, work directory and spec file name contain no character a shell would interpret, and otherwise skips endpoint extraction with a warning. Excluded directory names with such characters are left out of CHEN_IGNORE_DIRS, and the Ruby frontend is not started on a source path with such characters. As in 13.8.0, evidence can only be set by the operator: a config file that sets it is ignored with a warning, and a profile or technique taken from a config file no longer turns evidence on. 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.

First affected release of each issue:

  • config-file values passed to atom: 11.2.3
  • atom project configuration in the scanned tree: 9.5.0

Workarounds

  • Do not generate evidence for untrusted repositories.
  • Start cdxgen from outside the checkout and pass the path, so that config files in the repository are not read.
  • Delete atom.json, .atom/ and cdxgen config files from untrusted checkouts before scanning.

Credit

These issues were found by Anthropic's OSS Scanner (scan cdxgen-20261108-009) and reported as ANT-2026-AS19W66G, ANT-2026-X0EWKAAR.

References

Affected versions

References

GitHub · cdxgen/cdxgen