Build the SBOM from
Cargo.lock: it pins every crate in the workspace graph. Usecargo cyclonedx(the official CycloneDX tool) or any lockfile-based generator. Two things to check:Cargo.lockdoesn't mark dev- or build-dependencies, and it also lists your own workspace crates. To prove what is inside each binary, build it withcargo auditable.
Which file the SBOM comes from
| Package manager | File | Full dependency tree? | Dev dependencies left out? |
|---|---|---|---|
| Cargo | Cargo.lock | Yes, for the whole workspace | No: dev-dependencies and build-dependencies aren't marked |
How to generate it
With the official CycloneDX tool
cargo-cyclonedx reads the Cargo metadata and writes one SBOM per crate, next to its Cargo.toml.
cargo install cargo-cyclonedx
cargo cyclonedx --format json With the CRA Starter Kit tool
normavio_sbom.py reads Cargo.lock, skips target, and writes a readable report for the technical file next to the SBOM.
python3 normavio_sbom.py ./firmware-agent \
--name "Nimbus T1 agent" --version 2.0.0 \
--osv --out ./technical-file/sbom/2.0.0
# -> sbom.cdx.json and sbom-report.md Make each binary carry its own list
cargo-auditable embeds the dependency list in the compiled binary, so you (or a market surveillance authority) can check later exactly what a given release contains.
cargo install cargo-auditable
cargo auditable build --release What catches teams out
- Your own crates. Workspace members appear in
Cargo.lockwithout asourceline. A plain lockfile reader, including the kit's tool, lists them as components. Keep them and say they are first-party, or remove them. - Dev- and build-dependencies. Test frameworks and build helpers sit in the same lockfile. Build-dependencies (proc macros,
build.rshelpers) aren't in the binary, but they did shape it: many teams keep them and label them in the report. - C libraries. With the
vendoredfeature,openssl-syscompiles OpenSSL into your binary and the lockfile shows theopenssl-srccrate, whose version carries the OpenSSL version (for example300.3.1+3.3.1). Without it, OpenSSL comes from the system and belongs in the SBOM of the OS image. - Libraries without Cargo.lock. If you sell a crate as a component and don't commit the lockfile, run
cargo generate-lockfilebefore each release so the SBOM matches what you tested.
What the CRA asks of this SBOM
- Identify and document the components, including by drawing up an SBOM in a commonly used, machine-readable format, covering at least the top-level dependencies (Annex I, Part II, point 1).
- Keep it in the technical documentation, one per product version (Annex VII, point 2).
- Use it to find and fix vulnerabilities in those components without delay (Annex I, Part II, point 2).
The SBOM guide covers formats, fields and how to keep it alive.
Frequently asked questions
One SBOM per crate or one for the product?
One per product you place on the market, at each release. If the product is several binaries from one workspace, one SBOM for the workspace is fine as long as the report says which binaries it covers.
Is Cargo.lock in itself an SBOM?
No. It has the data, but the CRA asks for a commonly used, machine-readable SBOM format. Convert it to CycloneDX or SPDX.
How do I check vulnerabilities in Rust crates?
cargo-audit checks Cargo.lock against the RustSec database, which also feeds OSV.dev. The kit's tool queries OSV.dev with --osv.