Skip to content

Trivy possibly leaks registry credential when scanning images from malicious registries

Moderate severity GitHub Reviewed Published May 20, 2024 in aquasecurity/trivy • Updated May 20, 2024

Package

gomod github.com/aquasecurity/trivy (Go)

Affected versions

< 0.51.2

Patched versions

0.51.2

Description

Impact

If a malicious actor is able to trigger Trivy to scan container images from a crafted malicious registry, it could result in the leakage of credentials for legitimate registries such as AWS Elastic Container Registry (ECR), Google Cloud Artifact/Container Registry, or Azure Container Registry (ACR). These tokens can then be used to push/pull images from those registries to which the identity/user running Trivy has access.

Taking AWS as an example, the leakage only occurs when Trivy is able to transparently obtain registry credentials from the default credential provider chain. You are affected if Trivy is executed in any of the following situations:

  • The environment variables contain static AWS credentials (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN) that have access to ECR.
  • Within a Pod running on an EKS cluster that has been assigned a role with access to ECR using an IAM Roles for Service Accounts (IRSA) annotation.
  • etc.

You are not affected if the default credential provider chain is unable to obtain valid credentials. The same applies to GCP and Azure.

Workarounds

If you are using Trivy v0.51.2 or later, you are not affected. If you are using Trivy v0.51.1 or prior, you should ensure you only scan images from trusted registries.

This vulnerability only applies when scanning container images directly from a registry. If you use Docker, containerd or other runtime to pull images locally and scan them with Trivy, you are not affected. To enforce this behavior, you can use the --image-src flag to select which sources you trust.

References

@knqyf263 knqyf263 published to aquasecurity/trivy May 20, 2024
Published to the GitHub Advisory Database May 20, 2024
Reviewed May 20, 2024
Published by the National Vulnerability Database May 20, 2024
Last updated May 20, 2024

Severity

Moderate
5.5
/ 10

CVSS base metrics

Attack vector
Local
Attack complexity
High
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N

Weaknesses

CVE ID

CVE-2024-35192

GHSA ID

GHSA-xcq4-m2r3-cmrj

Source code

Credits

Checking history
See something to contribute? Suggest improvements for this vulnerability.