Why Scanners Disagree & False Positives
Scan the same image with two scanners on the same day and you get two different lists. That isn't a bug in either; it follows from how scanning works. Knowing why lets you decide which findings are real, and stops you from "fixing" the scanner instead of the software.
Same image, two answers
Earlier lessons scanned alpine:3.18.0 with both tools. Line them up by CVE id:
img=/opt/samples/images/alpine-3.18.0.tar
grype $img -q --by-cve -o json | jq -r '.matches[] | "\(.artifact.name) \(.vulnerability.id)"' | sort -u > grype.txt
trivy image -q --input $img -f json | jq -r '.Results[].Vulnerabilities[] | "\(.PkgName) \(.VulnerabilityID)"' | sort -u > trivy.txt
echo "grype: $(wc -l < grype.txt) trivy: $(wc -l < trivy.txt) both: $(comm -12 grype.txt trivy.txt | wc -l)"
echo "--- only grype, and the data it matched on:"
comm -23 grype.txt trivy.txt | cut -d' ' -f2 | sort -u | while read -r cve; do
grype $img -q --by-cve -o json | jq -r --arg c "$cve" 'first(.matches[] | select(.vulnerability.id == $c)) | "\($c) \(.vulnerability.namespace) \(.matchDetails[0].type) fix: \(.vulnerability.fix.state | if . == "" then "-" else . end)"'
done
echo "--- only trivy: $(comm -13 grype.txt trivy.txt | wc -l)"grype: 63 trivy: 49 both: 49
--- only grype, and the data it matched on:
CVE-2024-58251 nvd:cpe cpe-match fix: -
CVE-2025-46394 nvd:cpe cpe-match fix: -
CVE-2025-60876 nvd:cpe cpe-match fix: -
CVE-2026-27171 nvd:cpe cpe-match fix: unknown
CVE-2026-40200 nvd:cpe cpe-match fix: -
CVE-2026-6042 nvd:cpe cpe-match fix: -
--- only trivy: 0
Every finding Trivy reported, Grype reported too. The extra Grype findings all come from the same place: namespace nvd:cpe, match type cpe-match, no fix. Grype matched the package's CPE against NVD's records for the upstream projects (busybox, musl, zlib), while Trivy only used Alpine's own security database. Neither is wrong:
- The NVD matches may be real: upstream has a vulnerability and Alpine hasn't published a fixed package yet (for an end-of-life release, it never will).
- They may be false positives: Alpine may have patched the code without changing the version, or the vulnerable feature may not be built into Alpine's package.
Only a human (or a VEX statement from Alpine) can tell which.
Same package, different ids
On the Node project the two tools agreed on the vulnerabilities but not on the names:
cp -r /opt/samples/node-app . && cd node-app
grype . -q -o json | jq -r '.matches[] | .vulnerability.id as $g | ([.relatedVulnerabilities[].id] | first // $g) as $c | "\($c) (\($g))"' | sort > grype.txt
grype . -q --by-cve -o json | jq -r '.matches[].vulnerability.id' | sort > grype-cve.txt
trivy fs . -q -f json | jq -r '.Results[].Vulnerabilities[].VulnerabilityID' | sort > trivy.txt
cat grype.txt
echo "--- trivy only (comparing by CVE):"
comm -13 grype-cve.txt trivy.txtCVE-2020-28500 (GHSA-29mw-wpgm-hmr9)
CVE-2020-8203 (GHSA-p6mc-m468-83gw)
CVE-2021-23337 (GHSA-35jh-r3h4-6jhm)
CVE-2021-44906 (GHSA-xvch-5gv4-984h)
CVE-2025-13465 (GHSA-xxjr-mmjv-4gpg)
CVE-2026-2950 (GHSA-f23m-r3pf-42rh)
CVE-2026-4800 (GHSA-r5fr-rjxr-66jc)
--- trivy only (comparing by CVE):
NSWG-ECO-516
Grype reports the GHSA records it matched; Trivy reports CVE ids. With --by-cve they line up, except for NSWG-ECO-516, a pre-GitHub Node Security Working Group advisory that only Trivy's database still carries. It describes the same lodash problem as one of the CVEs, so it's a duplicate, not a new risk.
The reasons, in general
| Cause | Effect |
|---|---|
| Different data sources (NVD CPEs, GHSA, distro trackers, OSV) | one tool reports what another never heard of |
| Different ids (GHSA vs CVE vs vendor ids) | the same issue looks like different issues |
| Different cataloging | one tool finds a JAR inside a JAR, or a Go binary's modules, and the other doesn't |
| Distro backports | upstream says "fixed in 1.2.3", the distro patched 1.2.0-5; version-range matching on upstream data reports a false positive |
| CPE guessing | a package named jquery-ui-rails gets a CPE for jquery-ui; a Python package shares a name with a C library |
| Severity sources | NVD scores 9.8, the distro scores 5.3 for its build; tools pick different sources |
| Database age | one DB updated this morning, the other yesterday |
A model: why backports fool upstream ranges
Distributions fix old versions in place. In this made-up but typical example, Debian's package revision openssl 3.0.11-1~deb12u2 backports a fix that upstream only shipped in 3.0.12. A scanner that compares the upstream version against the upstream fixed version reports a vulnerability that the distribution already fixed.
def v(s):
return tuple(int(x) for x in s.split("."))
# Upstream advisory: affected before 3.0.12.
UPSTREAM_FIXED = "3.0.12"
# Distribution tracker: fixed in the distribution's package revision 3.0.11-1~deb12u2.
DISTRO_FIXED = {"bookworm": "3.0.11-1~deb12u2"}
installed = [("bookworm", "3.0.11-1~deb12u1"), ("bookworm", "3.0.11-1~deb12u2"), ("bookworm", "3.0.13-1~deb12u1")]
def revision(pkg_version):
upstream, _, rev = pkg_version.partition("-")
return v(upstream), rev
for distro, pkg in installed:
up, rev = revision(pkg)
by_upstream = up < v(UPSTREAM_FIXED)
fixed_up, fixed_rev = revision(DISTRO_FIXED[distro])
by_distro = (up, rev) < (fixed_up, fixed_rev) # simplified Debian ordering for this example
verdict = "agree" if by_upstream == by_distro else "FALSE POSITIVE (upstream data)"
print(f"{pkg:18} upstream says {'vulnerable' if by_upstream else 'fixed':10} distro says {'vulnerable' if by_distro else 'fixed':10} -> {verdict}")3.0.11-1~deb12u1 upstream says vulnerable distro says vulnerable -> agree
3.0.11-1~deb12u2 upstream says vulnerable distro says fixed -> FALSE POSITIVE (upstream data)
3.0.13-1~deb12u1 upstream says fixed distro says fixed -> agree
This is why scanners prefer distribution data for OS packages when it exists, and why both Grype and Trivy identify the distribution (distro=… in the purl) before matching.
Triage, not tuning
When a finding looks wrong:
- Find the match source (
matchDetailsin Grype's JSON,DataSourcein Trivy's). Acpe-matchdeserves more doubt than an exact purl match against a distribution feed. - Check the distribution's tracker (security.alpinelinux.org, security-tracker.debian.org, ubuntu.com/security) for the package's status.
- Check whether the vulnerable code is shipped and reachable. For Go,
govulncheckdoes this automatically using call graphs (go-modules). - Record the conclusion as VEX (
not_affected+ justification) or a scoped ignore rule with a reason and expiry, never by switching scanners until the list is short. - Report real false positives upstream (scanner issue trackers, GHSA corrections); they get fixed for everyone.
Running two scanners and taking the union is a reasonable policy for high-value artifacts; taking the intersection to get a shorter list is not.
Test yourself
Grype reports busybox CVEs with namespace nvd:cpe that Trivy doesn't. What is the most likely reason?
- Trivy is broken
- Grype matched upstream NVD records by CPE; Trivy used only Alpine's database
- Grype's DB is older
- Trivy doesn't support busybox
Why can an upstream version range produce a false positive for a Debian package?
- Debian packages have no versions
- Debian backports fixes into older upstream versions, changing only the package revision
- NVD doesn't cover Debian
- Debian uses semver
Which policy for two scanners is reasonable?
- Take the intersection to reduce noise
- Take the union and triage, recording conclusions as VEX or scoped ignores
- Use whichever reports fewer findings
- Disable the one that fails