DEV Community

david
david

Posted on Originally published at woitzik.dev

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

Originally published at woitzik.dev

I narrowed the Trivy SARIF upload in my homelab CI to severity: CRITICAL,HIGH, reproduced it locally, got 0 results and declared the GitHub Security tab clean. It wasn't. The upload still carried all 459 MEDIUM and LOW findings, because aquasecurity/trivy-action deletes the severity filter for SARIF output unless limit-severities-for-sarif is exactly true. My second attempt set that input to CRITICAL,HIGH, which is not true, so it changed nothing. A guard script I added the same afternoon caught it on its first run. Three PRs on 2026-10-02 (#821, #822, #823), and the interesting part is why the first check lied.

View the complete homelab infrastructure source on GitHub

The Setup

The security-scan job in .github/workflows/ci.yml runs Trivy three times over the repo: two format: table steps restricted to severity: CRITICAL,HIGH that print findings in the log, and one format: sarif step that uploads to the GitHub Security tab.

The SARIF step had no severity filter. Measured against kubernetes/ with the repo's .trivyignore, that produced 478 findings:

error     19   HIGH/CRITICAL
warning  167   MEDIUM
note     292   LOW/UNKNOWN
Enter fullscreen mode Exit fullscreen mode

So the Security tab showed 478 alerts while the part CI cares about was 19. A 19-item signal under 459 advisory rows is a signal nobody reads, and because the count never moved, a real regression would have looked exactly like the backlog.

