TExcelTAD

Field Notes: SBOMs & Scans

Habits from teams that run SBOM and scanning programs in production, each with the failure it prevents.

1. An SBOM nobody can find is worth nothing

The first real use of an SBOM is usually months after it was generated: a new critical CVE lands and someone asks "are we affected, and where?". If the SBOM was a CI artifact that expired after 30 days, the answer is "let's rebuild everything and see". Store every release's SBOM keyed by the artifact digest, keep it as long as the release can run anywhere, and make it queryable.

The simplest version is a directory (or bucket) of SBOMs named by digest, plus a re-scan job:

bash · try it yourself
mkdir -p sbom-store && cd sbom-store
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/edge:1.0 > /dev/null 2>&1
store() {   # store <image ref> <name> <version>: SBOM file named after the digest
  local d; d=$(crane digest "$1")
  syft scan "registry:$1" -q --source-name "$2" --source-version "$3" -o cyclonedx-json="${d#sha256:}.cdx.json"
}
store localhost:5000/shop/edge:1.0 edge-proxy 1.0
syft scan /opt/samples/node-app -q --source-name storefront --source-version 1.0.0 -o cyclonedx-json=storefront-1.0.0.cdx.json
cp /opt/samples/sbom/legacy-service.cdx.json legacy-service-0.9.0.cdx.json
ls | sed -E 's/^([0-9a-f]{12})[0-9a-f]+/\1…/'
echo "--- nightly re-scan of every stored SBOM, gate on known-exploited only"
for f in *.cdx.json; do
  name=$(jq -r '.metadata.component | "\(.name) \(.version)"' "$f")
  kev=$(grype "sbom:$f" -q --by-cve -o json | jq -r '[.matches[] | select((.vulnerability.knownExploited // []) | length > 0) | .vulnerability.id] | unique | join(",")')
  echo "$name: ${kev:-no known-exploited vulnerabilities}"
done
f04ffda0b140….cdx.json
legacy-service-0.9.0.cdx.json
storefront-1.0.0.cdx.json
--- nightly re-scan of every stored SBOM, gate on known-exploited only
edge-proxy 1.0: no known-exploited vulnerabilities
legacy-service 0.9.0: CVE-2021-44228,CVE-2021-45046
storefront 1.0.0: no known-exploited vulnerabilities

In production this becomes Dependency-Track, GUAC, a registry that stores SBOM attestations next to images, or a table in your data warehouse. The important properties are the same: keyed by digest, kept for the life of the release, re-scanned on a schedule against a fresh database.

2. Zero findings is not "safe"

A scanner only reports vulnerabilities in components it recognised, matched against advisories that already exist. A clean report can mean the software is fine, or that the SBOM is blind to it. Software copied into an image without a package manager is the classic blind spot:

bash · try it yourself
mkdir -p img/app/vendor && cd img
cp /opt/samples/node-app/package.json app/
printf '/* lodash 4.17.15, copied from a CDN years ago */\nmodule.exports = {};\n' > app/vendor/lodash.js
tar --sort=name --mtime=@$SOURCE_DATE_EPOCH --owner=0 --group=0 --numeric-owner -cf layer.tar app
crane append -f layer.tar -t localhost:5000/shop/blind:1 > /dev/null 2>&1
echo "packages found: $(syft scan registry:localhost:5000/shop/blind:1 -q -o json | jq '.artifacts | length')"
echo "vulnerabilities: $(grype registry:localhost:5000/shop/blind:1 -q -o json | jq '.matches | length')"
packages found: 1
vulnerabilities: 0

The image ships lodash 4.17.15, yet Syft finds a single package (the application itself, node-app, from its package.json) and Grype reports nothing: package.json declares dependencies, but without a lockfile or an installed node_modules/lodash/package.json there is no evidence of which lodash, and the vendored file has no metadata at all. Same for binaries fetched with curl in a Dockerfile, statically linked C libraries and code pasted into the repository. Countermeasures:

  • install through package managers, with lockfiles, so evidence exists;
  • add components the tools can't see to the SBOM by hand (CycloneDX and SPDX both allow it) or with Syft's binary classifiers;
  • treat "0 packages found" (or only the application itself) in an image you know has dependencies as a failed scan;
  • and remember that zero known vulnerabilities says nothing about the next xz-utils.

3. Scan what you ship, from the SBOM you publish

Generate one SBOM per artifact, from the final image (not only the source tree: base-image packages and build-time downloads appear only in the image), attest it, and scan that SBOM. A source-only SBOM misses the OS layer; an image SBOM generated by a different tool than the one you scan with makes the two disagree.

4. Always record which database answered

Every report should say which scanner version and database build date produced it (grype db status, trivy version). "The scan on 3 March was clean" is only meaningful with "…against the DB of 3 March". It also explains, months later, why an old report missed a CVE published after it.

5. Gate on what you will act on

A gate that blocks on every medium finding gets bypassed within a week. Start with what the team will fix immediately (known-exploited, critical with a fix), report the rest in a dashboard, and tighten gradually. Make the gate fail on new findings in a pull request rather than on all historical debt, and record exceptions as VEX or expiring ignore rules (Ignore Rules, VEX).

6. Patch by rebuilding, not by patching images

Fixing an OS vulnerability means rebuilding on an updated base image and redeploying, not apk upgrade in a running container. That requires being able to rebuild any release quickly: pinned inputs, reproducible builds and an update bot that bumps base-image digests (Tags vs Digests). End-of-life bases (Trivy's EOSL: true) can't be patched by rebuilding at all; plan the major upgrade.

Test yourself

A scan of an image reports 0 packages and 0 vulnerabilities, but the image contains an application. What should CI do?

  1. Pass: nothing to fix
  2. Treat it as a failed scan: the SBOM generator found no evidence, so the result means nothing
  3. Retry with --only-fixed
  4. Switch to Trivy

Why store SBOMs keyed by image digest rather than by tag?

  1. Digests are shorter
  2. The digest identifies exactly what was deployed; tags move
  3. Tags can't contain dots
  4. Registries require it

Why should every scan report include the vulnerability database's build date?

  1. For licensing
  2. Results depend on the database; without the date, a clean report can't be interpreted later
  3. Grype requires it
  4. To compute EPSS