Sub topic 15
Why Docker Scout and Trivy can disagree
This chapter assumes you can run docker scout cves and trivy image. It also assumes you know what a CVE ID, a severity rating and a fixed version are, and what an SBOM is. If you scan the same image with both tools, you will often get different counts. This chapter explains why, and how to decide whether a difference matters.
The working model
A scanner does two jobs.
- Inventory: work out which packages and versions are in the image.
- Matching: compare each package against advisory data and report the ones that are affected.
Both tools do both jobs, but each makes its own choices at each step. A difference in either step changes the result. Neither tool is "wrong" by default. They are answering slightly different questions with slightly different data.
Difference 1: how packages are found
The inventory step is the most common source of missing or extra findings.
- Trivy unpacks the image layers and analyzes the filesystem. It reads OS package databases such as
/var/lib/dpkg/statusand language files such as lock files and manifests. It can also read dependency data embedded in some compiled binaries. - Docker Scout builds an SBOM for the image from the image contents. If the image carries an SBOM attestation from the build, Scout can use that instead.
A package can therefore appear in one inventory and not the other. Typical cases:
- A library copied into the image by hand, with no package manager record.
- A language dependency that is declared in a manifest but not in a lock file.
- A statically linked Go binary, where version data exists only if the toolchain embedded it.
- A package installed in an early layer and removed in a later one. The data is still in the image, but whether a tool reports it depends on how it merges layers.
Compare the inventories first. If the tools disagree about what is installed, the findings cannot agree.
Difference 2: advisory sources
A vulnerability database is not one list. Each tool combines several upstream sources and tracks them on its own schedule.
| Source type | Examples | What it is good for |
|---|---|---|
| Distribution trackers | Debian Security Tracker, Alpine secdb, Red Hat, Ubuntu | Accurate fixed versions for OS packages |
| Ecosystem advisories | GitHub Advisory Database, language-specific databases | Language dependencies |
| General databases | NVD | Broad coverage, but generic version ranges |
The mix and the priority between sources differ per tool. This has real effects:
- Fixed versions. A distribution often backports a fix without raising the upstream version number. A distribution-aware match says "fixed in
1.2.3-4+deb12u1". A match that only compares upstream versions may report the package as vulnerable. Check the fixed version each tool reports. - Coverage lag. One database may receive a new advisory hours or days before the other. Scanning at different times can alone cause a difference.
- Different IDs. A tool may report a GitHub advisory ID (
GHSA-...) where another reports the matching CVE. A naive comparison counts these as two separate findings.
Difference 3: severity and fix status
The same CVE can carry different severities. A vendor may rate it Medium for its own build, while NVD rates it High. Each tool picks a source by its own rules. Trivy records which source it used in the SeveritySource field of its JSON output. If you gate a build on HIGH,CRITICAL, a rating difference moves a finding across the gate even though the CVE is the same.
Fix status differs as well. Distributions label some findings as "will not fix" or "fix deferred". The unfixed filters treat these in tool-specific ways:
- Trivy:
--ignore-unfixedhides vulnerabilities that have no fixed version. - Scout:
--only-fixedshows only vulnerabilities that have a fix available.
These look equivalent but are not guaranteed to produce identical sets. A "will not fix" finding has no fix, but whether it counts as unfixed depends on how each tool reads the distribution data.
Difference 4: scope and context
- Base image awareness. Scout can relate findings to the base image and suggest updates in its
recommendationsoutput. This is why it can say a finding comes from the base layer. Trivy reports packages and layers but does not suggest a replacement base image. - Exploitability data. Some findings are marked as not affecting the image through VEX statements (machine-readable "not affected" notes). A tool that applies such statements will report fewer findings than one that does not.
- Extra scanners.
trivy imagecan also scan for secrets and misconfigurations. Restrict it with--scanners vulnwhen you only want a like-for-like comparison. - Platform. A multi-platform image holds one filesystem per architecture. Make sure both tools scan the same one.
Comparing the results by script
Do not compare screenshots or totals. Compare sets of vulnerability IDs for the same image digest. This script assumes docker, trivy and jq are installed, and that Docker Scout is signed in.
#!/bin/sh
set -e
IMAGE="$1"
trivy image --scanners vuln --severity HIGH,CRITICAL \
--format json --output trivy.json "$IMAGE"
docker scout cves --only-severity critical,high \
--format sarif --output scout.sarif "$IMAGE"
jq -r '[.Results[]?.Vulnerabilities[]?.VulnerabilityID] | unique[]' \
trivy.json > trivy.ids
jq -r '[.runs[].results[]?.ruleId] | unique[]' \
scout.sarif > scout.ids
echo "Only in Trivy:"
comm -23 trivy.ids scout.ids
echo "Only in Scout:"
comm -13 trivy.ids scout.idscomm needs sorted input, and unique in jq sorts its output, so the files are ready to compare. comm -23 prints lines only in the first file. comm -13 prints lines only in the second.
Then investigate each ID that appears on one side only. Ask these questions in order:
- Is the affected package in both inventories?
- Does the other tool report the same issue under a different ID, such as a
GHSA-ID instead of a CVE? - Do the severities differ, so the finding fell outside the
--severityfilter? - Is the fix status different, so a finding was dropped by an unfixed filter?
- Was one tool's database newer?
Common errors
- Comparing different targets.
nginx:latestcan point to different digests on different days. Pin the digest:trivy image nginx@sha256:.... - Comparing different filters. Trivy
--severity HIGH,CRITICAL --ignore-unfixedagainst an unfiltered Scout run proves nothing. Match the filters on both sides. - Comparing counts. One CVE can appear once per affected package. One tool may count package-CVE pairs while the other counts unique CVEs.
- Trusting a clean result. A zero from one tool can mean the package was never detected. Check the inventory before you trust the zero.
- Stale caches. Trivy caches its database locally. Run a fresh scan, or refresh the database, before you compare.
Choosing between them, or using both
Pick based on what you need, not on which gives fewer findings.
- Use Scout when you want base image recommendations and comparison between image versions in the Docker workflow.
- Use Trivy when you want a standalone open source scanner that runs anywhere, reads many target types, and writes JSON and CycloneDX output.
- Use both when the cost of a missed finding is high. The union of the two reports is wider than either alone. Gate CI on a single agreed tool so the build result stays predictable, and use the second tool as a periodic cross-check.
Whatever you choose, record the choice. When you suppress a finding in .trivyignore, note which tool reported it and why you accepted it.
Exercise
Trivy reports a High vulnerability in a package, and Docker Scout does not list it. Name three checks that could explain the difference, in the order you would run them.
Show answer
First, confirm both tools scanned the same image digest and platform, with the same severity and fix filters. Second, check whether both inventories contain the package, since a missing package explains a missing finding. Third, check whether the advisory IDs or severities differ (for example a GHSA ID versus a CVE ID, or a different severity source), and whether a fix-status filter or a database update date explains the gap.
Exercise
Why does comm -23 trivy.ids scout.ids in the comparison script work reliably, and what would break it?
Show answer
comm requires both inputs to be sorted. The unique filter in jq sorts the IDs, so both files are in order. If you removed unique, or built the files with another command that does not sort, comm would give wrong or misleading results.