Scanning images for vulnerabilities
How image scanners turn a package list into CVE reports, why most findings have no fix, and how to gate CI on the ones that matter with Scout, Trivy or Grype.
Choosing a base imageImage names: repositories, tags and digests
Scanning images for vulnerabilities
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A scanner does two things: it inventories the packages in an image, an SBOM, and matches each name and version against vulnerability databases.
- Distribution packages must be matched against the distribution's own advisories. Debian and Red Hat backport fixes without changing the upstream version number.
- Most findings in a fresh image have no fix available yet. Filter to fixable ones with `--ignore-unfixed` (Trivy), `--only-fixed` (Scout, Grype) when deciding what to act on.
- Severity alone is a poor priority. Reachability, exploit data such as CISA's KEV list, and VEX statements from the image maker tell you what actually matters.
- Images rot. An image with no findings today will have some next month, so rebuild on a schedule to pick up base-image fixes, and rescan what is running.
- `docker scout cves`, `trivy image` and `grype` all scan local or remote images and can fail a CI job with an exit code above a severity threshold.
- The scanner is part of your supply chain. In March 2026 a compromised Trivy release and GitHub Action stole CI credentials, so pin scanners by version or digest.
You ship more than your code
A typical image is a few megabytes of your application on top of a few hundred megabytes of someone else’s operating system. Every package in that base, openssl, curl, libxml2, glibc, will have vulnerabilities published against it over time. You didn’t write them, but you deploy them. Scanning is how you find out which ones you have.
How a scanner works
Every scanner, Docker Scout, Trivy or Grype, does the same two steps.
- Inventory. It reads the image’s layers and lists what is installed: the Debian or Alpine package database,
node_modules, Python site-packages, Go module data compiled into binaries. That list is an SBOM, a software bill of materials. - Matching. For each package name and version it looks up advisories in databases: the distribution’s security tracker for OS packages, GitHub’s advisory database and OSV for language packages, and NVD for severity data.
To see both steps without a scanner, I did them by hand. Docker’s official images carry an SBOM attestation, as DevOps’ registries, tags and image provenance showed. I downloaded the SPDX SBOM for nginx:latest (amd64) from Docker Hub: 236 packages, including openssl 3.5.9-1~deb13u1 and curl 8.14.1-2+deb13u7, each with a package URL such as pkg:deb/debian/openssl@3.5.9-1~deb13u1?os_version=13.
Then I sent the 234 Debian entries to OSV’s batch query API with the ecosystem Debian:13. On 2026-11-28 it returned 220 matches across 38 packages. curl had 39, libxml2 20, openssl 14.
Why most findings don’t need a ticket
Then I asked of each match: does Debian 13 have a fixed version? 216 of the 220 had no fix available yet. All 14 openssl entries were recent CVEs whose Debian urgency was “not yet assigned”. Only two vulnerabilities had a fixed package, one in libzstd and one in shadow, each reported twice (once as a CVE entry, once as a Debian security advisory).
That ratio is normal, and it explains why teams drown in scanner output. A finding with no fix can’t be resolved by updating. You track it, and you act if it becomes exploitable in your context. A finding with a fix means rebuilding on a newer base. Every scanner has a switch for this:
docker scout cves --only-fixed --only-severity critical,high myapp:1.4.2
trivy image --ignore-unfixed --severity HIGH,CRITICAL myapp:1.4.2
grype myapp:1.4.2 --only-fixed --fail-on high
My hand-matching was naive in one way real scanners aren’t: I matched by package name, and OSV’s Debian data is keyed by source package. A binary package like libssl3t64 comes from the source package openssl, so a real scanner maps binaries to sources first.
Backports: why version numbers lie
Debian, Ubuntu and Red Hat don’t upgrade a library to a new upstream release in a stable distribution. They patch the fix into their own build and bump only the package revision: 3.5.9-1~deb13u1, then ~deb13u2. Compared against upstream OpenSSL’s advisories, that version looks vulnerable forever. This is why good scanners use the distribution’s own advisory feed for OS packages, and why a scanner that doesn’t is noisy.
The SBOM showed a subtler case. nginx 1.31.10-1~trixie is labelled as a Debian package, but it comes from nginx.org’s repository, not Debian’s. Debian’s advisories don’t describe it at all.
Deciding what matters
Severity scores describe the worst case, not your case. Better signals:
- Fix available. As above.
- Exploited in the wild. CISA’s Known Exploited Vulnerabilities list. Scout can filter to it with
--only-cisa-kev, and EPSS scores estimate the probability of exploitation. - Reachable. A vulnerable XML parser in an image that never parses XML is a lower risk.
- VEX. A Vulnerability Exploitability eXchange document is a signed statement from the image maker that a CVE does not affect their image, and why. Scout and Trivy can read VEX to suppress those findings.
The cheapest reduction is a smaller base. Fewer packages means fewer findings, which is why choosing a base image matters more than any scanner setting.
Images rot
A scan describes an image on a date. The image is frozen, the vulnerability databases are not. An image that scanned clean in January will report new CVEs in March with no change to a single byte. Two habits follow: rebuild your images on a schedule, not only when your code changes, so they pick up patched base packages; and rescan what is deployed, not only what you are about to deploy. Scout’s compare and recommendations commands are built for this, showing what a newer base image would fix.
The scanner is a dependency too
On 19 March 2026, an attacker with stolen credentials published a malicious Trivy v0.69.4 and force-pushed 76 of 77 version tags of the aquasecurity/trivy-action GitHub Action to credential-stealing code. Three days later they pushed malicious Trivy images to Docker Hub. GitHub’s advisory, GHSA-69fq-xp46-6x23, lists who was affected: anyone who pulled those versions or latest during the window. Unaffected: anyone who referenced the images by digest, or used versions protected by immutable releases.
A scanner runs inside CI with registry credentials in reach. Pin it like any other dependency: a fixed version, Actions by commit SHA, images by digest, and verify signatures where offered, as the next lesson explains.
About the video
The embed is all of Adrian Dolinay’s “Security Scans for Docker Images using Trivy!”, January 2025, 5 minutes 48 seconds. The chapters cover installing Trivy, scanning an image, filtering to critical vulnerabilities, comparing images built on different base operating systems, JSON output, listing only vulnerabilities with a fixed version, and dealing with what you find. It is short and practical, and fits the “fix available” theme of this lesson. It predates the March 2026 compromise, and it doesn’t cover how matching works or VEX, which the lesson adds. English is confirmed by YouTube’s “English (US) original” audio flag. The Docker Scout walkthrough in deeper is from 2023, when docker scout was new; its main commands still exist.
What was run: the nginx:latest SBOM attestation was downloaded from Docker Hub’s registry API and parsed, and its Debian packages were matched against OSV’s API, then each match checked for a Debian 13 fixed version. No scanner was installed and no image was scanned with Scout, Trivy or Grype. Their flags are from their current CLI references, the incident from GitHub’s advisory, all checked 2026-11-28.
Where this fits
Scanning tells you what is in an image. Signing tells you who built it and that it hasn’t changed since: signing and verifying images.
Check yourself
Debian's openssl is version 3.5.9-1~deb13u1. A scanner using only upstream OpenSSL data flags a CVE fixed upstream in 3.5.10. Is the image vulnerable?
Not necessarily. Debian often backports fixes into its own package revisions without changing the upstream version, so only Debian's security tracker can say whether 3.5.9-1~deb13u1 is fixed.
A scan of a freshly built image reports 200 vulnerabilities. What filter turns that into an actionable list, and why?
Show only vulnerabilities with an available fix, then sort by severity and exploit data. Unfixed ones can't be resolved by updating; they are tracked, not acted on.
Your image scanned clean in January. Nothing in your code changed. Why does it fail the scan in March?
New CVEs were published against packages already in the image. The image didn't change; the vulnerability database did. Rebuild on an updated base image.
How do you make a CI job fail only for fixable HIGH or CRITICAL vulnerabilities with Trivy?
trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 <image>.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.