Kai Ole Hartwig
10 min read

Zero findings because the scanner saw nothing

Five times during the rebuild of my container images, my scanner reported less than was actually there. Not because the images had become cleaner, but because it saw less. Every one of these results looked like a good one: green, zero findings, no warning.

TL;DR

TL;DR: A scanner reports what it finds, not what it could not check. If trivy finds no os-release file, it detects no operating system, checks no system packages and still exits with code 0. Without --platform, a multi-arch image is scanned for one architecture only. A local Go replace strips a module of its version and with it the match against advisories. And an exporter that reads numbers by position quietly shifts the columns as soon as the format changes. Each of these zeros looked like a real one. So every zero needs a denominator next to it: what was actually scanned.

No operating system, no findings

I build my runtime images from a minimal root file system that ends up in a FROM scratch. The os-release file was missing from it, and with it trivy lost the basis for everything that follows.

trivy detects the operating system through /etc/os-release or /usr/lib/os-release. The ID field becomes the family, which for Tumbleweed is opensuse-tumbleweed. Only with the family does trivy know which advisory data to match the packages against. It reads the packages themselves from the RPM database, on current openSUSE systems /usr/lib/sysimage/rpm/rpmdb.sqlite. Without the release file there is no family. Without the database there is a family but no packages. Both end in the same zero.

The tricky part is that trivy does not treat this as an error. The message "OS is not detected." only shows up with --debug, the exit code stays 0, and a gate with --exit-code 1 lets the image through. That is by design. In a discussion from October 2026, the maintainers declined to add a warning, because a missing operating system is not always a problem. Their advice: check the JSON report.

That is exactly what my build does now. The RPM database and openSUSE-release stay in every image, and the job fails if trivy does not detect opensuse-tumbleweed. A check like this is enough, as long as it also verifies that packages were actually read:

 

trivy image --format json --output scan.json "$IMAGE"

jq -e '.Metadata.OS.Family == "opensuse-tumbleweed"' scan.json
jq -e '[.Results[]? | select(.Class == "os-pkgs") | .Packages[]?] | length > 0' scan.json

 

If either expression fails, the job turns red. A silent zero is then no longer a green result but a stop with a reason.

I had measured the same pattern with Nix before. In a Nix image, trivy detected no operating system packages at all. That was one of the reasons against Nix as a base.

Half of a multi-arch image

18 of my images ship for arm64 and amd64. In the registry, each of them is an image index pointing to two manifests, one per platform. The scan read only one of them.

Which one depends on where trivy gets the image from. Without --image-src, it asks Docker, containerd and Podman in turn, and the registry only last. A local daemon returns whatever it pulled for its own architecture. From the registry, the underlying go-containerregistry library resolves an index without a preference to linux/amd64. On a runner fleet with both architectures, the runner the job happens to land on makes the call.

In my case the scan ran as a container_scanning job, using GitLab's analyzer, which runs trivy under the hood. The general runners these jobs land on are all arm64 instances on Graviton. amd64 workers exist only in a separate pool for package builds. So mixed runners were not the cause for me. It came down to how the analyzer resolves the index, and that was exactly what I had never checked.

That would be harmless if both halves were the same. On Tumbleweed they are not. aarch64 is built and published as a separate port, so a fix can already ship on x86_64 while it is still missing on aarch64. A scan of the amd64 half then reports zero for an image that is vulnerable on the arm64 nodes in the cluster.

That is why the scan component in my CI names the platform explicitly and checks it since version 4.11. Since 4.12 it scans every platform the index publishes. At its core, it can be rebuilt like this:

 

crane manifest "$IMAGE" \
  | jq -r '.manifests[].platform | select(.os != "unknown") | "\(.os)/\(.architecture)"' \
  | while read -r platform; do
      trivy image --image-src remote --platform "$platform" \
        --format json --output "scan-${platform//\//-}.json" "$IMAGE"
    done

 

The filter on unknown is needed because BuildKit writes attestations into the index as separate entries with the platform unknown/unknown. And --image-src remote makes sure no local daemon undermines the platform choice.

A module the scanner no longer sees

For two Go modules, the fix existed only in the next major version. I backported it as a local copy in the repository, wired in with a replace in go.mod. In the next report, the finding was gone.

One of them was github.com/jackc/pgproto3/v2, which crowdsec pulls in through pgx v4. Its DataRow.Decode accepts negative field lengths, so a malicious or compromised PostgreSQL server can crash the client (GO-2026-4518, CVE-2026-32286). The module has been archived since January 2025, and the check for negative lengths exists only in pgx v5. I took it from there and applied it as a patch to v2.3.3. Before that, the build checks that v2.3.3 is really the selected version and stops if it is not.

