Sub topic 10
Filtering by severity and unfixed vulnerabilities
This chapter assumes you can run trivy image and read its table output, as covered in the previous chapter. It also assumes you know what a CVE is and that severity ratings come from advisory data. Here you will learn to cut a scan report down to the findings you can act on, and to avoid the mistakes that filtering invites.
Why filter at all
An unfiltered scan of a common image can list hundreds of findings. Many are rated LOW or UNKNOWN. Many have no patched package available. If you treat every row as a task, the report becomes noise and people stop reading it.
Filtering does not remove vulnerabilities from the image. It only changes what the report shows and what a CI job counts. Keep that in mind, because a clean filtered report does not mean a clean image.
Trivy gives you two main filters:
- Severity: show only findings at or above a chosen rating.
- Fix status: hide findings for which the distribution has not published a fixed version.
Filtering by severity
Trivy assigns each finding one of five severities: UNKNOWN, LOW, MEDIUM, HIGH and CRITICAL. The --severity option takes a comma-separated list of the levels to keep. It is a list of exact levels, not a minimum threshold, so you must name every level you want.
trivy image --severity HIGH,CRITICAL python:3.12-slimIf you write --severity HIGH, you get only HIGH findings and CRITICAL ones are hidden. This is a common mistake. When you mean "high and above", always list both.
The severity Trivy shows usually comes from the vendor of the operating system, such as Debian or Alpine. If the vendor gives no rating, Trivy falls back to the rating in a general source such as the NVD. This is why the same CVE can show different severities for different distributions.
Severity levels and what to do with them
| Severity | Typical meaning | Usual team policy |
|---|---|---|
| CRITICAL | Easily exploited, serious impact | Fix or block the release |
| HIGH | Serious impact, may need specific conditions | Fix soon, often block the release |
| MEDIUM | Limited impact or hard to exploit | Fix in normal maintenance |
| LOW | Minor impact | Review occasionally |
| UNKNOWN | No rating available | Look at it manually |
These policies are examples. Your team sets its own thresholds.
Filtering out unfixed vulnerabilities
Some findings have no fixed version. The package is affected, but the maintainers have not shipped a patch. In the Trivy table, the "Fixed Version" column is empty for these rows.
The --ignore-unfixed option hides them:
trivy image --severity HIGH,CRITICAL --ignore-unfixed python:3.12-slimThe reasoning is practical. You cannot fix a finding by updating a package if no updated package exists. Showing it as a to-do item gives you nothing to do. After you hide those rows, every remaining row has a fixed version you can move to, either by updating the package or by rebuilding on a newer base image.
What `--ignore-unfixed` does not tell you
Hiding unfixed findings has costs. Keep these in mind:
- The risk still exists. An unfixed CRITICAL vulnerability can be exploited today. You only stopped looking at it.
- Status changes over time. A finding with no fix today may get a fix next week. It then appears in your report on its own when you rescan.
- Some distributions mark a finding as "will not fix" or "end of life". Trivy treats these as unfixed as well, so they stay hidden, even though no fix will ever arrive.
- Mitigations may exist. For an unfixed finding you may still be able to remove the package, disable the feature, or use a different base image.
For these reasons, run an occasional report without --ignore-unfixed. It shows the full set of risks, and it helps you decide when to change base images.
Combining filters
Both options can be used together, and this is the most common form in pipelines. The filters combine as a logical AND: a finding must match the severity list and have a fix to appear.
trivy image --severity CRITICAL,HIGH --ignore-unfixed python:3.12-slimThe order of levels in the list does not matter.
The next diagram shows how a raw finding passes through each filter.
Filtering in Docker Scout
Docker Scout offers equivalent filters on docker scout cves. You have already seen --only-severity. Scout also has an option for fix status:
docker scout cves --only-severity critical,high --only-fixed nginx:latest--only-fixed hides vulnerabilities that have no fixed version, which matches the behavior of Trivy's --ignore-unfixed. Scout writes severity names in lowercase in its examples, while Trivy uses uppercase. Both tools accept the forms shown here.
| Goal | Trivy | Docker Scout |
|---|---|---|
| Keep only some severities | `--severity HIGH,CRITICAL` | `--only-severity high,critical` |
| Hide findings with no fix | `--ignore-unfixed` | `--only-fixed` |
Worked example
Suppose you scan an image and want a short, actionable report. First, count the unfiltered total by writing JSON and counting results with jq. This sketch assumes jq is installed.
trivy image --format json --output all.json python:3.12-slim
jq '[.Results[]?.Vulnerabilities[]?] | length' all.jsonThen do the same with both filters:
trivy image --severity HIGH,CRITICAL --ignore-unfixed \
--format json --output actionable.json python:3.12-slim
jq '[.Results[]?.Vulnerabilities[]?] | length' actionable.jsonThe second number is usually far smaller. Each remaining finding names a package and a fixed version. Your next step for each is one of three: rebuild on a newer base image, update the package directly, or record why you accept the finding. The last option is the subject of a later chapter on triage.
Common errors
- Using one severity and expecting a minimum.
--severity CRITICALhides HIGH findings. List every level you care about. - Reading an empty report as safe. An empty filtered report means "nothing actionable at these levels". It does not mean the image has no vulnerabilities.
- Filtering the report but not the gate. In CI, the exit code is computed from the findings that remain after filtering. If your report filter and your gate filter differ, the output and the pass/fail result may disagree.
- Forgetting UNKNOWN. Findings with no rating are hidden when you list only HIGH and CRITICAL. If you want to review them, include
UNKNOWNin a separate report. - Comparing tools with different filters. If Trivy runs with
--ignore-unfixedand Scout runs without--only-fixed, the counts will not match. Align the filters before comparing.
Summary of the key points
--severitytakes an explicit list of levels, not a threshold.--ignore-unfixedremoves findings that have no patched version, so every remaining row has a possible fix.- Both filters can be combined, and Docker Scout has matching options in
--only-severityand--only-fixed. - Filtering is a view, not a fix. Keep an occasional unfiltered scan.
Exercise
A teammate runs trivy image --severity HIGH --ignore-unfixed myapp:1.4 and reports "no critical issues found". What is wrong with this conclusion, and what command would you run instead?
Show answer
--severity HIGH keeps only HIGH findings, so CRITICAL findings are hidden and nothing was checked for them. The conclusion is also weakened by --ignore-unfixed, which hides critical findings that have no fix yet. Run trivy image --severity HIGH,CRITICAL --ignore-unfixed myapp:1.4 for the actionable list, and run trivy image --severity HIGH,CRITICAL myapp:1.4 to see the unfixed findings as well.
Exercise
Write the Docker Scout command that is equivalent to trivy image --severity CRITICAL,HIGH --ignore-unfixed nginx:latest.
Show answer
docker scout cves --only-severity critical,high --only-fixed nginx:latest