# Threat Model This document describes the threat model for cdxgen — a polyglot CycloneDX BOM generator that produces SBOM, CBOM, HBOM, OBOM, SaaSBOM, CDXA, and VDR documents. It identifies threat actors, attack surfaces, trust boundaries, and mitigations across cdxgen's components: CLI, library, HTTP server, REPL, CI/CD infrastructure, container images, dependencies, the optional pure-ESM `@cdxgen/cdx-hbom` host collector, and the optional native helper binaries supplied through `cdxgen-plugins-bin`. ## System Overview cdxgen generates CycloneDX Bill-of-Materials (BOM) documents — including SBOM, CBOM, HBOM, OBOM, SaaSBOM, CDXA, and VDR — by parsing project manifests/lockfiles and optionally invoking external build tools. It also opportunistically uses the optional pure-ESM `@cdxgen/cdx-hbom` package for live hardware inventory on supported hosts, plus optional helper binaries from `cdxgen-plugins-bin` such as Trivy (container/rootfs OS inventory), osquery (live-OS OBOM), trustinspector (filesystem/signing/trust inventory), SourceKitten, and dosai. It operates in six modes: 1. **CLI** (`bin/cdxgen.js`) — Command-line invocation on local projects 2. **Library** (`lib/cli/index.js`) — Programmatic use via `createBom(path, options)` 3. **HTTP Server** (`lib/server/server.js`) — REST API accepting scan requests, optionally with Git clone 4. **REPL** (`bin/repl.js`) — Interactive shell for ad-hoc BOM operations 5. **Evinse** (`bin/evinse.js`) — Evidence generation for SBOM verification (analyzes call stacks, data flows, and usages) 6. **Verify** (`bin/verify.js`) — BOM signature verification using the JSON Signature Format (JSF) ## Trust Boundaries ``` ┌─────────────────────────────────────────────────────────────────────┐ │ User Environment │ │ ┌───────────┐ ┌────────────┐ ┌──────────────┐ ┌─────────────┐ │ │ │ CLI / REPL│ │ Library │ │ HTTP Server │ │ CI Runner │ │ │ └─────┬─────┘ └─────┬──────┘ └──────┬───────┘ └──────┬──────┘ │ │ │ │ │ │ │ │ ══════╪══════════════╪════════════════╪═════════════════╪══════ │ │ Trust boundary 1: cdxgen code ←→ external build tools │ │ │ │ │ │ │ │ ┌─────▼─────────────────────────────────────────────────────────┐ │ │ │ External Build Tools and Helper Binaries │ │ │ │ npm, maven, gradle, pip, go, cargo, dotnet, trivy, osquery… │ │ │ └─────┬─────────────────────────────────────────────────────────┘ │ │ │ │ │ ══════╪════════════════════════════════════════════════════════════│ │ Trust boundary 2: local system ←→ remote registries/hosts │ │ │ │ │ ┌─────▼─────────────────────────────────────────────────────────┐ │ │ │ Package Registries & Remote Hosts │ │ │ │ npmjs.org, maven.org, pypi.org, crates.io, ... │ │ │ └───────────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────┘ Trust boundary 3: HTTP server ←→ external HTTP clients Trust boundary 4: cdxgen process ←→ host operating system / filesystem Trust boundary 5: cdxgen container ←→ container host ``` ## Threat Actors | Actor | Capability | Motivation | | ----------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | **Malicious project author** | Controls manifest files, lockfiles, build scripts, `.npmrc`, `.mvn/`, `setup.py`, etc. | Supply-chain attack: execute code on machines that scan their project | | **Network attacker (MITM)** | Intercepts HTTP traffic between cdxgen/build tools and registries | Inject malicious package metadata, steal credentials, tamper with SBOMs | | **Malicious HTTP client** | Sends crafted requests to the cdxgen server | Path traversal, SSRF, denial of service, Git clone exploits | | **Environment manipulator** | Controls environment variables in the cdxgen process | Command injection via `NODE_OPTIONS`, credential theft, behavior alteration | | **Compromised dependency** | A direct or transitive npm dependency of cdxgen is compromised | Arbitrary code execution in the cdxgen process at import time | | **Compromised helper binary** | Controls or replaces an auxiliary native binary executed by cdxgen | Tamper with scan results, execute unexpected code, exfiltrate host data | | **Compromised CI/CD** | Access to GitHub Actions workflows or self-hosted runners | Tamper with releases, inject malicious code into published artifacts | ## Threats and Mitigations by Component ### 1. CLI and Library (`bin/cdxgen.js`, `lib/cli/index.js`) #### T1.1 — Command injection via project files **Threat:** Attacker-controlled values from manifests or lockfiles (package names, versions, URLs) are passed to `safeSpawnSync` in a way that escapes command boundaries. **Mitigations:** - `safeSpawnSync` uses array-based arguments (not shell strings) via `spawnSync`, preventing shell metacharacter injection - `safeSpawnSync` blocks `shell: true` invocations when the command or direct argument values contain shell metacharacters - Dry-run/debug activity summaries flag discovered direct paths containing shell metacharacters so operators can review suspicious repository-controlled names before invoking external build tools - Command allowlisting via `CDXGEN_ALLOWED_COMMANDS` — only explicitly permitted commands can execute - In secure mode, automatic package installations are disabled, reducing the set of commands invoked - `commandsExecuted` tracks all invoked commands for post-run audit **Scope note:** These mitigations cover commands, options, and path values that cdxgen itself passes to external processes through `safeSpawnSync`. They do not sanitize every nested project path, module name, or generated path that an external build tool later discovers and interprets inside its own process. That behavior belongs to the separate cdxgen ↔ external build tool trust boundary. **Residual risk:** Medium — cdxgen invokes many different commands with project-derived arguments, and external build tools may further interpret project-controlled files and paths after cdxgen has safely crossed its own process boundary. Continuous review is needed as new language support is added. #### T1.2 — Arbitrary code execution via build tools **Threat:** cdxgen invokes `npm install`, `mvn`, `pip install`, `gradle`, etc. These tools execute code from project files (postinstall scripts, `setup.py`, Gradle build scripts, `.mvn/jvm.config`, `Directory.Build.rsp`, SwiftPM manifests, `project.clj`, Podfiles and podspecs, `.cargo/config.toml`, `build.rs`). **Mitigations:** - Secure mode (`CDXGEN_SECURE_MODE=true`, the `cdxgen-secure` command and image) turns installs off by default - With installs off, cdxgen does not run the scanned project's own build tooling (see the next section) and parses manifests and lock files instead - A config file in the working directory, a profile or a lifecycle cannot turn installs back on when the operator turned them off, and in secure mode only `--install-deps` on the command line or `CDXGEN_INSTALL_DEPS=true` can - In secure mode a C/C++ compilation database is read only when the operator names one with `--compile-commands` or `CDXGEN_COMPILE_COMMANDS`. A `compile-commands` set by a config file in the working directory is ignored with a warning, since the file can come with the code just as the database can - A config file (`.cdxgenrc`, `.cdxgen.json`, `.cdxgen.yml` or `.cdxgen.yaml`) in the working directory may set only the options listed in `PROJECT_CONFIG_OPTIONS` in `lib/core/projectConfig.js`. It cannot choose an executable (`--scalasem-command`), start the server, turn off certificate checks for Dependency-Track uploads, enable feature flags, or open the terminal interface (`--tui`), and every key that is not a declared option is ignored. That covers options only library callers pass, such as `dosaiCommand` and `traceCmd`, and yargs' `extends` key, which would otherwise load a module or another config file named in the file. Project types that inventory the host, such as `os`, `hbom` or `vscode-extension`, and names cdxgen does not know as project types are dropped from the file's `type`. The file cannot turn on evidence collection, which hands project-named values to atom, either with `evidence` or through a profile or technique, and its `operational` profile does not add the `os` type, and formulation or crypto collection that only the file asked for leaves the host's crypto libraries, certificates, authorized keys and keychain items out of the formulation section. It cannot name a slices file either, since cdxgen reads an existing one back as the project's evidence, and a license policy it names is announced - A `server-url` that only the config file names is ignored, with a warning, when the Dependency-Track API key comes from the command line or the environment (`--api-key` or `CDXGEN_API_KEY`), so the operator's key does not reach a server the scanned project chose - The automatic `npm install` of a project without a lockfile refuses a project `.npmrc` that sets `script-shell`, `shell`, `git`, `global`, `prefix`, `node-options`, `userconfig`, `globalconfig` or another key that changes which program npm starts or where it installs. The keys `proxy`, `https-proxy`, `cafile`, `ca` and `strict-ssl` do not stop the scan. They belong to the operator, because a project `.npmrc` outranks the operator's user config and would otherwise route the operator's registry token through a proxy or certificate authority the project chose. cdxgen ignores them with a warning that names the keys and the file, and starts npm with `npm_config_*` variables that npm reads above every `.npmrc`: a variable the operator already exports is kept, then the value from the operator's user `.npmrc`, then the npm default (no proxy, strict TLS, and the certificate authorities Node.js trusts by default, written to a temporary `cafile` that is removed after the install). A registry or scope prefixed spelling such as `//host/:cafile` is still refused, and so are the five keys when the project is installed with pnpm or yarn - A directory of BOM audit rules (`--bom-audit-rules-dir`, `CDXGEN_BOM_AUDIT_RULES_DIR`) is read only when the operator names it. A `bom-audit-rules-dir` in a config file in the working directory is ignored with a warning, and the server takes no such parameter from a request, because the JSONata conditions of a rule run synchronously and a project could use them to keep the scan busy - `safeSpawnSync` warns when `pip`/`uv install` is invoked without `--only-binary=:all:` (prevents `setup.py` execution during wheel builds). The flag applies to requirements looked up in an index. pip builds a project directory, archive, URL or editable requirement named on its command line whatever the flag says, so in secure mode cdxgen does not run pip for a `pyproject.toml` or `setup.py` project, or for a requirements file (included files too) that names an editable install, a local directory or archive, a source archive or version control URL, `--no-binary`, or an `--only-binary` value other than `:all:`. It prints a warning and reads the dependencies from the files instead - `safeSpawnSync` warns when Python is invoked without `-S` flag - Users are advised to run in sandboxed environments for untrusted projects **Which tools run with installs off:** installs are off in secure mode unless `--install-deps` is passed, with the `cdxgen-secure` command, with `--no-install-deps`, with `--lifecycle pre-build`, with `--profile ml-tiny`, in dry-run mode and for container scans. cdxgen then skips: - Maven, including the project's `mvnw`, the `--evidence` jar collection and atom's Maven class path step (evinse passes `delombok-mode=no-delombok` to atom) - Gradle, sbt and Mill build evaluation and their wrappers, scala-cli and scalasem builds - Leiningen (`lein deps :tree-data`) - `poetry export` and `pdm export` - `dotnet msbuild` property evaluation - SwiftPM: `swift package dump-package`, `show-dependencies`, `resolve` and the evidence build; compiler plugin flags, `-vfsoverlay` and `-sdk` read from an existing `.build` directory are dropped (on macOS the SDK path implies a plugin directory and plugin server), and the host toolchain's SDK is used instead - CocoaPods: `pod ipc podfile-json` and `pod ipc spec` on Ruby podspecs (JSON podspecs are read directly) - Rust: `cargo check` and rusi under `--deep` or `--evidence`; `cargo metadata` runs from the temporary directory with `--offline`, so the project's `.cargo/config.toml` and `rust-toolchain.toml` do not apply - Ruby: `bundle exec` for gem module names The toolchain version probes for formulation also run from the temporary directory, so files such as `global.json` and `rust-toolchain.toml` cannot pick the binary. Tools that read without running project code still run, for example `go list` and `go mod graph`, which download modules through `GOPROXY` and, for modules the proxy does not serve, from the host the module path names. Set `GOPROXY=off` to keep such a scan offline. `CDXGEN_ALLOWED_COMMANDS` is a separate allowlist that applies in any mode. `--introspect`, given on the command line or as `CDXGEN_INTROSPECT=true`, keeps this tooling running with installs off outside secure mode, because introspection exists to observe the project's own toolchain. The same setting from a config file does not. Each skip prints a message once per scan, and the skips that change the SBOM record a `*.tooling-disabled` event for the introspection report. **Residual risk:** High. Accurate dependency resolution often requires invoking build tools that may execute untrusted code, and `--install-deps` or `--introspect` turn that back on. With the project tooling skipped, the SBOM contains only what static parsing of the manifests and lock files can recover; for Maven that is the direct dependencies of each pom, with versions from its properties, its dependencyManagement and parent poms inside the scanned directory. #### T1.3 — Environment variable poisoning **Threat:** Attacker sets `NODE_OPTIONS` with `--require` or `--eval` to inject code, or manipulates `JAVA_TOOL_OPTIONS`, `NODE_PATH`, proxy variables, or TLS settings. **Mitigations:** - `auditEnvironment()` runs at startup and detects: - Code execution patterns in `NODE_OPTIONS` (`--require`, `--eval`, `--import`, `--loader`, `--inspect`) - JVM agent injection in `MVN_ARGS`, `GRADLE_ARGS`, `JAVA_TOOL_OPTIONS` - Module resolution poisoning via `NODE_PATH` - Disabled TLS verification (`NODE_TLS_REJECT_UNAUTHORIZED=0`) - Credential-like variables - Debug mode exposure - Running as root outside containers - Proxy interception variables - Findings are reported with severity ratings and remediation guidance - The container images that bundle a JDK set `JAVA_TOOL_OPTIONS` to `-XX:+IgnoreUnrecognizedVMOptions -XX:-UseBASE64Intrinsics`, which turns off the HotSpot Base64 intrinsic that Java4Shell (CVE-2026-114938) overflows on x86-64 CPUs with AVX-512 VBMI. The JVM tools cdxgen runs on a scanned project (Maven, Gradle, sbt) can be pointed at an attacker's repository server by a `pom.xml`, `settings.xml` or build script, which is the client-side shape of that defect. Hosts that run cdxgen outside the images get a one-line warning when the JDK is 17.0.6 or later, the CPU has AVX-512 VBMI and no `-XX:-UseBASE64Intrinsics` is set. The workaround and its limits are described in `docs/ADVANCED.md`. **Residual risk:** Medium — `auditEnvironment` is pattern-based and may not catch novel obfuscation. An attacker who can set environment variables often already has significant access. #### T1.4 — Path traversal via file inputs **Threat:** Attacker crafts file paths with `../`, Unicode tricks, or Windows device names to read or write outside the intended project directory. **Mitigations:** - `hasDangerousUnicode()` detects bidirectional control characters, zero-width characters, and other obfuscation - `cdx-verify`, `cdx-sign`, `cdx-validate`, the `cdx-audit` progress line and license policy errors write control characters and U+2028/U+2029 taken from a document, a package name or a path as `\uXXXX` escapes, so a crafted BOM cannot move the cursor or rewrite what the terminal shows - `isValidDriveRoot()` prevents Unicode lookalike drive letters on Windows (CVE-2025-27210 mitigation) - Node.js `--permission` model (in secure mode) restricts filesystem access to explicitly allowed paths - `safeExistsSync` and `safeMkdirSync` check permissions before operations - Path options in a config file, whether spelled out or set through an alias such as `o`, must resolve inside the config's directory after symbolic links are resolved. A value with a `..` segment is refused, because the file system follows a link before it takes the parent - `safeWriteSync()` does not write through a symbolic link in the last component of the path. A link such as a `bom.json` committed to the scanned repository is replaced with a regular file, and the open uses `O_NOFOLLOW` where the platform has it. Node's permission model follows such links to paths outside its grants, so this also applies in secure mode. The standard streams and descriptor paths (`/dev/stdout`, `/dev/stderr`, `/dev/fd/`, `/proc/self/fd/`) are written as given. Other paths under `/dev` and `/proc`, such as `/dev/shm/...` and `/proc/self/cwd/...`, get no exception. Links in parent directories are still followed - `safeCopyFileSync()` treats a symbolic link in the last component of its destination the same way. A link committed under a name cdxgen copies to, such as the `project/plugins.sbt.cdxgen` backup made before running sbt, is replaced with a regular file created with `COPYFILE_EXCL`, so neither the content nor the mode of the source reaches the file the link pointed at - `getAllFiles()` returns a file only when its real path is inside the directory searched, or inside the exploded image during a container scan. A manifest that is a symbolic link to a file elsewhere, such as a `requirements.txt` pointing at `/proc/self/environ`, a file reached through a linked directory, and a match of a workspace pattern with `..` or an absolute path are skipped with a warning instead of being read into the BOM. So is a link to a file the search ignores, such as `.git/config`, which holds the credentials of a CI checkout. Node's permission model follows such links too, so this also applies in secure mode. Outside secure mode the operator can set `CDXGEN_FOLLOW_EXTERNAL_SYMLINKS=true` for a trusted tree whose links leave it on purpose, such as one member of a pnpm workspace. Files a builder opens by a fixed name next to a manifest do not go through this check - `safeChmodSync()` changes the mode of regular files only and does nothing in a dry run. A `gradlew`, `mvnw` or `mill` committed to the scanned repository as a symbolic link is not made executable, so the file or directory it points at keeps its mode; the mode is set through a descriptor opened with `O_NOFOLLOW` where the platform has it - The evidence analyzers do not write through such a link either. golem and rusi write their report into a temporary directory of the run, and cdxgen copies it to the `--semantics-slices-file` path with `safeWriteSync()`. atom and dosai keep their atom and slices files next to the BOM or in the scanned directory for reuse, so cdxgen removes a symbolic link found at those paths right before the tool runs (`safeRemoveOutputLinkSync()`). Working files a tool names itself, such as atom's `.chen` cache, are not covered **Residual risk:** Low in secure mode, Medium in default mode. #### T1.5 — Remote source scanning via git URL and purl inputs **Threat:** A user (or wrapper tool) supplies a malicious git URL or purl that resolves to an unsafe repository. **Mitigations:** - CLI and server both use shared source validation (`validateAndRejectGitSource()`) and hardened clone behavior - Protocol allowlisting via `GIT_ALLOW_PROTOCOL` / `CDXGEN_GIT_ALLOW_PROTOCOL` - Host allowlisting via `CDXGEN_GIT_ALLOWED_HOSTS` (or `CDXGEN_SERVER_ALLOWED_HOSTS` in server mode). While an allowlist or secure mode applies, git runs with `http.followRedirects=false`, so an allowed host cannot redirect a clone or `ls-remote` to a host the allowlist does not name - Temporary clone directories are removed after scan completion - purl resolution emits an explicit warning that registry metadata may be untrusted **Residual risk:** Medium — trust is delegated to external registry metadata and remote repository hosting unless strict allowlists are configured. #### T1.6 — User-controlled pattern complexity in CLI options **Threat:** An operator supplies highly complex glob or regular-expression patterns through CLI/configuration options such as `--exclude`, `--include-regex`, `--exclude-regex`, `ASTGEN_IGNORE_FILE_PATTERN`, or related ignore-pattern environment variables, causing excessive CPU use during local matching or downstream frontend filtering. **Security boundary:** These patterns are considered trusted operator input in CLI, REPL, and library usage. ReDoS or other algorithmic-complexity behavior that depends on a user intentionally supplying pathological command-line arguments or environment variables is not treated as a cdxgen security vulnerability. This scope note does not apply to regexes or patterns derived from untrusted remote clients, registry metadata, manifests, lockfiles, or scanned project content without explicit operator opt-in. **Mitigations:** - cdxgen avoids shell interpretation for these values and treats them as filtering patterns only - Directory-oriented excludes are additionally forwarded as literal directory names for performance where supported by Atom and astgen - Server deployments should validate or constrain request options at the API boundary if untrusted clients can submit scans - Patterns from untrusted sources pass through `boundUntrustedGlobPatterns()` in `lib/core/globPatterns.js`: each may be at most 512 characters, and a list may stand for at most 128 patterns after brace expansion and after glob has split the `..` segments from the `**` segments before them, with a comma separated pattern counted once for each entry the evidence filters read from it. The server refuses a request whose `exclude` patterns use braces or break either limit. A config file in the scanned directory may use braces, but its `exclude` and `include-regex` patterns share the 128-pattern budget, and those past it are dropped with a warning **Residual risk:** Low for intended local/CI usage where the operator controls CLI arguments. Medium for wrappers or server deployments that expose pattern options to untrusted users without additional validation. #### T1.7 — Malicious archive metadata in packaged release artifacts **Threat:** An attacker ships a crafted ASAR archive with malformed header data, path-like entry names, integrity mismatches, or unpacked/native payloads intended to confuse inventory, trigger unsafe extraction behavior, or hide high-risk runtime capabilities. **Mitigations:** - Native ASAR parsing validates header structure before walking entries - Entry names containing path separators or traversal markers are rejected during header validation - Header validation caps the summed length of all entry paths relative to the header size, so nested long directory names cannot expand a small archive into gigabytes of path text - The packed entries of a header may not claim more bytes than the archive stores, so entries cannot alias one data region to multiply the work of a scan - A scan follows at most 512 nested ASAR archives, to a depth of four, and scans an archive reached through several symbolic links once - Archive inventory records both declared integrity metadata and computed SHA-256 hashes for file components - `.asar.unpacked` extraction only writes within a temp directory created through safe wrappers - `--dry-run` still blocks temp extraction even for ASAR scans, while allowing in-memory header and file-content analysis - JavaScript capability analysis highlights eval/code generation, dynamic fetch/import, network, filesystem, hardware, and child-process indicators in packaged source files **Residual risk:** Medium — cdxgen can inventory and verify what is present, but a trusted-looking packaged archive may still contain malicious application logic that requires human review or runtime sandboxing to fully assess. #### T1.8 — Compromised or substituted helper binary **Threat:** cdxgen executes optional native helpers from `cdxgen-plugins-bin` (for example Trivy, osquery, and trustinspector). A compromised, replaced, or unexpected binary could tamper with scan output or execute malicious logic. Separately, a forged `plugins-manifest.json` could attempt to spoof helper metadata recorded in `metadata.tools`. **Mitigations:** - Helper execution still flows through `safeSpawnSync`, command allowlisting, and the general secure-mode guardrails - Optional helper package versions are pinned in `package.json`, and the companion repository generates post-build metadata/SBOMs for shipped binaries - `plugins-manifest.json` is treated as data only: cdxgen does not execute commands, paths, or scripts from the manifest - Manifest ingestion is constrained to the real `plugins-manifest.json` file under `CDXGEN_PLUGINS_DIR`, requires a regular file, enforces a size bound, and sanitizes accepted fields before merging them into `metadata.tools` - Only the names of the helpers `cdxgen-plugins-bin` ships are looked up in the manifest when `metadata.tools` is built, so a manifest entry named after another executed tool, such as `git` or `pnpm`, is ignored. - Docker/rootfs tests assert non-cdxgen tool identity evidence and container/rootfs result parity, making silent helper-behavior drift easier to detect in CI - macOS osquery execution uses one-shot shell mode with the persistent database disabled, reducing the need for helper-managed state under privileged host paths such as `/var/osquery` **Residual risk:** Medium — helper binaries remain executable third-party/native code and expand the trusted computing base for deep OS/container inventory. A malicious actor who can replace the plugin directory can still spoof helper metadata or swap binaries, but that is a local integrity problem rather than a new command-injection path through manifest parsing. #### T1.9 — Malicious rootfs repository or trusted-key metadata **Threat:** A crafted image or root filesystem plants misleading repository source files or trusted key material so that the BOM reflects false trust relationships or reviewer-confusing crypto inventory. **Mitigations:** - Repository source entries are modeled as `type: data` with explicit `cdx:os:repo:*` provenance properties including source path and URL - Trusted key files are modeled as `type: cryptographic-asset` with hashes, source paths, trust-domain properties, and schema-valid `cryptoProperties` - When repo config explicitly references a key (`signed-by`, `gpgkey`), cdxgen emits a dependency edge from the repository component to the corresponding key asset instead of flattening the relationship away - Docker/rootfs regression tests compare archive and reconstructed-rootfs signatures so repo/key inventory drift is caught during CI **Residual risk:** Medium — cdxgen inventories what exists on disk and can preserve trust relationships, but it cannot prove that the configured repositories or keys are themselves benign or organization-approved. #### T1.10 — Over-privileged HBOM live collection on managed hosts **Threat:** An operator grants broader privileges than necessary to collect HBOM data on Linux or Windows, or assumes that every partial HBOM requires root or administrator access, increasing the blast radius of the scanning process on production hosts. **Mitigations:** - HBOM collection defaults to unprivileged mode and relies first on `/proc`, `/sys`, and other low-risk local sources where possible - `--privileged` is explicit opt-in and only enables the documented permission-sensitive command paths exposed by `@cdxgen/cdx-hbom` - `@cdxgen/cdx-hbom` (since 0.4.0) records missing-command and permission-denied diagnostics directly in the BOM root and collector trace instead of silently hiding partial evidence gaps - cdxgen derives compact `cdx:hbom:analysis:*` summary properties and exposes `hbom diagnostics` so operators can distinguish "install a package" from "rerun with --privileged" without guessing - In secure mode, cdxgen reuses the HBOM dry-run declaration as a preflight plan and aborts live HBOM collection when the declared commands fall outside `CDXGEN_ALLOWED_COMMANDS` or the declared local paths fall outside `CDXGEN_ALLOWED_PATHS`; for `@cdxgen/cdx-hbom` this also covers explicit `sudo -n` retry paths declared for permission-sensitive commands - The Linux privileged path uses non-interactive `sudo -n`, avoiding interactive password prompts that would otherwise encourage ad hoc operator workarounds - On Windows, `--privileged` only adds the `windows-cim-privileged` batch (TPM, BitLocker, storage reliability, Secure Boot). `@cdxgen/cdx-hbom` never elevates, never prompts for UAC and never starts `sudo.exe`, so an unelevated run records `permission-denied` diagnostics and still returns the rest of the inventory; the normal local-session inventory needs no administrator rights - Windows collection runs fixed, read-only PowerShell scripts through the absolute `%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe` with `-NoLogo -NoProfile -NonInteractive -Command`, no encoded payload and no execution-policy override. The scripts are static and readable, the BOM records only their digests, and `getCommandPlan` returns them for audit. Allowlisting `powershell.exe` is coarse because it admits any PowerShell invocation, and `SystemRoot` is a trust input in the same way as `PATH` - The preflight compares allowlist entries exactly and case-sensitively, as `@cdxgen/cdx-hbom` does when it starts a process, and it keeps checking the Windows and Darwin plans under `--no-command-enrichment`, which those collectors do not honour **Residual risk:** Medium — HBOM still runs on the target host and may require elevated access for richer firmware or graphics detail (on Windows, for TPM, BitLocker and reliability data, which only an already-elevated session can read). Users remain responsible for applying least privilege and deciding whether the additional evidence is worth the extra permissions. #### T1.11 — Untrusted AI metadata from remote model registries and local model artifacts **Threat:** A remote model repository (for example on Hugging Face) or a local AI artifact (for example GGUF) exposes misleading, oversized, or secret-bearing metadata that cdxgen could mirror into the BOM, confusing downstream review or leaking sensitive content. **Mitigations:** - Hugging Face remote resolution sanitizes URLs, strips userinfo/query/fragment components, and emits bounded revision-aware references instead of mirroring raw request contexts - AI-BOM prefers CycloneDX-first structures such as `modelCard`, `pedigree`, `externalReferences`, `services`, `dependencies`, and `data` components over dumping opaque metadata blobs into ad-hoc properties - GGUF parsing intentionally avoids copying raw tokenizer vocabularies, raw Hugging Face tokenizer JSON payloads, and raw chat templates; it emits safe derivatives such as counts, booleans, and token IDs instead - Hugging Face model-card parsing avoids copying raw gated-access prompts, widget conversations, and other unbounded prompt-like payloads into top-level BOM properties; it emits bounded booleans, counts, task/I-O hints, and stable links instead - Remote Hugging Face Spaces are modeled as `application` components with explicit model/dataset dependency edges so reviewer-relevant relationships survive without copying large runtime payloads **Residual risk:** Medium — cdxgen can sanitize and bound what it emits, but it still trusts remote and artifact-provided metadata enough to model lineage, datasets, and popularity/runtime hints. Human review is still required for policy decisions on untrusted third-party models. ### 2. HTTP Server (`lib/server/server.js`) #### T2.1 — Path traversal via scan requests **Threat:** A client sends a scan request with a path like `/app/../../../etc/passwd` to scan or access files outside allowed directories. **Mitigations:** - `isAllowedPath()` resolves paths and checks they are within `CDXGEN_SERVER_ALLOWED_PATHS` - Uses `path.relative()` to detect `..` traversal - `hasDangerousUnicode()` blocks Unicode obfuscation in paths - `isAllowedWinPath()` blocks Windows device names, UNC paths, and invalid drive roots - Body parser has 1MB request size limit **Residual risk:** Low when `CDXGEN_SERVER_ALLOWED_PATHS` is configured. Medium when unconfigured (any path is scannable). #### T2.2 — Git clone exploits **Threat:** A client sends a Git URL that exploits Git features to execute code during clone (e.g., `ext::` protocol, `fd::` protocol, malicious submodules). **Mitigations:** - `validateAndRejectGitSource()` rejects dangerous protocols (`ext::`, `fd::`) - Validates URL format and hostname against `CDXGEN_SERVER_ALLOWED_HOSTS` - Git clone uses hardened configuration: - `core.fsmonitor=false` — disables filesystem monitor hooks - `safe.bareRepository=explicit` — prevents bare repo attacks - `-c alias.clone=` — prevents alias abuse - `core.hooksPath=/dev/null` — disables hook execution entirely - `--template=` — prevents OS hook templates from being copied into the new repo - `GIT_CONFIG_NOSYSTEM=1` and `GIT_CONFIG_GLOBAL=/dev/null` in secure mode — prevents reading system/user configs including Git 2.54 `hook..command` entries - `GIT_TERMINAL_PROMPT=0` — prevents interactive prompts - `http.followRedirects=false` while `CDXGEN_GIT_ALLOWED_HOSTS`, `CDXGEN_SERVER_ALLOWED_HOSTS` or secure mode applies, so the allowlisted host is the one git talks to - `-c credential.helper=` when the URL carries a password, so the credential helpers of the account do not save one client's token and answer with it for another client's request - `--depth 1` — limits history to reduce attack surface - `GIT_ALLOW_PROTOCOL` defaults to `https:ssh` in secure mode **Residual risk:** Low — multiple layers of Git hardening are applied. #### T2.3 — Server-Side Request Forgery (SSRF) **Threat:** A client triggers cdxgen to make HTTP requests to internal hosts via package registry lookups or Git clone URLs. **Mitigations:** - `CDXGEN_ALLOWED_HOSTS` restricts `cdxgenAgent` outbound connections - `CDXGEN_SERVER_ALLOWED_HOSTS` restricts Git clone target hosts, and git does not follow HTTP redirects while it is set - Server-side Dependency-Track submission host checks require exact matches or real subdomain matches for wildcard entries (for example, `*.example.com` matches `api.example.com` but not `evil-example.com`) - Dependency-Track submission redirects are disabled so an allowlisted host cannot bounce uploads to a different destination - Secure mode enforces HTTPS-only - Redirect following is disabled in secure mode **Residual risk:** Medium — build tools invoked by cdxgen make their own HTTP requests that are not controlled by `CDXGEN_ALLOWED_HOSTS`. #### T2.4 — Denial of service **Threat:** A client sends many concurrent requests, very large bodies, or requests for enormous projects to exhaust server resources. **Mitigations:** - Body parser limit: 1MB - Server timeout: 10 minutes (configurable via `CDXGEN_SERVER_TIMEOUT_MS`) - Spawn timeout: 20 minutes (configurable via `CDXGEN_TIMEOUT_MS`) - Max buffer: 100MB (configurable via `CDXGEN_MAX_BUFFER`) - Git checkout ceiling: the tree of a cloned repository is measured before any file is written, and a repository requested from the server is not checked out above 1 GiB or 200000 files and directories; the command line and `cdx-audit` have no ceiling unless set (configurable via `CDXGEN_GIT_MAX_CHECKOUT_BYTES` and `CDXGEN_GIT_MAX_CHECKOUT_FILES`) - Remote git operations: the server runs `git clone` and `git ls-remote` without blocking its event loop, so a git host that accepts the connection and then stays silent does not stop other requests or `/health` from being answered. Each is stopped after 5 minutes in server mode (configurable via `CDXGEN_GIT_TIMEOUT_MS`, which also applies to the command line), and an HTTP peer that stays below 1000 bytes a second for a minute is dropped, together with the helper processes git started - Parsers of scanned project files avoid regular expressions whose work grows faster than the input. The CrewAI reader for `agents.py` and `tasks.py`, for example, reads each file once - Request `exclude` patterns may not use braces, run past 512 characters or number more than 128, since every pattern is matched against every file the scan walks - Request `type` and `excludeType` lists may not number more than 1024 entries, since both are read for every ecosystem of every scanned path - A request's `filter` and `only` lists may each hold at most 128 terms, since every term is searched for in every component of the BOM. A config file in the scanned directory is held to the same limit, and the terms past it are dropped with a warning **Residual risk:** Medium — no built-in rate limiting or concurrent request limits. The server is designed for trusted internal use. Deploy behind a reverse proxy for production exposure. #### T2.5 — No authentication or authorization **Threat:** Any client that can reach the server can trigger scans, potentially accessing the host filesystem. **Mitigations:** - `CDXGEN_SERVER_ALLOWED_PATHS` restricts scannable directories - Users are expected to deploy behind a reverse proxy with authentication - The server is intended for internal/CI use, not public exposure **Residual risk:** High if exposed without access controls. Low in intended deployment behind a reverse proxy. #### T2.6 — Registry metadata poisoning for purl requests **Threat:** A purl request resolves through registry metadata (`repository`, `homepage`, or similar fields) to attacker-controlled repositories. **Mitigations:** - purl-to-repository resolution is restricted to known ecosystems and then validated with git protocol + host allowlists - Host allowlists can block unexpected repository hosts even when metadata is poisoned - cdxgen logs warnings when using registry-derived repository URLs **Residual risk:** Medium — poisoned metadata can still redirect scans if allowlists are broad or unset. ### 3. Dependencies #### T3.1 — Compromised npm dependency **Threat:** A direct or transitive dependency publishes a malicious update that executes code when imported. **Mitigations:** - `pnpm-lock.yaml` provides reproducible installs with integrity hashes - `onlyBuiltDependencies` in `pnpm-workspace.yaml` restricts which packages can run install scripts - Renovate provides automated dependency updates with CI testing - CodeQL scanning runs on the codebase - npm provenance attestation on published packages - Optional heavy dependencies (atom, server middleware) are in `optionalDependencies` to reduce the attack surface of minimal installs **Residual risk:** Medium — supply-chain attacks on npm packages are an industry-wide threat. cdxgen has a moderate dependency tree. #### T3.2 — Dependency confusion **Threat:** An attacker publishes a malicious package with the same name as a private dependency to a public registry. **Mitigations:** - cdxgen uses only public npm packages; no private registry dependencies - All dependencies are explicitly versioned in `package.json` - `pnpm-lock.yaml` pins exact versions with integrity hashes **Residual risk:** Low. ### 4. CI/CD Infrastructure #### T4.1 — GitHub Actions supply-chain attack **Threat:** A compromised GitHub Action or workflow modification injects malicious code into cdxgen releases. **Mitigations:** - All GitHub Actions are pinned to full SHA digests (not mutable tags) - `permissions: {}` default (no permissions) at workflow level; explicit per-job grants - `persist-credentials: false` on all checkout steps - npm provenance (`NPM_CONFIG_PROVENANCE=true`) provides verifiable build attestation - Concurrency controls prevent parallel release workflows **Residual risk:** Low — strong workflow hardening practices are in place. #### T4.2 — Self-hosted runner compromise **Threat:** A self-hosted CI runner is compromised, allowing an attacker to tamper with builds or access secrets. **Mitigations:** - Self-hosted runners are used only for specific heavy jobs (e.g., depscan analysis) - Workflow permissions are scoped to specific jobs - `persist-credentials: false` limits credential exposure - Jobs on self-hosted runners do not have release/publish permissions **Residual risk:** Medium — self-hosted runners inherently have a larger trust boundary than GitHub-hosted runners. #### T4.3 — Release integrity **Threat:** An attacker modifies the npm package or container image between build and publish. **Mitigations:** - npm provenance attestation links published packages to specific GitHub Actions runs - Container base images are pinned to SHA digests - Multi-platform container builds use consistent base images - CodeQL analysis runs on PRs and pushes **Residual risk:** Low. ### 5. Container Images #### T5.1 — Container escape **Threat:** A vulnerability in the container runtime or cdxgen's container configuration allows escaping to the host. **Mitigations:** - `cdxgen-secure` image runs as non-root user (`cyclonedx`) - Node.js `--permission` model restricts filesystem and child process access within the container - Limited `--allow-fs-write` to temp and output directories only - `COMPOSER_ALLOW_SUPERUSER=0` prevents accidental root operations **Residual risk:** Low for cdxgen-specific vectors. Container runtime vulnerabilities are the responsibility of the runtime vendor. #### T5.2 — Vulnerable base image **Threat:** The base container image contains known vulnerabilities. **Mitigations:** - Base images are pinned to SHA digests for reproducibility - Images are regularly rebuilt with updated dependencies - CI builds test images before publishing **Residual risk:** Low — regular rebuilds reduce the window of vulnerability. ### 6. SBOM Output #### T6.1 — Sensitive data in SBOM **Threat:** Generated SBOMs contain sensitive information (file paths, emails, secrets, internal hostnames) that is inadvertently shared. **Mitigations:** - `thoughtLog` performs limited log normalization (for example, replacing the literal `'.'` with `''`), but logs may still include direct or absolute paths - Warning when `--include-formulation` is used with `--server-url` (formulation may contain emails and secrets) - In secure mode, using `--include-formulation` with `--server-url` calls `process.exit(1)` after the warning, preventing automatic upload of formulation data - Git metadata (formulation, release notes, submodule versions) is read only from the scanned directory's own repository. A `.git` file or symbolic link, `commondir`, `core.worktree`, `objects/info/alternates`, symbolic links below `.git` and `include.path` cannot point git at another repository of the host: cdxgen prints a warning and leaves the metadata out. Linked worktrees and submodules keep working because their git directory names the working tree in return. Only the operator can accept other layouts, with `CDXGEN_GIT_ALLOW_EXTERNAL_GITDIR=true`; a project config file cannot - `auditEnvironment` detects and warns about credential-like environment variables - Output from package managers and build tools (npm, pip, uv, poetry, Maven, Gradle, cargo, docker and the other tools cdxgen runs) is redacted before it is printed: URLs lose their userinfo and query string, URL path segments that look like access tokens (as in `https://host//simple/`) read `***`, and the value of any environment variable whose name marks a credential (names ending in `_TOKEN`, `_PASSWORD`, `_SECRET`, `_KEY`, `_AUTH`, `_PAT`, `_PSW`, `_PWD` and the like, and index URL variables such as `PIP_INDEX_URL` and `UV_INDEX_URL`) reads `***` wherever it appears. Values shorter than 8 characters are not replaced. A spawn error is printed as its name and message only - Query parameters in URLs: `sanitizeUrlQuery()` in `lib/core/propertySanitizer.js` is the one rule for the URLs of `externalReferences`, URL-valued properties, endpoints and free text. A URL keeps a query parameter only when its name is on a short list of names that say what the URL points at and never hold a secret (NuGet `api-version`, `q`, `prerelease`, `semVerLevel`, `packageType`, `skip`, `take`, `_src` and the `LinkId` of `go.microsoft.com/fwlink`; Go `go-get`; the git `ref`, `rev`, `tag`, `branch`, `commit`, `subdirectory`, `egg` and `depth` that uv, pip, Terraform and Cargo write; digests such as `sha256` in a fragment; `itemName`, `version`, `path` and a few more) and its value is plain text of at most 256 characters without a token shape. A list was chosen over a list of secret names because a parameter nobody thought of is dropped instead of kept. A query that holds a signing or secret parameter anywhere is removed whole, since the other parameters of a presigned URL (the expiry, the key id, the policy) only describe how to use the signature: AWS `X-Amz-*`, Google `X-Goog-*` and `GoogleAccessId`, Azure SAS (`sv`, `se`, `sp`, `sr`, `sig` and the key-delegation fields), CloudFront `Policy` and `Key-Pair-Id`, Alibaba OSS, and every name that ends in or contains `token`, `secret`, `password`, `auth`, `session`, `signature`, `api_key` or a credential qualifier before `key`. Userinfo is always removed - Secret-bearing BOM metadata values are sanitized before emission in AI/MCP inventory and Chrome extension metadata flows: - URLs and URIs of any scheme (`https://`, `postgres://`, `jdbc:mysql://` and the like) drop userinfo and fragments, also inside free text, and keep only the query parameters that name the target (see "Query parameters in URLs" below); a URL template such as `https://host/users/{id}` keeps its braces as written - inline credential patterns are redacted - component `externalReferences` built from scanned manifests and metadata (a Python `METADATA` `Home-page:`, a `package.json` `repository` or `bugs` URL, a download URL) drop their userinfo (an SSH `git@` user is kept), the query parameters that are not on the list below, and a fragment that holds a token shape or `=` pairs other than the listed ones; a fragment naming a git ref such as `#v1.2.0` is kept - raw command strings are reduced to safer summaries such as the executable name - dangerous structured keys such as `__proto__`, `constructor`, and `prototype` are removed before JSON serialization - the `Exec*` lines, other settings and description of package-owned systemd units and init scripts, the apt and yum repository URLs and descriptions of a container or rootfs scan, and the command line, environment and URL columns of osquery rows have credential arguments redacted and URL credentials removed; the container image environment is reported as variable names and the image command as the base name of its executable - Hugging Face widget examples, gated-access forms, and GGUF tokenizer/chat-template payloads are reduced to bounded derivatives instead of being copied verbatim into BOM properties **Residual risk:** Medium — SBOMs inherently contain metadata about the project. Users should review SBOMs before sharing, especially when formulation data is included. #### T6.2 — SBOM tampering in transit **Threat:** An SBOM is modified during upload to a BOM server (Dependency-Track, etc.). **Mitigations:** - Secure mode enforces HTTPS-only for all connections including SBOM upload - cdxgen supports SBOM signing via `SBOM_SIGN_PRIVATE_KEY`; the signed BOM is the one written, printed, and submitted to Dependency-Track - When signing is configured but fails, including a missing key file, cdxgen exits with status 1 instead of publishing an unsigned BOM; a private key set without `SBOM_SIGN_ALGORITHM` produces a warning **Residual risk:** Low when secure mode and SBOM signing are enabled. #### T6.3 — Forged or altered signatures accepted by `cdx-verify` **Threat:** An attacker who can modify a signed BOM (for example in a registry, in transit, or in a pull request that CI verifies) crafts a document that `cdx-verify`, `cdx-validate`, or `verifyBom()` accepts without the signer's private key, or rewrites signature metadata so that the BOM appears to come from another key, algorithm, or approval order. The attacker controls every field of the signature block, including `algorithm`, `keyId`, `publicKey`, and the order of `signers` and `chain` entries, and every byte of the BOM text: they can remove signatures, repeat member names, reuse signatures taken from other BOMs, add entries, and supply files next to the BOM. **Mitigations:** - The declared `algorithm` is only honoured when the verification key has exactly the matching type (RSA for `RS*`, RSA or RSA-PSS for `PS*`, the named curve for `ES*`, Ed25519/Ed448 for `Ed*`); unknown identifiers are rejected - HMAC (`HS*`) verification only accepts a secret supplied through `--secret-key` (a secret `KeyObject` in the library). Keys given as strings or Buffers are always parsed as public keys, and key material is refused as a shared secret, so a verifier's public key can never become an HMAC secret - Following JSF, each signature covers the signature metadata as well as the content; only `value` is excluded, and it must be canonical base64url. A `chain` entry also covers every earlier entry - An embedded `publicKey` must match the verification key, and `excludes` is rejected, so no part of a signed object can be left unsigned - Malformed signature blocks and entries with other key types are reported as non-matching instead of throwing, so a hostile entry cannot stop later entries from being checked - `cdx-sign --mode chain` checks the existing chain entries against the earlier signers' public keys (`--verify-existing-with`) and refuses to countersign history it cannot verify, unless `--allow-unverified-history` is passed. `--mode signers` requires at least one existing entry to verify, so a co-signature is never added to content that no longer matches the earlier signatures. Both modes refuse a BOM without a root signature when `--verify-existing-with` is given or a nested element is still signed, so removing the root signature does not skip that check - `cdx-validate` verifies nested signatures by default, matching `cdx-verify`, and fails with exit code 4 whenever a key is given and verification fails - The trusted key must be named with `--public-key` or `--secret-key`; `cdx-verify` never reads a key from the working directory or from the document - A root signature is required. A BOM whose root signature was removed fails, and `--allow-nested-only` accepts one only when every component, service, and annotation carries a signature that verifies - The signed root must carry `bomFormat` (or `specFormat`) and `specVersion` and consist of CycloneDX root members, and signed nested elements must not carry `bomFormat`, `specFormat`, or `specVersion`, so a component, service, or annotation signature cannot be presented as a BOM signature. `cdx-sign` refuses to produce either shape - BOM bytes that are not UTF-8, or text that repeats a member name, holds a number an IEEE 754 double cannot represent exactly, or holds an unpaired surrogate escape, are refused before verification (`lib/parsers/strictJson.js`), so every JSON parser reads the values the signature covers - Every root and nested `signers` and `chain` entry is reported with its outcome. `--require-all` requires each entry to verify with one of the trusted keys and each trusted key to verify an entry of the root signature, so a removed co-signature or a truncated chain fails. For a BOM without a root signature that `--allow-nested-only` accepts, each trusted key must verify an entry of every nested signature instead - A signature may hold at most 32 entries and no members beside its `signers` or `chain` array. Each signed object is canonicalized once, and the signed bytes of one entry are released before the next, so verification time and memory stay proportional to document size - `cdx-sign` embeds the signer's public key in the root signature by default, binding RSA and ECDSA signatures to their key, and writes ECDSA signatures in low-`s` form **Residual risk:** Low. Verification is only as trustworthy as the public key or shared secret the verifier supplies; distribute it out of band. Removing whole signature entries, such as the last entries of a chain, is only detected with `--require-all` and the key of every expected signer. A signature that an earlier `cdx-sign` made over an untrusted nested element carrying `bomFormat` and `specVersion` can still be presented as a BOM signature; re-sign BOMs whose nested elements came from untrusted input. With `--allow-nested-only`, nothing protects which signed elements a BOM lists. ECDSA signatures verify in both `s` forms, so a signature `value` is not a unique identifier. ### 7. Dynamic Process Tracing (`tracebom`, `lib/inventory/traceRunner.js`) #### T7.1 — Sandbox bypass or escape during command execution **Threat:** The user executes a malicious binary under `tracebom --cmd` which escapes `@cdxgen/safer-exec` sandboxing to access the host filesystem or perform network operations. **Mitigations:** - `@cdxgen/safer-exec` implements kernel-level namespace isolation, Landlock network confinement, and cgroup v2 resource limits on Linux, Seatbelt sandboxing on macOS, and a Microsoft eXecution Container (BaseContainer with Windows Filtering Platform rules and a job object) on Windows 11. - Tracing is locked down using LD_AUDIT / DYLD_INSERT_LIBRARIES mechanism enforced securely by the sandbox boundary. On Windows DLL loads come from an ETW session the engine runs outside the container, which the low-privilege workload cannot stop. - since 1.1, safer-exec sends audit entries and results to the engine over a pipe the workload does not inherit, so a traced command cannot forge components, services, or diff entries by printing look-alike lines. On Linux, `lib-load` entries still come from a helper inside the workload and can be forged. - Configurable sandbox limits (`--max-memory`, `--max-cpu`, `--max-processes`, `--timeout`, `--disable-network`, `--read-paths`, `--write-paths`, `--strict`, `--sanitize-env`, `--diff`, `--block-fork`, `--trace-exec`, `--allow-exec`, `--block-exec`, `--allow-host`, `--allow-port`, `--allow-url`) allow operators to restrict the traced process. **Residual risk:** On Windows, `--private-tmp` and `--protect-home` hold only while no granted path reaches the host's temp directory or the user profile; safer-exec reports a grant that does, and `--strict` refuses the run. `--block-interpreters` has no effect on Windows (tracebom warns). TLS parameters recorded through `--proxy-egress` are what each handshake claimed; a command talking to a server it controls can make them say anything, so treat traced crypto assets as an inventory rather than proof. #### T7.2 — Arbitrary command execution on host operating system **Threat:** The command supplied to `--cmd` contains shell metacharacters or executes untrusted binaries directly. **Mitigations:** - `traceRunner.js` splits and parses the command string into an array of arguments, avoiding shell wrapper execution. - Command execution is performed via `SaferExec` class which enforces the standard process constraints and does not run raw strings inside shell wrappers. - No allowlist enforcement in traceRunner — the CLI operator is trusted to pass safe commands. The sandbox itself is the enforcement mechanism. - Additional sandbox controls (`--allow-exec`, `--block-exec`, `--block-fork`, `--trace-exec`) allow restricting which child processes the command can spawn, mitigating post-install script attacks. ## Data Flow Diagram ``` ┌───────────────┐ │ Package │ │ Registries │ │ (npm, maven, │ │ pypi, etc.) │ └───────┬───────┘ │ HTTP(S) │ [TB2] │ ┌───────────┐ ┌─────────────────┐ ┌───────▼───────┐ ┌──────────────┐ │ Project │ │ cdxgen │ │ Build Tools │ │ BOM Server │ │ Files │───►│ ┌───────────┐ │ │ (npm, mvn, │ │ (Dependency │ │(manifests,│ │ │ Parsers │ │ │ pip, go...) │ │ Track, etc.)│ │ lockfiles,│ │ └─────┬─────┘ │ └───────────────┘ └──────▲───────┘ │ configs) │ │ │ │ ▲ │ └───────────┘ │ ┌─────▼─────┐ │ │ safeSpawnSync │ SBOM [TB4] │ │ BOM │ │─────────┘ [TB1] │ Upload │ │ Builder │ │ │ ┌──────────┐ │ └─────┬─────┘ │ │ │ HTTP │ │ │ │───────────────────────────────┘ │ Client │────►│ ┌─────▼─────┐ │ HTTP(S) [TB2] └──────────┘ │ │ Server │ │ [TB3] │ └───────────┘ │ └─────────────────┘ cdxgen process [TB4, TB5] ``` _TB = Trust Boundary (see Trust Boundaries section above)_ ## Security Controls Summary | Control | Implementation | Threat(s) Addressed | | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | | Command allowlisting | `CDXGEN_ALLOWED_COMMANDS` + `safeSpawnSync`; HBOM secure-mode dry-run preflight validates declared host-collector commands before live execution | T1.1, T1.2, T1.10 | | Host allowlisting | `CDXGEN_ALLOWED_HOSTS` + `CDXGEN_GIT_ALLOWED_HOSTS` + `cdxgenAgent` hooks; server-side Dependency-Track submission uses strict wildcard subdomain matching | T2.3, T2.2, T2.6 | | Path allowlisting | `CDXGEN_SERVER_ALLOWED_PATHS` + `isAllowedPath`; HBOM secure-mode dry-run preflight validates declared local collector paths against `CDXGEN_ALLOWED_PATHS` | T1.10, T2.1 | | Node.js permission model | `--permission` flags in `NODE_OPTIONS` | T1.4, T5.1 | | Secure mode | `CDXGEN_SECURE_MODE=true` | T1.2, T2.2, T2.3, T6.2 | | Environment audit | `auditEnvironment()` at startup | T1.3 | | Unicode validation | `hasDangerousUnicode()`, `isValidDriveRoot()` | T1.4, T2.1 | | Git hardening | `validateAndRejectGitSource()`, hardened clone config | T1.5, T2.2, T2.6 | | Safe wrappers | `safeExistsSync`, `safeMkdirSync`, `safeSpawnSync` | T1.1, T1.4 | | BOM metadata sanitization | URL scrubbing, inline secret redaction, command summarization, structured-key filtering | T6.1, T2.3 | | Helper binary pinning and metadata | Optional helper package version pinning, companion binary SBOM/metadata generation, CI parity checks, and tool identity evidence | T1.8, T4.3 | | Trust-material modeling | Repository-source `data` components, trusted-key `cryptographic-asset` components, file hashes, and repo-to-key dependency edges | T1.9, T6.1 | | JSF signature verification | Algorithm-to-key binding, HMAC only with an explicit shared secret, signed metadata and chain order, embedded key checks | T6.2, T6.3 | | Structured logging | `thoughtLog`, `traceLog`, `commandsExecuted`, `remoteHostsAccessed` | Auditability for all threats | | Dependency pinning | `pnpm-lock.yaml`, SHA-pinned Actions, SHA-pinned base images | T3.1, T3.2, T4.1 | | Provenance attestation | `NPM_CONFIG_PROVENANCE=true` | T4.3 | | Non-root container | `USER cyclonedx` in Dockerfile-secure | T5.1 | | Request limits | Body parser 1MB limit, server timeout, spawn timeout, max buffer | T2.4 | ## Recommendations for Deployers 1. **Use secure mode** — Set `CDXGEN_SECURE_MODE=true` and configure `NODE_OPTIONS` with the Node.js permission model, or use the `ghcr.io/cdxgen/cdxgen-secure` container image. 2. **Configure allowlists** — Set `CDXGEN_ALLOWED_HOSTS` and `CDXGEN_ALLOWED_COMMANDS` based on your project types. For HBOM in secure mode, run `hbom --dry-run` first and use the declared command set as the review baseline before enabling live collection (on Windows the declared set is `powershell.exe`). 3. **Restrict paths deliberately** — When running HBOM in secure mode, set `CDXGEN_ALLOWED_PATHS` to the approved local inventory roots for that host profile (for example `/proc,/sys,/etc` on Linux where appropriate). In server mode, also set `CDXGEN_SERVER_ALLOWED_PATHS` and `CDXGEN_GIT_ALLOWED_HOSTS` (or `CDXGEN_SERVER_ALLOWED_HOSTS`). 4. **Deploy server behind a proxy** — The cdxgen server has no built-in authentication. Use a reverse proxy (nginx, Envoy, etc.) with authentication and rate limiting. 5. **Sandbox untrusted projects** — Scan untrusted code in containers or ephemeral CI environments, not on developer machines. 6. **Review environment** — Check `auditEnvironment` output for warnings. Remediate HIGH severity findings before production use. 7. **Enable trace logging in CI** — Set `CDXGEN_TRACE_MODE=true` in CI pipelines for auditability of commands and network access. 8. **Review generated metadata before sharing** — Even with built-in redaction, inspect BOM properties when scanning AI/MCP configs, agent instructions, or browser extension manifests. 9. **Keep cdxgen updated** — Apply updates promptly, especially those that reference security fixes.