Vulnerabilities in pkg:golang/zotregistry.io/zot

PACKAGE
Advisory Identifier: GHSA-55r9-5mx9-qq7r
Advisory Summary

CVE-2024-39897 is a MODERATE (CVSS 4.3) cache driver getblob() allows read vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Zotregistry.io/zot libraries in the Go ecosystem. The issue involves cache driver getblob() allows read access to any blob without access control check. Remediation is available by upgrading affected packages to version 2.1.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/zotregistry.io/zot

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/zotregistry.io/zot. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-55r9-5mx9-qq7r CVE-2024-39897 MODERATE Cache driver GetBlob() allows read access to any blob without access control check

CVE-2024-39897 at a Glance

CVE Identifier CVE-2024-39897
GHSA Identifier GHSA-55r9-5mx9-qq7r
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-639: Authorization Bypass Through User-Controlled Key
Affected Product Zotregistry.io/zot
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-39897

To remediate this vulnerability, upgrade all affected Zotregistry.io/zot dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

zotregistry.io/zot fixed: 2.1.0
Upgrade zotregistry.io/zot to 2.1.0
zotregistry.dev/zot fixed: 2.1.0
Upgrade zotregistry.dev/zot to 2.1.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for zotregistry.io/zot

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-39897, inspect your project dependencies for Zotregistry.io/zot:

inspect dependencies for zotregistry.io/zot

Analyze the terminal output to locate any version of Zotregistry.io/zot in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Zotregistry.io/zot, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary Cache driver `GetBlob()` allows read access to any blob without access control check ### Details If a Zot `accessControl` policy allows users read access to some repositories but restricts read access to other repositories and `dedupe` is enabled (it is enabled by default), then an attacker who knows the name of an image and the digest of a blob (that they do not have read access to), they may maliciously read it via a second repository they do have read access to. This allows an attacker to read an image that the `accessControl` policy denies. This attack is possible because [`ImageStore.CheckBlob()` calls `checkCacheBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/storage/imagestore/imagestore.go#L1158-L1159) to find the blob a global cache by searching for the digest. If it is found, it is copied to the user requested repository with `copyBlob()`. This cache behavior is intentionally used in [`RouteHandler.CreateBlobUpload()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L1194-L1197) to implement cross repository blob mount (`POST /v2/<name>/blobs/uploads/?mount=<digest>&from=<repository name>`) in Zot. This is still missing an access control to check read access on the source repository. This cache behavior is unexpectedly also used in [`RouteHandler.CheckBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L886) too for `HEAD /v2/<name>/blobs/<digest>`. If a blob is requested that does not exist on the requested repository, Zot will search for it in a global cache (possibly returning a result from an from an incorrect repository) and then will store it into the `ImageStore` for the requested repository. [`RouteHandler.GetBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L1000) does _not_ call `ImageStore.CheckBlob()` so it is not directly vulnerable. However an attacker with only limited read access may first call `CheckBlob()` to fetch the blob from the cache, then call `GetBlob()` to read the blob. ### Mitigation The attack may be mitigated by configuring `"dedupe": false` in the `"storage"` settings. This disables Zot's cache drivers. `dedupe` is enabled by default using the BoltDB cache driver. ### Impact An attacker can read images that the `accessControl` policy denies if they have read access to any other second repository. This attack only allows accessing blobs (both config and layers) by digest. Manifests cannot be accessed. This attack requires the attacker to know the name of a private image and its layer digests. A scenario where this might happen is if a project has public CI build logs but publishes the image to a private repository. Many image build tools log layer digests.

CVE-2024-39897 Affected Zotregistry.io/zot Versions

2 component(s)
Fixed Versions:
2.1.0
Product / Package Ecosystem Affected Versions Fixed Version
zotregistry.io/zot
Go
< 2.1.0
2.1.0
zotregistry.dev/zot
Go
< 2.1.0
2.1.0

References

Frequently Asked Questions

