See how trivy compares to other vendors in security performance
Summary
When Trivy downloads an OCI artifact, it uses the org.opencontainers.image.title annotation from the artifact manifest as the destination filename without validation. An attacker who can make Trivy fetch an attacker-controlled artifact can supply a crafted annotation that resolves to a path outside the intended destination, causing Trivy to write the layer content to an arbitrary location on the host filesystem.
Affected configurations
Exploitation requires the attacker to direct Trivy at an attacker-controlled OCI artifact via one of the following inputs:
| Input | Used for | | --- | --- | | --db-repository flag, TRIVYDBREPOSITORY environment variable, or db.repository in trivy.yaml | Vulnerability database | | --java-db-repository flag, TRIVYJAVADBREPOSITORY environment variable, or db.java-repository in trivy.yaml | Java vulnerability database | | --checks-bundle-repository flag (and the deprecated --policy-bundle-repository alias), TRIVYCHECKSBUNDLEREPOSITORY environment variable, or misconfiguration.checks-bundle-repository in trivy.yaml | Misconfiguration checks bundle | | Repository argument to trivy module install <REPO> | WASM module installation |
Realistic scenarios in which an attacker may influence these inputs include a copy-pasted command or documentation snippet pointing to an untrusted mirror, or a third-party mirror that turns out to be hostile.
Trivy's default configuration, which downloads these artifacts from Aqua-operated repositories, is not affected. The risk applies only when one of the inputs above is overridden to download a different artifact.
Impact
An attacker who satisfies the conditions above can overwrite or create arbitrary files on the host filesystem within the privilege boundary of the user running Trivy. The vulnerability does not grant any privileges beyond what that user already has.
The practical impact depends on the deployment. In environments where the running user can overwrite files such as SSH authorizedkeys, shell startup files, cron entries, or binaries on PATH, the file write may be leveraged to achieve code execution as that user. In more restricted deployments, the impact is bounded to the user's writable scope but may still allow tampering with scan results, build artifacts, or other files consumed by subsequent steps in the same pipeline.
Patches
Fixed in Trivy 0.71.1. Users should upgrade to that release or later.
Workarounds
If upgrading is not immediately possible, do not download Trivy artifacts (vulnerability database, Java database, misconfiguration checks bundle, modules, etc.) from OCI repositories you do not operate or trust.
Credits
Reported by @ikkebr.
Summary
Trivy's plugin manager does not fully validate metadata from a plugin's manifest before using it to construct filesystem paths under the plugin root (~/.trivy/plugins). A crafted plugin can cause Trivy to write its files (the manifest and the downloaded plugin binary) outside the plugin root, to an arbitrary location writable by the user running Trivy.
Plugins are third-party binaries that Trivy downloads and executes, so Trivy's documentation already advises installing only plugins you trust. This issue does not change that trust boundary: exploitation requires the user to install a malicious plugin in the first place.
Affected configurations
The vulnerability is triggered only when a user installs an attacker-controlled plugin, for example via trivy plugin install <SOURCE> or trivy plugin run <SOURCE>. An attacker has to trick a user into installing a plugin they crafted, for instance by publishing it or by getting a malicious source pasted into a command or documentation snippet.
Plugins distributed through the official Trivy plugin index are not affected.
Impact
A user who installs a malicious plugin can have files written outside the plugin root, to any location writable by the user running Trivy. The vulnerability does not grant any privileges beyond what that user already has.
Patches
Fixed in Trivy 0.72.0. Users should upgrade to that release or later.
Workarounds
Only install Trivy plugins from sources you trust. Plugins from the official Trivy plugin index are safe. See the plugin documentation for details.
Credits
Reported by @fatihhcelik.