How do you scan an SBOM for vulnerabilities with Grype or Trivy?
BeginnerHands-onSBOM
Answer
Short answer
Feed the SBOM file to a scanner: grype sbom:./sbom.json or trivy sbom ./sbom.json. The scanner matches every component and version against its vulnerability database — without needing the original image or source code.
Commands
grype sbom:./sbom.cdx.json
grype sbom:./sbom.cdx.json --fail-on high # exit non-zero for high+
trivy sbom sbom.cdx.json
trivy sbom --severity CRITICAL --exit-code 1 sbom.cdx.json
Why scan an SBOM instead of the image?
- Speed — no need to pull a large image again.
- Historical releases — rescan last year's release with today's CVE data.
- Third-party software — scan a vendor's SBOM when you don't have their image or code.
- Separation of duties — build generates the SBOM once; security tooling scans it repeatedly.
Typical flow
build → syft → sbom.cdx.json (stored) → grype/trivy nightly → alerts on new CVEs
What to say in the interview
"grype sbom: or trivy sbom scans the inventory against current vulnerability data without the artifact itself, which makes rescanning old releases and vendor software quick. We generate the SBOM once at build and rescan it on a schedule."
More on SBOM
What is an SBOM and how do you generate one?BeginnerWhat is an SBOM and why does it matter?BeginnerWhat are SPDX and CycloneDX?BeginnerHow do you generate an SBOM with Syft?BeginnerWhat should an SBOM contain? (NTIA minimum elements)IntermediateWhat is the difference between an SBOM from source and an SBOM from a container image?Intermediate