Generating an SBOM: CycloneDX vs SPDX, the Tools, and What CISA and the CRA Require
A new critical CVE lands in some library you've vaguely heard of. The question from whoever owns security is always the same: do we ship it, and where? Without an inventory you answer by grepping lockfiles across repos and guessing what's inside each container image. With one, you query a file.
That's all a software bill of materials is: a machine-readable list of the components in a piece of software, with versions, identifiers and the relationships between them. The hard parts are choosing a format, generating it at the right point in the build, and knowing what the official texts actually require, which is more than a bare npm ls.
What the official texts ask for
Two documents matter for most teams as of November 2026. Read them yourself; I quote only what they say.
CISA's 2026 Minimum Elements. On 29 July 2026 CISA, NSA, FBI and international partners published the 2026 Minimum Elements for a Software Bill of Materials, which "updates and replaces" NTIA's 2021 list. The PDF defines 17 data fields:
| About the SBOM itself | About each component |
|---|---|
| SBOM Author, SBOM Author Signature | Component Name, Component Version |
| SBOM Timestamp, SBOM Version | Component Producer (replaces "Supplier Name") |
| SBOM Data Format Name and Version | Component Identifiers |
| SBOM Tool Name and Version | Component Hash Algorithm and Hash Value |
| SBOM Generation Context | Component License, Component Dependency Relationship |
Ten of those are new since 2021, including the hash, license, tool and generation-context fields. The coverage rule is stricter too: an SBOM "should include information for all components that make up the target software, including transitive dependencies. There is no minimum depth." If you don't know a value, the document asks you to say so explicitly rather than leave it blank. It's guidance, not law. The PDF states it "does not constitute advice for compliance, regulatory, or legal purposes." Read it as a well-documented baseline, not a legal requirement.
The EU Cyber Resilience Act. Regulation (EU) 2024/2847 requires manufacturers of products with digital elements to identify components "including by drawing up a software bill of materials in a commonly used and machine-readable format covering at the very least the top-level dependencies of the products" (Annex I, Part II, point 1). A few details people get wrong:
- The SBOM goes into the technical documentation and is handed to a market surveillance authority on a reasoned request. Recital 77 says manufacturers "should not be obliged to make the SBOM public."
- The CRA itself names no format. Article 13(24) lets the Commission specify the format and elements later through implementing acts.
- Timing: the regulation applies from 11 December 2027. The Article 14 reporting obligations for actively exploited vulnerabilities have applied since 11 September 2026, and Chapter IV, on notifying conformity assessment bodies, since 11 June 2026.
So the CRA's floor is top-level dependencies, while CISA's guidance asks for the full tree. If you generate the full tree you satisfy both, and there's no good reason not to: the tools do it by default.
CycloneDX or SPDX
CISA names both as the two widely used formats and says organisations "should accept any widely used, interoperable, and machine-processable SBOM format", while avoiding deprecated versions of either.
| CycloneDX | SPDX | |
|---|---|---|
| Steward | OWASP; standardised as Ecma ECMA-424 | Linux Foundation; ISO/IEC 5962:2021 |
| Current release | 1.7 (Oct 2025), patch 1.7.2 (Sep 2026) | 3.0.1 (Dec 2024); 3.1-RC1 pre-release (Jan 2026) |
What npm sbom emits | CycloneDX 1.5 | SPDX 2.3 |
| Docker BuildKit attestation | no | SPDX (in-toto predicate) |
The ISO edition of SPDX is based on SPDX 2.2.1, so "ISO-standard SPDX" and "latest SPDX" aren't the same document. My rule: emit whatever the person receiving it asks for. If nobody's asking, I default to CycloneDX JSON, because npm, Syft, cdxgen and Docker Scout all write it and the scanners at the end of this post read it. Syft can write both from one scan, so this is rarely a hard choice.
Where in the build you generate it
CISA's new "SBOM Generation Context" field exists because SBOMs from different stages describe different things. Its examples: an SBOM from source code is "before build", and binary analysis tools produce one "after build".
The difference is real. A lockfile-based SBOM lists your npm dependencies, including dev dependencies unless you omit them, but knows nothing about the OS packages in your base image. An image scan sees the Debian or Alpine packages and the node_modules that actually shipped, but nothing that only existed in a build stage, such as the dev dependencies your bundler used. For a containerised service I'd ship the image SBOM as the record of what's deployed and keep the source SBOM for license review.
Generating one: the commands
From an npm project. npm has had a built-in npm sbom command since 10.2.0 (October 2023):
npm sbom --sbom-format cyclonedx --sbom-type application --omit dev > sbom.cdx.json
npm sbom --sbom-format spdx --package-lock-only > sbom.spdx.json
Reading npm's source, the CycloneDX output copies each package's lockfile integrity into hashes and records the lifecycle phase as pre-build with --package-lock-only or build otherwise. That covers two of CISA's new fields for free. npm 12 also changed the component name, bom-ref and purl to come from each package's package.json rather than the folder name, per the 12.0.0 release notes, so diffs across that upgrade will look noisy.
From a directory or image with Syft. Syft (v1.57.0 as of 5 November 2026) handles dozens of ecosystems plus OS packages:
syft ./ -o cyclonedx-json=sbom.cdx.json
syft myapp:1.4.2 -o spdx-json=./spdx.json -o cyclonedx-json=./cdx.json
With cdxgen. cdxgen targets CycloneDX 1.6, 1.7 and 2.0 and can export SPDX 3.0.1 JSON-LD. It's the one to try for polyglot repos:
cdxgen -o bom.json .
cdx-validate -i bom.json --benchmark scvs-l2,cra
Its README installs itself with npm install -g @cdxgen/cdxgen --ignore-scripts --min-release-age=2, which tells you something about how SBOM tool authors think about npm installs.
At image build time. BuildKit can generate and attach an SPDX SBOM as an attestation using its Syft-based scanner, per Docker's build docs:
docker buildx build --sbom=true -t registry.example.com/myapp:1.4.2 --push .
docker buildx imagetools inspect registry.example.com/myapp:1.4.2 --format "{{ json .SBOM.SPDX }}"
By default BuildKit only scans the final stage. Declare ARG BUILDKIT_SBOM_SCAN_STAGE=true in the Dockerfile (globally or per stage) to cover the builder stages of a multi-stage build too; the docs say an explicit ARG is the only way to set it.
For an existing image. The old docker sbom plugin is retired; use docker scout sbom:
docker scout sbom --format cyclonedx --output myapp.cdx.json myapp:1.4.2
Gotchas before you hand one over
- Generate per release, not once. CISA's Frequency element says each software version should have its own SBOM, and errors should be corrected with a revised one. Generate in the release job and store the file next to the artifact.
- Dev dependencies. Decide deliberately. They're not shipped, but a build-time compromise still affects you. One reasonable split: publish a runtime SBOM and keep a full one internally.
- Missing hashes and licenses. Not every generator fills them in. Check for the CISA fields before you send anything;
cdx-validateexists to grade exactly this. - Format versions. CISA asks recipients to avoid SBOMs for new software in deprecated format versions.
npm sbomstill writes CycloneDX 1.5; if a recipient wants 1.7, generate with a tool that targets it rather than editing the version string. - Signing. "SBOM Author Signature" is now a minimum element. Syft can create signed SBOM attestations in the in-toto format, which gets you closer than a loose JSON file.
Make it earn its keep
An SBOM nobody queries is paperwork. The useful loop is to rescan stored SBOMs when new vulnerabilities are published, without rebuilding anything:
grype sbom:./sbom.cdx.json --fail-on high
syft -o spdx-json myapp:1.4.2 | docker scout cves sbom://
That's the moment the CISA coverage rule pays off: if the component isn't in a complete SBOM, you can say you're not affected and mean it. Wire the generation into the pipeline from our GitHub Actions CI/CD patterns post, and if you're still working through the rest of the supply-chain section of the OWASP Top 10:2025 checklist, this is the item that makes the others measurable. For Next.js images specifically, our containerizing Next.js walkthrough produces exactly the kind of multi-stage image these commands expect.
Written by AIDToolStack Editorial
Researched from official documentation, specifications and vendor pages, listed under Sources below. Last checked November 2026.
Sources
- www.cisa.gov/resources-tools/resources/2026-minimum-elements-software-bill-materials-sbom
- www.cisa.gov/sites/default/files/2026-07/2026_cisa_sbom_minimum_elements_508c.pdf
- eur-lex.europa.eu/eli/reg/2024/2847/oj/eng
- cyclonedx.org/news/cyclonedx-v1.7-released
- github.com/CycloneDX/specification/releases
- github.com/spdx/spdx-spec/releases
- github.com/npm/cli/blob/v12.2.2/docs/lib/content/commands/npm-sbom.md
- github.com/npm/cli/blob/v12.2.2/lib/utils/sbom-cyclonedx.js
- github.com/npm/cli/releases/tag/v12.0.0
- github.com/anchore/syft
- github.com/CycloneDX/cdxgen
- docs.docker.com/build/metadata/attestations/sbom/
- docs.docker.com/retired/
- docs.docker.com/reference/cli/docker/scout/sbom/
- github.com/npm/cli/blob/v10.9.10/CHANGELOG.md
- github.com/npm/cli/blob/v12.2.2/lib/utils/sbom-spdx.js
- content.govdelivery.com/accounts/USDHSCISA/bulletins/422a7eb
Related Posts
Explore on AIDToolStack
Discover tools and servers featured in our directory.
AI Tools
MCP Servers
Sponsor Our Newsletter
Reach thousands of developers who are actively evaluating AI tools, MCP servers, and dev infrastructure. Our weekly newsletter goes to engaged technical decision-makers.
All sponsored content is clearly labeled per our editorial policy.