Putting SBOMs to Work: From Build Artifact to Incident Response
A software bill of materials is only useful if you can query it when a new vulnerability lands. Learn how to generate SBOMs for container images, store and sign them by digest, scan them later and answer which of our systems use this package in minutes.
Putting SBOMs to Work: From Build Artifact to Incident Response
A new vulnerability is announced in a widely used library. Within an hour, someone asks the question every security and platform team dreads: which of our systems use it?
Without good data, answering means rescanning every image, searching repositories by hand and asking teams to check their own services. It can take days, and the answer is often incomplete.
A software bill of materials (SBOM) is meant to make this fast. It is a machine-readable list of the components inside a piece of software: packages, libraries, versions and identifiers. But many organizations generate SBOMs only to satisfy a requirement, store them somewhere nobody looks, and never use them. An SBOM that cannot be queried during an incident is just paperwork.
This guide shows how to generate SBOMs for container images, store them so they map to what is actually running, sign them, scan them for new vulnerabilities and use them to answer the "are we affected?" question quickly.
SBOM Basics
Two formats dominate:
- SPDX, a standard originally focused on license compliance and now widely used for security.
- CycloneDX, a standard designed with security use cases in mind.
Both are supported by common tools, and either works for the workflow in this guide. Pick one for consistency. The examples here use CycloneDX JSON.
Each component in an SBOM usually includes a name, a version and a package URL (purl), a standardized identifier such as pkg:npm/express@<version> or pkg:deb/debian/openssl@<version>. The purl is what makes SBOMs reliably searchable across ecosystems.
Step 1: Generate SBOMs for Your Images
You can generate SBOMs from built images with open source tools. Syft is a popular choice:
syft registry.example.internal/api:2.4.0 -o cyclonedx-json > api-2.4.0.cdx.json
Trivy can produce the same kind of output:
trivy image --format cyclonedx --output api-2.4.0.cdx.json registry.example.internal/api:2.4.0
Both commands read the image and write a local file. They do not change the image or the registry.
Generate at Build Time
The most reliable place to create SBOMs is the build pipeline, right after the image is built. Docker BuildKit can generate an SBOM and attach it to the image as an attestation:
docker buildx build --sbom=true --push -t registry.example.internal/api:2.4.0 .
The SBOM is stored in the registry alongside the image. You can view it with:
docker buildx imagetools inspect registry.example.internal/api:2.4.0 --format '{{ json .SBOM }}'
This requires a registry that supports storing attestations alongside images.
Know the Limits
SBOM tools mostly work by finding package metadata: operating system package databases, language lock files and manifests embedded in binaries. They can miss components that leave no metadata, such as vendored source code, manually copied binaries or some statically linked libraries. Treat an SBOM as a strong but not perfect inventory, and prefer building from lock files so dependency information is available to the tools.
Step 2: Store SBOMs by Image Digest
The biggest mistake is storing SBOMs by tag. Tags move, so an SBOM labeled api:2.4.0 may not describe the image that is actually running. Store each SBOM keyed by the image digest, which identifies exact image content.
Get the digest when the image is pushed:
docker buildx imagetools inspect registry.example.internal/api:2.4.0 --format '{{ .Manifest.Digest }}'
Then store the SBOM where it can be found by that digest. Common options include:
- As an attestation in the registry, attached to the image itself, as in the BuildKit example.
- In an artifact store or object storage bucket, with the digest in the file name or metadata.
- In a dedicated SBOM management platform, if your organization runs one.
Whatever you choose, keep SBOMs for at least as long as the corresponding images might be running. An SBOM deleted after 30 days is no help for an image that has been in production for a year.
Step 3: Sign SBOMs So They Can Be Trusted
If an SBOM can be altered, it cannot be trusted during an incident. Signing ties the SBOM to the image and proves who produced it. With cosign, you can attach an SBOM to an image as a signed attestation:
cosign attest --type cyclonedx --predicate api-2.4.0.cdx.json \
registry.example.internal/api@sha256:<digest>
This pushes a signed attestation to the registry. It changes registry contents, so run it from your pipeline with the appropriate signing identity, whether keyless signing tied to your CI identity or a managed key.
Consumers can then verify the attestation before relying on it:
cosign verify-attestation --type cyclonedx \
registry.example.internal/api@sha256:<digest>
Verification requires options matching your signing setup, such as the expected key or the expected identity and issuer for keyless signing. Check the cosign documentation for the flags that apply to your configuration.
Step 4: Scan SBOMs Instead of Rescanning Images
Once you have SBOMs, you can check them against vulnerability databases at any time, without pulling and unpacking images again. This is much faster, and it works even for images that are hard to access.
grype sbom:./api-2.4.0.cdx.json
# or
trivy sbom api-2.4.0.cdx.json
Both commands read the SBOM and query vulnerability data. Run them on a schedule across all stored SBOMs for images that are still in use. New vulnerabilities are disclosed every day, so an image that was clean at build time may not be clean today. Scanning SBOMs regularly catches that without rebuilding anything.
Step 5: Answer "Are We Affected?" in Minutes
This is the payoff. When a vulnerability is announced in a specific package, search your stored SBOMs directly.
To list every component in a single CycloneDX SBOM:
jq -r '.components[]? | [.name, .version, (.purl // "")] | @tsv' api-2.4.0.cdx.json
To find every SBOM in a directory that contains a given package, along with its version:
PKG=openssl
for f in sboms/*.cdx.json; do
jq -r --arg n "$PKG" --arg f "$f" \
'.components[]? | select(.name == $n) | [$f, .name, .version] | @tsv' "$f"
done
Both commands only read local files. Matching by name is a quick first pass. For precise results, match on the purl, which includes the package ecosystem and avoids confusing packages with similar names from different ecosystems.
The output tells you which images contain the package and at what version. Compare those versions with the affected ranges in the vulnerability advisory to narrow the list.
Connect Images to Running Systems
Knowing which images are affected is only half the answer. You also need to know where those images run. Because SBOMs are stored by digest, you can match them with the digests reported by your runtime. In Kubernetes, for example:
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{range .status.containerStatuses[*]}{.imageID}{" "}{end}{"\n"}{end}'
This read-only query prints each pod with the image digests it is running. Join that list with the digests of affected SBOMs, and you have a list of affected workloads, by namespace and name, that you can hand to the owning teams.
Step 6: Reduce Noise with VEX
SBOM scans can report vulnerabilities in components that are present but not exploitable in your context, for example a vulnerable function that your application never calls. VEX (Vulnerability Exploitability eXchange) documents let you record that assessment in a machine-readable way, stating that a product is "not affected" by a vulnerability and why.
Some scanners can read VEX documents and suppress findings marked as not affected. Use this carefully: every VEX statement should be justified, reviewed and revisited when the software changes.
Security Considerations
- SBOMs are sensitive. A complete list of your components and versions is useful to attackers looking for weak spots. Control who can read stored SBOMs, especially for internal systems.
- Verify before you trust. Unsigned SBOMs, especially from third parties, can be incomplete or inaccurate. Prefer signed attestations, and verify them before relying on them for decisions.
- An empty result is not proof. If a package does not appear in an SBOM, that may mean the tool could not detect it. For critical vulnerabilities, combine SBOM searches with other checks, such as runtime inspection or direct image scans.
- Cover third-party software too. Ask vendors for SBOMs of the software and images you run, and store them alongside your own.
- Keep SBOM generation in the trusted pipeline. SBOMs produced on developer laptops or outside your build system are harder to trust and to keep consistent.
Making SBOMs Part of Your Inventory
SBOMs are most valuable when connected to the rest of your infrastructure data: which images run on which hosts and clusters, who owns them and how they are exposed. Without that connection, an SBOM can tell you that an image is affected but not where it runs. Linking component data to a live view of your infrastructure is the kind of visibility AtGlance focuses on. Whatever tooling you use, keying SBOMs by digest and joining them with runtime data is what makes that link possible.
Conclusion
An SBOM is only useful if you can query it when it matters. Generate SBOMs in your build pipeline, store them by image digest rather than tag, and sign them so they can be trusted. Scan them regularly to catch newly disclosed vulnerabilities without rebuilding images, and use simple queries to find affected components in minutes. Finally, join SBOM data with the digests actually running in your environments, so "are we affected?" becomes a quick lookup instead of a days-long investigation.