DEV Community

Trivy Action: Why severity CRITICAL,HIGH Still Uploaded 459 Findings

david on November 22, 2026

Originally published at woitzik.dev I narrowed the Trivy SARIF upload in my homelab CI to severity: CRITICAL,HIGH, reproduced it locally, got 0 ...
Collapse
 
lycore profile image
Lycore Development •

The detail that limit-severities-for-sarif has to be exactly true is the kind of thing that only shows up when a guard checks the output instead of the config. Reproducing locally with TRIVY_SEVERITY gave a clean result that the real action never produced, so it is a good reminder that a local run isn't the same test as the pipeline. Have you thought about asserting on the uploaded SARIF's severity levels in CI so it fails if a filter silently stops applying?

Collapse
 
dwoitzik profile image
david •

Yes, that's what caught it. The same PR added scripts/check-trivy-sarif.py, which runs after the upload under if: always() and fails the build if the SARIF contains any result, or if the file is missing. It found the 459 findings on its first run, less than an hour after I had declared the tab clean. Asserting on the artifact rather than the config is the part I'd keep for any scanner.

Collapse
 
lycore profile image
Lycore Development •

Asserting on the SARIF artifact with an if: always() step is a good pattern, especially since the failure mode here was a config that looked right. Did the check also catch the opposite case, a scan that produced no SARIF at all? We've seen that one pass silently when the upload step was skipped.

Thread Thread
 
dwoitzik profile image
david •

Yes, that case is covered. The script fails if the SARIF file is missing, not only if it contains results, so a skipped or crashed scan step can't pass as clean. I tested it in three states: a real filtered SARIF passes, injected findings fail and get listed, and a missing file fails.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

The log line said it plainly and you explained it away. 'Building SARIF report with all severities' was the action telling you the filter was gone.

Collapse
 
dwoitzik profile image
david •

Fair, and that's the uncomfortable part of the post. The line said exactly what was happening and I had a plausible story for why it didn't mean that. That's why the guard checks the uploaded file now instead of relying on me reading logs correctly.

Collapse
 
robertpaschal profile image
Odinaka Robert Nnamani •

Checking the manifest instead of the lockfile makes sense. The lockfile can only repeat a decision that was already made upstream.

Thread Thread
 
dwoitzik profile image
david •

Same principle, though here it was the uploaded SARIF rather than a lockfile: check the artifact the pipeline actually produced, not the config that was supposed to shape it.

Thread Thread
 
robertpaschal profile image
Odinaka Robert Nnamani •

the uploaded SARIF is the thing to check. the config only says what should have happened.

Collapse
 
sudokat_ profile image
Gordon Chase •

A plural limit-severities-for-sarif right below severity: CRITICAL,HIGH is a classic YAML bear trap. Even funnier, ${INPUT_LIMIT_SEVERITIES_FOR_SARIF:-false,,} is broken bash: ,, gets eaten into the default string, so True or TRUE silently drops TRIVY_SEVERITY too. Would a pre-upload check on non-error SARIF rows catch wrapper bugs without blocking real HIGH/CRITICAL alerts?

Collapse
 
dwoitzik profile image
david •

You're right about the ,,, and I've added it to the post. Inside ${VAR:-default} it's just part of the default string, so nothing gets lowercased: I checked in bash, and True and TRUE drop TRIVY_SEVERITY exactly like CRITICAL,HIGH does. Thanks for catching that.

On the level-based check: yes, that works if you keep real findings in the upload. Trivy maps CRITICAL and HIGH to SARIF level error, MEDIUM to warning and LOW to note, so failing on any result that isn't error catches a dropped filter while real HIGH/CRITICAL alerts still go through. My guard is stricter because every enforced finding is triaged into .trivyignore, so the expected SARIF is empty and any result at all is a regression. For a repo that keeps open HIGH/CRITICAL alerts, your version is the better fit.

Collapse
 
bellatrix profile image
Bella •

This is an excellent example of why validating the scanner itself is not enough when security tooling is wrapped in CI/CD automation. The most important takeaway here is that the behavior of the underlying tool and the behavior of the action orchestrating it are not necessarily equivalent. Your local reproduction was technically correct, but it validated Trivy's native severity filtering rather than the effective configuration after trivy-action modified the environment.

The limit-severities-for-sarif implementation is particularly interesting because its name makes it easy to assume it accepts a severity list, when it actually expects a boolean. That subtle interface mismatch silently invalidated the intended security control. What's even more concerning is that the workflow remained green and the SARIF upload succeeded, creating a false sense of confidence while hundreds of lower-severity findings continued accumulating in the Security tab.

I especially like the guard script approach. Validating the generated SARIF artifact rather than trusting the scanner's exit code or the upload step's success is a much stronger CI/CD design principle. It turns an implicit assumption into an explicit, testable invariant. The if: always() placement is also important because it helps ensure that the validation step still executes when an earlier step fails.

There is a broader lesson here for DevSecOps: a successful security scan, a successful artifact upload, and a correctly enforced security policy are three different things. We often focus on whether tools execute successfully, but the real question is whether their outputs satisfy the security guarantees we intended to enforce.

One additional improvement worth considering would be to validate the SARIF metadata and severity distribution, not just the total result count. That could catch future regressions involving unexpected severity levels, missing analysis runs, or malformed reports. Also, checking the final GitHub Code Scanning state through an appropriately permissioned API token would close the remaining gap between artifact validation and what developers actually see in the Security tab.

The decision to pin the Trivy version independently from the action version is another solid practice. It makes changes to the scanner's detection rules and changes to the workflow wrapper independently reviewable.

Ultimately, the most valuable part of this write-up isn't the one-word fix. It's the debugging methodology: inspect the wrapper, question misleading success signals, validate the actual artifact, and encode the expected behavior as an automated regression check. This is a pattern worth applying to virtually every security integration in a CI/CD pipeline.