Trivy only consumes security advisories from the sources listed in the above table.
As for packages installed from OS package managers (dpkg, yum, apk, etc.), Trivy uses the advisory database from the appropriate OS vendor.
For example: for a python package installed from yum (Amazon linux), Trivy will only get advisories from ALAS.
But for a python package installed from another source (e.g. pip), Trivy will get advisories from the GitLab and GitHub databases.
This advisory selection is essential to avoid getting false positives because OS vendors usually backport upstream fixes, and the fixed version can be different from the upstream fixed version.
The severity is taken from the selected data source since the severity from vendors is more accurate.
Using CVE-2023-0464 as an example, while it is rated as "HIGH" in NVD, Red Hat has marked its 'Impact' as "Low".
As a result, Trivy will display it as "Low".
The severity depends on the compile option, the default configuration, etc.
NVD doesn't know how the vendor distributes the software.
Red Hat evaluates the severity more accurately.
That's why Trivy prefers vendor scores over NVD.
If the data source does not provide a severity, the severity is determined based on the CVSS score as follows:
Base Score Range
Severity
0.1-3.9
Low
4.0-6.9
Medium
7.0-8.9
High
9.0-10.0
Critical
If the CVSS score is also not provided, it falls back to NVD.
NVD and some vendors may delay severity analysis, while other vendors, such as Red Hat, are able to quickly evaluate and announce the severity of vulnerabilities.
To avoid marking too many vulnerabilities as "UNKNOWN" severity, Trivy uses severity ratings from other vendors when the NVD information is not yet available.
The order of preference for vendor severity data can be found here.
You can reference SeveritySource in the JSON reporting format to see from where the severity is taken for a given vulnerability.
"SeveritySource":"debian",
In addition, you can see all the vendor severity ratings.
The unfixed/unfixable vulnerabilities mean that the patch has not yet been provided on their distribution.
To hide unfixed/unfixable vulnerabilities, you can use the --ignore-unfixed flag.
Trivy can detect vulnerabilities in Kubernetes clusters and components by scanning a Kubernetes Cluster, or a KBOM (Kubernetes bill of Material). To learn more, see the documentation for Kubernetes scanning.
The information from the above sources is collected and stored in databases that Trivy uses for vulnerability scanning. Trivy automatically fetches, maintains, and caches the relevant databases when performing a vulnerability scan
For more information about Trivy's Databases mechanism and configurations, refer to the Databases document.
Trivy prioritizes precision in vulnerability detection, aiming to minimize false positives while potentially accepting some false negatives.
This approach is particularly relevant in two key areas:
For files installed by OS package managers, such as apt, Trivy exclusively uses advisories from the OS vendor.
This means that even if a JAR file is present in a container image, if it was installed via an OS package manager (e.g., apt), Trivy will not analyze the JAR file itself and use upstream security advisories.
For example, consider the Python requests package in Red Hat Universal Base Image 8:
[root@987ee49dc93d/]# head -n 3 /usr/lib/python3.6/site-packages/requests-2.20.0-py3.6.egg-info/PKG-INFO
Metadata-Version:2.1
Name:requests
Version:2.20.0
Version 2.20.0 is installed, and this package is installed by dnf.
At first glance, this might seem vulnerable to CVE-2023-32681, which affects versions of requests prior to v2.31.0.
However, Red Hat backported the fix to v2.20.0-3 in RHSA-2023:4520, and the package is not vulnerable.
Red Hat (python-requests): Backported fix applied in v2.20.0-3 (RHSA-2023:4520)
If Trivy were to detect CVE-2023-32681 in this case, it would be a false positive.
This illustrates why using the correct security advisory is crucial to avoid false detections.
To minimize false positives, Trivy trusts the OS vendor's advisory for software installed via OS package managers and does not use upstream advisories for these packages.
However, this approach may lead to false negatives if the OS vendor's advisories are delayed or missing.
In such cases, using --detection-priority comprehensive allows Trivy to consider upstream advisories (e.g., GitHub Advisory Database), potentially increasing false positives but reducing false negatives.
When a package version cannot be uniquely determined (e.g., package-a: ">=3.0"), Trivy typically skips vulnerability detection for that package to avoid false positives.
If a lock file is present with fixed versions, Trivy will use those for detection.
To detect potential vulnerabilities even with unspecified versions, use --detection-priority comprehensive.
This option makes Trivy use the minimum version in the specified range for vulnerability detection.
While this may increase false positives if the actual version used is not the minimum, it helps reduce false negatives.
It's possible to only enable certain package types if you prefer.
You can do so by passing the --pkg-types option.
This flag takes a comma-separated list of package types.
Available values:
os
Scan OS packages managed by the OS package manager (e.g. dpkg, yum, apk).
library
Scan language-specific packages (e.g. packages installed by pip, npm, or gem).
Trivy supports filtering vulnerabilities based on the relationship of packages within a project.
This is achieved through the --pkg-relationships flag.
This feature allows you to focus on vulnerabilities in specific types of dependencies, such as only those in direct dependencies.
In Trivy, there are four types of package relationships:
root: The root package being scanned
direct: Direct dependencies of the root package
indirect: Transitive dependencies
unknown: Packages whose relationship cannot be determined
The available relationships may vary depending on the ecosystem.
To see which relationships are supported for a particular project, you can use the JSON output format and check the Relationship field:
Trivy provides a --detection-priority flag to control the balance between false positives and false negatives in vulnerability detection.
This concept is similar to the relationship between precision and recall in machine learning evaluation.
precise: This mode prioritizes reducing false positives. It results in less noisy vulnerability reports but may miss some potential vulnerabilities.
comprehensive: This mode aims to detect more vulnerabilities, potentially including some that might be false positives.
It provides broader coverage but may increase the noise in the results.
The default value is precise. Also refer to the detection behavior section for more information.
Regardless of the chosen mode, user review of detected vulnerabilities is crucial:
By default, Trivy automatically detects the OS during container image scanning and performs vulnerability detection based on that OS.
However, in some cases, you may want to scan an image with a different OS version than the one detected.
Also, you may want to specify the OS version when OS is not detected.
For these cases, Trivy supports a --distro flag using the <family>/<version> format (e.g. alpine/3.20) to set the desired OS version.
By default, Trivy automatically detects severity (as described here).
But there are cases when you may want to use your own source priority. Trivy supports the --vuln-severity-source flag for this.
Fill in a list of required sources, and Trivy will check the sources in that order until it finds an existing severity.
If no source has the severity - Trivy will use the UNKNOWN severity.
Note
To use the default logic in combination with your sources - use the auto value.
Example logic for the following vendor severity levels when scanning an Alpine image:
"VendorSeverity":{"ghsa":3,"nvd":4,}
--vuln-severity-source auto,nvd - severity is CRITICAL, got from auto.
--vuln-severity-source alpine,auto - severity is CRITICAL, got from auto.
--vuln-severity-source alpine,ghsa - severity is HIGH, got from ghsa.
--vuln-severity-source alpine,alma - severity is UNKNOWN.