Languages

SBOMs for Rust

Stable Cargo has no SBOM command yet. sbombox generate uses cargo-cyclonedx if installed, then cdxgen or syft. Commit Cargo.lock so every version is exact.

At a glance

Rust and SBOMBox
Package managerBuilt-in SBOM commandWhat sbombox generate runsLockfile to commit
CargoNightly only (-Z sbom)cargo-cyclonedx, then cdxgen or syftCargo.lock

Generate with SBOMBox

curl -fsSL https://sbombox.com/install.sh | sh

sbombox generate -o sbom.json
sbombox score sbom.json

Run it from the directory that holds Cargo.toml and Cargo.lock. To use the native tool, install it first:

cargo install cargo-cyclonedx

To pin the choice, set SBOMBOX_GENERATOR to one or more generator names, comma-separated. SBOMBox tries them in that order and skips any that are not installed. An unknown name fails with the list of valid names.

SBOMBOX_GENERATOR=syft sbombox generate -o sbom.json

Valid names for Rust: cargo-cyclonedx (alias cargo), cdxgen, syft.

Use cargo-cyclonedx

cargo-cyclonedx writes one SBOM next to each Cargo.toml in the workspace. --override-filename sets a fixed file name.

cargo cyclonedx -f json --spec-version 1.5

# Upload the JSON file it wrote next to Cargo.toml
sbombox push <file> --version v1.4.0

Embed dependency data in binaries

cargo-auditable records the dependency list inside the compiled binary. syft can read it, so you can produce an SBOM from a binary you already shipped.

cargo install cargo-auditable
cargo auditable build --release
syft ./target/release/my-app -o cyclonedx-json=sbom.json

Cargo's own SBOM support

Nightly Cargo can write SBOM precursor files with -Z sbom. With sbom = true under [unstable] and [build] in .cargo/config.toml, or CARGO_BUILD_SBOM=true, it writes <artifact>.cargo-sbom.json next to each binary. These are Cargo's own JSON format, not CycloneDX or SPDX, so they need conversion before upload. Stabilising this is an accepted Rust project goal for 2026.

Monorepos and workspaces

Known gaps and how SBOMBox handles them

Troubleshooting

Common Rust issues
SymptomCauseFix
No lockfile for cargo: transitive dependencies may be missing and versions may be guessed.Cargo.lock not committedCommit Cargo.lock
Dependencies missing for your release platformSBOM built for the host targetPass --target with your release triple
.cargo-sbom.json not accepted by sbombox pushCargo precursor format, not CycloneDX or SPDXUse cargo-cyclonedx or syft for the uploaded SBOM

In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.