Stop collecting SBOMs. Start diffing them.
An SBOM nobody reads is just a compliance artifact. The diff between two releases is where the signal is.
Most teams I talk to generate an SBOM on every build and store it somewhere. Then nobody looks at it again until an auditor asks.
A single SBOM isn’t very useful on its own. A list of eight hundred components tells a reviewer almost nothing. The difference between this release and the last one is useful, because it answers the questions that matter during review:
- What new components came in?
- Did any license change?
- Did a transitive dependency jump a major version without anyone asking?
- Is anything new on a known-exploited list?
- Did a component change publisher or source repository?
That last question catches the quiet supply chain attacks: a package taken over by a new maintainer, or a name that suddenly resolves to a different registry than it used to.
Generate SBOMs you can compare
A diff is only as good as the two documents going into it. Three habits make SBOMs comparable from one build to the next.
Pin the generator. Syft, like every SBOM tool, changes what it detects between releases. If the CI image floats to the latest version, a tool upgrade shows up as fifty “new” components nobody added. Pin the image by version and upgrade it in its own merge request.
Pick one format and stay with it. CycloneDX and SPDX both work. Mixing them means translating, and translation loses fields. I use CycloneDX JSON because purls and hashes sit in predictable places.
Scan the same thing every time. A source-tree SBOM reads lockfiles. An image SBOM reads what was actually installed, including the base image’s OS packages. Both are worth having, but compare source to source and image to image.
# Source tree, from the lockfiles
syft dir:. -o cyclonedx-json=sbom-src.cdx.json
# The built image, by digest rather than tag
syft "$CI_REGISTRY_IMAGE@$IMAGE_DIGEST" -o cyclonedx-json=sbom-image.cdx.json
Scanning by digest matters. A tag can move between the build and the scan, and then the SBOM describes an image you never shipped.
Diff on identity, not on names
A plain text diff of two SBOMs is noise. Field order changes, serial numbers and timestamps change, and the same component can appear under two spellings. Compare on the package URL (purl) with the version split out, so that pkg:npm/[email protected] becomes “left-pad, 1.2.0 to 1.3.0” and not one removal plus one addition.
A few lines of jq get you most of the way:
ident() {
jq -r '.components[]? | select(.purl)
| "\(.purl | split("@")[0])\t\(.version)\t\(.hashes[0].content // "-")"' "$1" \
| LC_ALL=C sort -u
}
ident sbom-base.cdx.json > base.tsv
ident sbom-head.cdx.json > head.tsv
# Components that exist only in the new release
LC_ALL=C comm -13 <(cut -f1 base.tsv | LC_ALL=C sort -u) <(cut -f1 head.tsv | LC_ALL=C sort -u)
# Same component, different version or hash
LC_ALL=C join -t $'\t' base.tsv head.tsv | awk -F'\t' '$2 != $4 || $3 != $5'
Keep the hashes where your generator records them. If the version stayed the same and the hash changed, someone republished a release under an existing version number, and you want to know why before it ships. A component that lists two versions at once will print more than one line in the join. That’s usually a real finding too, since it means two copies of the same library are bundled.
Check the new components, not all of them
Vulnerability scanning the whole SBOM on every merge request buries the reviewer in findings they inherited years ago. Scan everything nightly. On the merge request, look hardest at what the merge request added.
Grype reads a CycloneDX file directly:
grype sbom:sbom-head.cdx.json -o json > grype.json
Then cross the results against the CISA Known Exploited Vulnerabilities catalog, which CISA publishes as a JSON feed:
curl -sSf -o kev.json \
https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json
LC_ALL=C comm -12 \
<(jq -r '.matches[] | .vulnerability.id, (.relatedVulnerabilities[]?.id)' grype.json | LC_ALL=C sort -u) \
<(jq -r '.vulnerabilities[].cveID' kev.json | LC_ALL=C sort -u)
Grype reports some matches under a GitHub advisory ID, which is why the filter also pulls the related CVE IDs. Anything that comes out of that second command is exploited in the wild today. That deserves a blocked merge, not a ticket. In an air-gapped factory, mirror the KEV feed and the Grype database on a schedule and record the date of each mirror, because a scan against a three-month-old database will pass things it shouldn’t.
Make the diff a gate
I run the diff as a CI job that posts a short report to the merge request and fails on policy hits. A new dependency then needs a human to approve it, the same way new code does.
The base SBOM comes from the target branch’s last successful pipeline. GitLab’s job artifacts API serves it by branch name and job name, and the job token is enough to read it from the same project:
default:
image: "$CI_REGISTRY/platform/tools/sbom-tools:1.4" # internal image: pinned syft, grype, jq, curl
sbom:
stage: build
script:
- syft dir:. -o cyclonedx-json=sbom.cdx.json
artifacts:
paths: [sbom.cdx.json]
reports:
cyclonedx: sbom.cdx.json
sbom-diff:
stage: verify
needs: [sbom]
script:
- >
curl -sSf --header "JOB-TOKEN: $CI_JOB_TOKEN" -o sbom-base.cdx.json
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME/raw/sbom.cdx.json?job=sbom"
- cp sbom.cdx.json sbom-head.cdx.json
- ./ci/sbom-diff.sh sbom-base.cdx.json sbom-head.cdx.json > diff.md
artifacts:
paths: [diff.md]
when: always
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
The tools image is an example name. I build one internal image with pinned versions of each tool rather than pulling the upstream images, which ship without a shell. ci/sbom-diff.sh holds the commands from the previous sections and exits non-zero when policy says so. I’m building the same logic into the SBOM Diff tool on the products page, which is still in development, but a shell script is enough to start.
The policy stays short. Mine fails the job on four things:
- A new license outside the allow list.
- A new component with a vulnerability in the KEV catalog.
- A hash change on an unchanged version.
- A new direct dependency with no owner listed in the code owners file.
Everything else is reported but doesn’t block.
Failure modes I see
The base SBOM is missing. Artifacts expire, or the target branch’s last pipeline failed before the SBOM job ran. If the diff job quietly treats “no base” as “no changes,” every merge request passes. Make a missing base fail loudly, and set the artifact expiry on the default branch long enough to cover your slowest release cycle.
The generator changed underneath you. Covered above, and it’s still the most common source of false alarms I find.
Components without purls. Vendored code, binaries copied into the image and C libraries built from source often come out with a name and nothing else. They drop out of a purl-based diff entirely. List them separately and review that list by hand.
Nobody reads the report. A gate that fires on every merge request gets switched off within a month. Two habits keep this one alive. Diff against the target branch, not the last tagged release, so each merge request only shows its own changes. And collapse purely transitive patch updates into one summary line. Reviewers read the top of the report and skip the rest.
Where this lands in the standards
NIST SP 800-218, the Secure Software Development Framework, asks you to collect, safeguard, maintain and share provenance data for all components of each release, for example in an SBOM (PS.3.2). It also asks you to acquire and maintain well-secured components (PW.4.1) and to gather information on vulnerabilities in the software you use (RV.1.1). The NTIA’s Minimum Elements for a Software Bill of Materials describes the fields an SBOM needs, and the unique identifier it calls for is exactly what makes a diff possible. The KEV catalog exists under CISA Binding Operational Directive 22-01; that directive binds federal civilian agencies, not contractors, but the catalog is the best public signal I know of for what attackers are using right now.
The DoD Enterprise DevSecOps Fundamentals and the DevSecOps Reference Designs put software composition analysis in the pipeline as a standard tool. They don’t prescribe diffing. Diffing is my answer to the practical problem of doing composition analysis every day without drowning the team in noise.
Want a second set of eyes on your pipeline?
SBOM generation, dependency intake and the gates around them are part of every pipeline security review I do. It’s a fixed-scope look at one pipeline from first commit to deploy, mapped to NIST SP 800-218. If you aren’t sure where to start, book a free 30-minute fit call.