Attempt 1 (#821): Set Severity on the SARIF Step

The plan in ADR-049 had two parts. Narrow the SARIF upload to the severities the table steps enforce, and move the 19 enforced findings into .trivyignore with their evidence. Most of them were deliberate decisions already recorded in manifest comments, for example workloads that crash with readOnlyRootFilesystem (I broke nine containers learning which ones). GitHub closes an alert when a later upload for the same analysis no longer contains it, so the tab should converge to zero without any dismissal API calls.

The workflow change was one line:

          format: sarif
          output: trivy-results.sarif
          trivyignores: .trivyignore
          severity: CRITICAL,HIGH
Enter fullscreen mode Exit fullscreen mode

To check it, I reproduced the scan locally with the Trivy version CI runs, 0.70.0:

TRIVY_SEVERITY=CRITICAL,HIGH trivy config kubernetes/ --format sarif --ignorefile .trivyignore
  -> 0 results
Enter fullscreen mode Exit fullscreen mode

Zero. I merged and called the tab clean.

Attempt 2 (#822): Read the Log, Misread the Log

Reading the CI job log afterwards, two things looked off. The action printed Building SARIF report with all severities, and the Trivy invocation in the log was trivy config kubernetes/ with no --severity flag.

I explained both away. The action passes severity to Trivy as the TRIVY_SEVERITY environment variable, not as a flag, so a missing flag proved nothing. And I read "all severities" as the action announcing that its optional SARIF post-processing was skipped, not as a statement about the report. My local reproduction said 0, so I trusted that.

To be safe I added the other input anyway:

          severity: CRITICAL,HIGH
          limit-severities-for-sarif: CRITICAL,HIGH
          version: v0.70.0
Enter fullscreen mode Exit fullscreen mode

version pins Trivy explicitly. CI had been running 0.70.0 only because that is the action's default, and I wanted a Trivy bump to be a deliberate change, not a side effect of updating the action.

More importantly, the same PR added a guard. Trivy runs with exit-code: 0, so nothing failed when a finding appeared on the Security tab. scripts/check-trivy-sarif.py runs after the upload and fails the build if the SARIF contains any result:

    document = json.loads(SARIF.read_text())
    runs = document.get("runs") or [{}]
    results = [r for run in runs for r in run.get("results", [])]

    if not results:
        print("  0 findings at CRITICAL,HIGH -- code scanning stays clean.")
        return 0

    print(f"  {len(results)} finding(s) at CRITICAL,HIGH reached code scanning:\n")
Enter fullscreen mode Exit fullscreen mode

It also fails if the SARIF file is missing, so a skipped scan step can't pass as clean. In the workflow it runs under if: always(), after the upload step:

      - name: Assert code scanning stays clean
        if: always()
        run: python3 scripts/check-trivy-sarif.py
Enter fullscreen mode Exit fullscreen mode

That way a regression updates the tab and turns CI red in the same run. I tested the script in three states: a real filtered SARIF passes, two injected findings fail and are listed, a missing file fails.

The CI run for #822 failed in Security / Trivy. The guard found 459 findings in the SARIF I had declared clean less than an hour earlier.

The Actual Mechanism

The answer is in the action's entrypoint.sh (v0.36.0, the version my workflow uses):

if [ "${TRIVY_FORMAT:-}" = "sarif" ]; then
  if [ "${INPUT_LIMIT_SEVERITIES_FOR_SARIF:-false,,}" != "true" ]; then
    echo "Building SARIF report with all severities"
    unset TRIVY_SEVERITY
  fi
fi
Enter fullscreen mode Exit fullscreen mode

For SARIF output, the action deletes TRIVY_SEVERITY before calling Trivy unless limit-severities-for-sarif is the literal string true. So severity alone does not filter a SARIF report at all. The input that controls it is a boolean despite its plural name, and its description in action.yaml is just "limit severities for SARIF format", with no default. Passing CRITICAL,HIGH is not a narrower severity list. It is a value that is not true, and it takes the branch that removes the filter.

That also explains the log line I dismissed. Building SARIF report with all severities is exactly what it says. It was the action telling me it had dropped the filter, and I read it as noise.

Attempt 3 (#823): The One-Word Fix

          severity: CRITICAL,HIGH
          # Boolean, not a list: unless exactly "true" the action unsets
          # TRIVY_SEVERITY (entrypoint.sh), so the SARIF carries every severity
          # no matter what the input above says.
          limit-severities-for-sarif: true
          version: v0.70.0
Enter fullscreen mode Exit fullscreen mode

I reproduced both settings through the action's own logic: 459 results with CRITICAL,HIGH, 0 with true. The CI run for #823 passed, including Security / Trivy, which means the guard saw an empty SARIF.

Why the Local Check Lied

This is the part I'd keep even if you never use Trivy. My reproduction in #821 was correct. TRIVY_SEVERITY=CRITICAL,HIGH trivy config ... really returns 0 results with 0.70.0. It just measured a configuration the action never runs, because the action is written specifically to remove that variable. The local number was true and irrelevant.

Nothing in the CI output contradicted me either. Successfully uploaded results carries no count, so from the log alone a 0-result upload and a 459-result upload look the same. The only thing that settled it was a check running inside the real pipeline, on the real artifact, after the real action had done its work.

What Is Still Not Verified

I could not look at the Security tab state through the API. Both tokens I had return 403 for the code-scanning endpoints. The evidence that the tab converges is the guard passing on the uploaded file, plus GitHub's documented behavior of closing alerts that are absent from a later upload. That's good evidence, but it is not the same as reading the tab, and I'd rather say so than claim it.

What to Check in Your Own Workflow

  • If you use format: sarif with trivy-action, set limit-severities-for-sarif: true. Without it, severity does nothing for the SARIF output. Any other value, including a severity list, behaves like false.
  • Grep your job log for Building SARIF report with all severities. If it's there, your SARIF is unfiltered no matter what severity says.
  • Reproduce through the tool you actually run. Calling the scanner directly with your own env vars tests your assumptions about the wrapper, not the wrapper.
  • Check the artifact, not the upload status. A small script that counts runs[].results[] in the SARIF and fails the build is about 45 lines. It caught this on its first run.
  • Pin the scanner version separately from the action version, so a new rule set arrives as its own reviewable change.

The same lesson keeps coming back in this homelab: the status I can see (a green upload, a Synced app) is not the state I care about. The ArgoCD drift audit was that problem with deployments. This was that problem with the Security tab.

Top comments (12)

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.