What is CVE-2024-39897?
CVE-2024-39897 is a security vulnerability in Zotregistry.io/zot involving Cache driver GetBlob() allows read access to any blob without access control check under CWE-639: Authorization Bypass Through User-Controlled Key.
Which Zotregistry.io/zot versions are affected?
Affected versions include releases prior to 2.1.0 across affected packages: zotregistry.io/zot, zotregistry.dev/zot.
What version fixes CVE-2024-39897?
Upgrading to 2.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zotregistry.io/zot affected?
Yes, zotregistry.io/zot is affected in releases prior to 2.1.0. Upgrade your dependency to 2.1.0 or later.
Is zotregistry.dev/zot affected?
Yes, zotregistry.dev/zot is affected in releases prior to 2.1.0. Upgrade your dependency to 2.1.0 or later.
What is the CVSS score of CVE-2024-39897?
CVE-2024-39897 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2024-39897?
CVE-2024-39897 is classified under CWE-639: Authorization Bypass Through User-Controlled Key (The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.).
How can I check Go dependencies for CVE-2024-39897?
Run the dependency tree command: 'inspect dependencies for zotregistry.io/zot'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-55r9-5mx9-qq7r",
  "modified" : "2024-07-10T18:34:34Z",
  "published" : "2024-07-09T21:04:00Z",
  "aliases" : [ "CVE-2024-39897" ],
  "summary" : "Cache driver GetBlob() allows read access to any blob without access control check",
  "details" : "### Summary\n\nCache driver `GetBlob()` allows read access to any blob without access control check\n\n### Details\n\nIf a Zot `accessControl` policy allows users read access to some repositories but restricts read access to other repositories and `dedupe` is enabled (it is enabled by default), then an attacker who knows the name of an image and the digest of a blob (that they do not have read access to), they may maliciously read it via a second repository they do have read access to. This allows an attacker to read an image that the `accessControl` policy denies.\n\nThis attack is possible because [`ImageStore.CheckBlob()` calls `checkCacheBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/storage/imagestore/imagestore.go#L1158-L1159) to find the blob a global cache by searching for the digest. If it is found, it is copied to the user requested repository with `copyBlob()`.\n\nThis cache behavior is intentionally used in [`RouteHandler.CreateBlobUpload()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L1194-L1197) to implement cross repository blob mount (`POST /v2/<name>/blobs/uploads/?mount=<digest>&from=<repository name>`) in Zot. This is still missing an access control to check read access on the source repository.\n\nThis cache behavior is unexpectedly also used in [`RouteHandler.CheckBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L886) too for `HEAD /v2/<name>/blobs/<digest>`. If a blob is requested that does not exist on the requested repository, Zot will search for it in a global cache (possibly returning a result from an from an incorrect repository) and then will store it into the `ImageStore` for the requested repository.\n\n[`RouteHandler.GetBlob()`](https://github.com/project-zot/zot/blob/v2.1.0-rc2/pkg/api/routes.go#L1000) does _not_ call `ImageStore.CheckBlob()` so it is not directly vulnerable. However an attacker with only limited read access may first call `CheckBlob()` to fetch the blob from the cache, then call `GetBlob()` to read the blob.\n\n### Mitigation\n\nThe attack may be mitigated by configuring `\"dedupe\": false` in the `\"storage\"` settings. This disables Zot's cache drivers. `dedupe` is enabled by default using the BoltDB cache driver.\n\n### Impact\n\nAn attacker can read images that the `accessControl` policy denies if they have read access to any other second repository.\n\nThis attack only allows accessing blobs (both config and layers) by digest. Manifests cannot be accessed.\n\nThis attack requires the attacker to know the name of a private image and its layer digests. A scenario where this might happen is if a project has public CI build logs but publishes the image to a private repository. Many image build tools log layer digests.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "zotregistry.io/zot"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.1.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "zotregistry.dev/zot"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.1.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/project-zot/zot/security/advisories/GHSA-55r9-5mx9-qq7r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-39897"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/project-zot/zot/commit/aaee0220e46bdadd12115ac67c19f9d3153eb1df"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/project-zot/zot"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-639" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-09T21:04:00Z",
    "nvd_published_at" : "2024-07-09T19:15:12Z"
  }
}