An SBOM is a machine-readable inventory of every component in a piece of software, including direct and transitive dependencies, their versions, licenses, and suppliers. When a new CVE drops, the SBOM is what lets you answer "are we affected" in minutes instead of days, because you can search the inventory instead of rebuilding every project from memory. An SBOM that is generated once and never updated is worse than useless, since it gives false confidence, so this skill treats SBOM generation as part of the build, distribution as part of the release, and consumption as part of vulnerability management.
Quick Workflow
- Pick a format, SPDX or CycloneDX, and standardize on it across all services so consumers only need one parser.
- Generate the SBOM at build time from the built artifact, not from a developer workstation, so it matches what actually ships.
- Name every component with a package URL (purl) plus an exact version, and include transitive dependencies, not just direct ones.
- Sign the SBOM and publish it alongside the release artifact, in the same place and under the same version tag.
- On every new CVE disclosure, correlate the SBOM inventory against vulnerability data and record VEX statements for components that are not actually exploitable in your build.
- Regenerate the SBOM on every dependency change and every rebuild, and fail the pipeline if generation or signing fails.
- Store SBOMs where incident responders can find them without asking the build team, and keep them for as long as the release is supported.
1. Choosing a format, SPDX versus CycloneDX
SPDX (an ISO standard, maintained by the Linux Foundation) is the format auditors and many government procurement processes ask for, and it has the richest license expression support. CycloneDX (from OWASP) is designed for security workflows, with first-class support for vulnerability data, VEX statements, and component pedigree. In practice, generate one primary format and convert when a consumer asks for the other, rather than maintaining two separate generation pipelines that can drift apart.
# Generate a CycloneDX SBOM for a container image with Trivy
trivy image --format cyclonedx --output sbom.cyclonedx.json myapp:1.2.3
# Generate an SPDX SBOM for the same image
trivy image --format spdx-json --output sbom.spdx.json myapp:1.2.3
# Generate an SBOM for a source directory (pre-build inventory)
trivy fs --format cyclonedx --output sbom-fs.cyclonedx.json .
# Check what a generated SBOM actually contains before trusting it
jq '.components | length' sbom.cyclonedx.json
jq -r '.components[] | "\(.purl) \(.version)"' sbom.cyclonedx.json | head -20
jq '.packages | length' sbom.spdx.json
Check the component count against your lockfile. If the SBOM has far fewer entries than the lockfile, the generator missed a language ecosystem or a layer, and the SBOM will miss the next CVE in that gap.
2. Generating SBOMs at build time
Generation belongs in CI, at the step that produces the artifact, so the SBOM and the artifact can never drift apart. Generate from the built image or package, not just from the manifest, because base image layers and system packages never appear in an application lockfile but still carry CVEs.
# Example build pipeline sequence (commands, not a full workflow)
docker build -t myapp:1.2.3 .
trivy image --format cyclonedx --output sbom.cyclonedx.json myapp:1.2.3
syft packages myapp:1.2.3 -o cyclonedx-json -o sbom-syft.cyclonedx.json
# Compare two generators on the same image and investigate gaps
jq -r '.components[].purl' sbom.cyclonedx.json | sort -u > trivy-purls.txt
jq -r '.components[].purl' sbom-syft.cyclonedx.json | sort -u > syft-purls.txt
comm -13 trivy-purls.txt syft-purls.txt
comm -23 trivy-purls.txt syft-purls.txt
# Generate an SBOM for a Python project from its lockfile
cyclonedx-py requirements -i requirements.txt -o sbom-python.cyclonedx.json
When two generators disagree, neither is automatically right. Investigate the differing entries by hand, check whether one tool missed an ecosystem, and record the decision so the next run does not re-litigate it.
3. Signing and distributing SBOMs
An unsigned SBOM is a claim anyone can forge, so sign it with the same identity used for the artifact and publish it where consumers already look, next to the release. Attestation (binding the SBOM to the artifact digest) is stronger than a detached signature file, because it prevents pairing a clean SBOM with a different artifact.
# Sign the SBOM with cosign using keyless signing
cosign sign-blob --yes sbom.cyclonedx.json --output-signature sbom.sig
# Verify a signed SBOM before consuming it
cosign verify-blob --signature sbom.sig sbom.cyclonedx.json
# Attest the image with its SBOM so the two cannot be separated
cosign attest --yes --predicate sbom.cyclonedx.json --type cyclonedx myapp:1.2.3
# Publish the SBOM next to the release artifact
cp sbom.cyclonedx.json "releases/1.2.3/sbom.cyclonedx.json"
cp sbom.sig "releases/1.2.3/sbom.cyclonedx.json.sig"
sha256sum "releases/1.2.3/sbom.cyclonedx.json"
Publish SBOMs for every supported release, including patch releases, and keep old SBOMs available. Incident response for a two-year-old release is impossible if its SBOM was overwritten by the current one.
4. Consuming SBOMs and correlating vulnerabilities
Consumption is where SBOMs pay off. Feed the SBOM into a scanner on a schedule, not just at build time, because new CVEs are disclosed against old components every day. A VEX (Vulnerability Exploitability eXchange) statement records a human judgment that a vulnerable component is not exploitable in a specific product, for example because the vulnerable code path is never called, and it stops the same CVE from paging the team every week.
# Scan an SBOM for known vulnerabilities without rebuilding anything
grype sbom:sbom.cyclonedx.json -o table
grype sbom:sbom.cyclonedx.json -o json > vuln-report.json
# Correlate against OSV data for a second opinion
osv-scanner --sbom sbom.cyclonedx.json --format json > osv-report.json
# Find every shipped product that contains one vulnerable component
for sbom in releases/*/sbom.cyclonedx.json; do
if jq -e '.components[] | select(.purl | contains("pkg:npm/lodash@4.17.20"))' "$sbom" > /dev/null; then
echo "AFFECTED - $sbom"
fi
done
# Record a VEX statement for a component that is not exploitable here
cat > vex-lodash.json <<'EOF'
{
"bomFormat": "CycloneDX",
"specVersion": "1.5",
"version": 1,
"vulnerabilities": [
{
"id": "CVE-2020-8203",
"affects": [{ "ref": "pkg:npm/lodash@4.17.20" }],
"analysis": {
"state": "not_affected",
"justification": "code_not_reachable",
"detail": "The vulnerable prototype pollution path is never called by this service."
}
}
]
}
EOF
A VEX "not_affected" claim needs evidence, not optimism. Link the statement to the code review or test that proved the path is unreachable, and re-check it when the component or the calling code changes.
Edge cases
- SBOMs for dynamically linked system libraries. A generator that only reads language manifests misses operating system packages in the image. Always generate from the built image as well as from source, and diff the two inventories.
- Vendored and copied code. Code pasted into a repository has no package manager entry and no version, so it never appears in an SBOM. Track vendored code in a separate inventory file and review it on the same CVE schedule.
- SBOMs that leak internal information. An SBOM lists exact versions of everything you ship, which is useful to attackers too. Publish SBOMs to customers and auditors under the same access controls as release artifacts, not on a public URL by default.
- Rebuilt artifacts with identical tags. If an image tag is rebuilt without a version bump, the old SBOM no longer describes it. Treat tags as mutable, pin by digest, and regenerate the SBOM on every rebuild.
- Components with no purl or no version. Some generators emit entries without a package URL, which breaks correlation. Reject SBOMs with unnamed or unversioned components in CI and fix the generator configuration instead of shipping a partial inventory.
- License-only SBOM requests. A customer may ask for an SBOM to check licenses, not vulnerabilities. The same inventory serves both, but license conclusions need a license scanner pass, not just the component list.
Key references
- SPDX Specification, Linux Foundation (spdx.dev)
- CycloneDX Specification, OWASP (cyclonedx.org)
- NTIA Minimum Elements for a Software Bill of Materials
- VEX Specification, CycloneDX (cyclonedx.org/capabilities/vex)
- CISA Software Bill of Materials guidance (cisa.gov)
- Executive Order 14028 software supply chain requirements
- Trivy documentation on SBOM generation (aquasecurity.github.io)
- OWASP Software Component Verification Standard
