What is an SBOM? CycloneDX, SPDX and package URLs in practice
When Log4Shell was published in December 2021, every team with Java software had to find out whether it ran log4j-core, and where. A list of the components in each application answers that with one search. That list is a software bill of materials (SBOM). Trivy writes one for a server or a container image in either of the two common formats, and scans it again later without the image.
What an SBOM contains
An SBOM is a machine-readable list of the components in a piece of software: name, version, a unique identifier, and often the supplier, licence and hashes. For a container image it lists the operating system packages and the language packages inside. For a server it lists the installed packages.
The SBOM itself does not list vulnerabilities. A scanner matches it against vulnerability data, and can match the same SBOM again every day as new CVEs come out, without access to the image or the server.
The two formats
| CycloneDX | SPDX | |
|---|---|---|
| Maintained by | OWASP | Linux Foundation |
| Standard | Ecma ECMA-424 | ISO/IEC 5962:2021 |
| Current version | 1.7 is what Trivy 0.75.0 writes | 3.0 is current; Trivy writes 2.3 |
| Focus | security: components, services, vulnerabilities, VEX | licences and provenance, with security added |
| File | JSON or XML | JSON, tag-value, RDF and others |
Both work for vulnerability matching, and most scanners read both; pick the one your tools read. CycloneDX can also carry vulnerabilities and VEX statements in the same document.
Package URLs (purl)
Tools need an identifier for each component that they can match without guessing. Both formats use the package URL, pkg:type/namespace/name@version?qualifiers:
pkg:deb/debian/libssl3@3.0.15-1~deb12u1?arch=amd64&distro=debian-12.9
pkg:pypi/pip@24.3.1
pkg:maven/org.apache.logging.log4j/log4j-core@2.14.1
pkg:golang/golang.org/x/net@v0.17.0
The type names the ecosystem and therefore the version rules. The distro qualifier on the Debian package tells a scanner to use Debian 12 data, so that backported fixes count as fixed.
Make an SBOM with Trivy
# a container image
trivy image --format cyclonedx --output app.cdx.json registry.example.com/app:1.4
# the running host (operating system packages and language packages it finds)
sudo trivy rootfs --format cyclonedx --output host.cdx.json /
# an application directory with lockfiles
trivy fs --format cyclonedx --output app-src.cdx.json /srv/app
# SPDX instead of CycloneDX
trivy image --format spdx-json --output app.spdx.json registry.example.com/app:1.4
For python:3.12.8-slim, the CycloneDX file lists 107 components and is about 200 KB. A component (shortened):
{
"type": "library",
"name": "libssl3",
"version": "3.0.15-1~deb12u1",
"purl": "pkg:deb/debian/libssl3@3.0.15-1~deb12u1?arch=amd64&distro=debian-12.9",
"properties": [
{ "name": "aquasecurity:trivy:SrcName", "value": "openssl" },
{ "name": "aquasecurity:trivy:SrcVersion", "value": "3.0.15" }
]
}
The SrcName property records the Debian source package. Debian publishes fixes per source package, so the scanner needs it to match libssl3 against advisories for openssl.
Docker can also attach an SBOM to an image at build time (docker buildx build --sbom=true) and store it next to the image in the registry.
Scan an SBOM
trivy sbom app.cdx.json
trivy sbom --severity CRITICAL --ignore-unfixed app.cdx.json
The scan of the SBOM of python:3.12.8-slim gave the same 9 critical findings as the scan of the image itself. Generate the SBOM once per build, keep it with the release, and scan it again whenever the vulnerability data changes.
What an SBOM does not tell you
- Whether a component is used. A library in the list may never be loaded. VEX documents can state "not affected" for specific CVEs.
- Anything the generator could not see. Software compiled from source without package metadata is missing: the
python:3.12.8-slimSBOM does not list the Python interpreter, which is built into/usr/local. - Whether the list is still current. An SBOM describes one build, and a server changes with every update. Make a new one after each change, or on a schedule.
SBOMs and the Cyber Resilience Act
The EU Cyber Resilience Act requires manufacturers of products with digital elements to document their components, including in an SBOM.
Sources
- CycloneDX specification overview (OWASP, ECMA-424, VEX)
- SPDX specifications (ISO/IEC 5962:2021, current version 3.0, previous 2.3)
- Package URL specification
- Trivy: SBOM and Docker: SBOM attestations
- Regulation (EU) 2024/2847, Cyber Resilience Act
- CycloneDX 1.7 and SPDX 2.3 files made with Trivy 0.75.0 from the file system of
python:3.12.8-slim, andtrivy sbomon the result, on 2026-11-26
Check your servers every day
The Vulnpocalypse collector reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.
Vulnpocalypse