The second was github.com/go-jose/go-jose/v3 in my Caddy build. go-jose fixed three flaws (CVE-2026-116585, CVE-2026-116586 and CVE-2026-116587) only in v4. I backported the three commits to v3.0.5. The build script copies the module to third_party/, applies the patch, runs the upstream tests plus a regression test of its own for each backport, and wires the module in with a replace.

Not because the scanner recognized the fix. For Go binaries, trivy reads the build information the compiler embeds and matches module path and version against the advisories. For a module replaced by a local copy, there is no version in it. The trivy documentation says so openly: dependencies replaced with local ones have an empty version. No version means no match, and no match means no finding.

The binary itself tells you which modules drop out of view this way:

 

go version -m ./bin/app | grep -B1 '=>'

 

Every line with => is a replacement, and the line above it is the original module. If the replacement points to a local path instead of a versioned module, the scanner no longer checks that module.

In my case the zero was right, but not proven. The proof is the regression test that reproduces the flaw and runs in every build. A backport without that test would be a zero without a basis, and the replace would make it invisible on top of that.

The test only proves the one fix, though. For every advisory published after it, the module stays invisible. So I keep every patch like this in a list of its own:

 

carried:
  - recipe: crowdsec.yaml
    module: github.com/jackc/pgproto3/v2
    version: v2.3.3
    patch: crowdsec/pgproto3-v2-datarow-negative-length.patch
    fixes: [GO-2026-4518]

 

A job asks OSV every day about the original module at exactly this version. If an advisory shows up that is not listed under fixes, the job turns red. It also fails when the recipe no longer references the patch, so no stale entry is left behind.

Numbers read by position

My CI exporter took the first four numbers from the summary line of the package audit and wrote them out as metrics. Then the line gained an extra column for MEDIUM. From then on, the number of MEDIUM findings showed up as "fixable" and the number of fixable findings as "justified".

The line comes from scan-packages.sh, the audit for my own packages. It unpacks every published package, runs trivy over it and sums up at the end. On October 13 MEDIUM was added, after a package with a fixable MEDIUM finding had slipped through:

 

# before
total: <n> CRITICAL, <n> HIGH — <n> of them with a published fix, <n> justified

# after
total: <n> CRITICAL, <n> HIGH, <n> MEDIUM — <n> of them with a published fix, <n> justified

 

Before, the line held exactly four numbers; after, five. Anything that keeps taking the first four reads MEDIUM in third place instead of the fixable findings, and the fixable ones in fourth place instead of the justified ones.

The values were plausible and in the same range as before. Nobody noticed, because a dashboard shows wrong numbers no differently from right ones.

Since then, the exporter reads every number by its label and records which architecture it came from. If you build an exporter like this, also let it fail when an expected label is missing, instead of reporting a zero. And where a tool offers machine-readable output, that is a better source than a line meant for humans.

And the other direction

A report can also say too much. When I compared the two architectures, the aarch64 port was behind x86_64 in 277 packages, which at first sounded like a problem of considerable size. Six of them were missing a security fix. Only those six are findings; the other 271 are version differences without any security relevance. A list of all 277 entries would have hidden the six as thoroughly as a zero.

Recommendations

  1. Write the denominator next to every zero. Detected operating system, scanned platforms, number of packages read. In trivy's JSON report you find them in Metadata.OS and in the results of class os-pkgs.
  2. Fail the build when no operating system is detected. Check for the expected distribution, not just for any. And check that packages were read, because a detected distribution without an RPM database is the same zero.
  3. Scan every published platform. Explicitly with --platform and --image-src remote, especially when the architectures run on different states.
  4. Read numbers by their label. Never by their position in a line, and from machine-readable output where possible.
  5. Where you hide a version, you need a test. A local replace ends the scanner's check. The test takes it over for the one fix, and a list of carried patches keeps OSV checking the original module.

Conclusion

A green gate is first a statement about coverage and only then one about findings. A better scanner would not have prevented any of my five cases, because each time it correctly reported what it saw. So the question is not whether your scanner finds something. It is whether you would notice when it does not look.

I check what your scanner actually sees.

Operating system detection, platforms, hidden modules and the evaluation afterwards. At the end, every zero in your report has a denominator.

Book a call →

About the author

Photo of Kai Ole Hartwig.

Kai Ole Hartwig

Freelance DevSecOps consultant · OnlyOle Consulting

Programming since 2002 – self-taught, set up my own business with KO-Web in 2012. Over 100 projects, with a focus on security, performance, automation and quality. Today freelance: DevSecOps consulting, training and software development.

Newsletter

The week, in one email.

The new advisories and posts, once a week and briefly put in context. You will get a confirmation email first, and opens and clicks are only counted anonymously.

Language