CVE-2021-21272: Github.com/deislabs/oras Zip Slip Directory Exploit Vulnerability

HIGH
Advisory Identifier: GHSA-g5v4-5x39-vwhx
CVSS 7.7
CWE-59 CWE-22
Published
Advisory Summary

CVE-2021-21272 is a HIGH (CVSS 7.7) zip slip directory exploit vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting Github.com/deislabs/oras libraries in the Go ecosystem. The issue involves zip slip directory exploit in github.com/deislabs/oras. Remediation is available by upgrading affected packages to version 0.9.0.

CVE-2021-21272 at a Glance

CVE Identifier CVE-2021-21272
GHSA Identifier GHSA-g5v4-5x39-vwhx
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product Github.com/deislabs/oras
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.7

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:C/C:N/I:H/A:N).

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

How to Fix CVE-2021-21272

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

github.com/deislabs/oras fixed: 0.9.0
Upgrade github.com/deislabs/oras to 0.9.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 github.com/deislabs/oras

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-21272, inspect your project dependencies for Github.com/deislabs/oras:

inspect dependencies for github.com/deislabs/oras

Analyze the terminal output to locate any version of Github.com/deislabs/oras in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.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-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In Github.com/deislabs/oras, 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

### Impact The directory support (#55) allows the downloaded gzipped tarballs to be automatically extracted to the user-specified directory where the tarball can have symbolic links and hard links. A well-crafted tarball or tarballs allow malicious artifact providers linking, writing, or overwriting specific files on the host filesystem outside of the user-specified directory unexpectedly with the same permissions as the user who runs `oras pull`. Precisely, the following users of the affected versions are impacted - `oras` CLI users who runs `oras pull`. - Go programs, which invokes `github.com/deislabs/oras/pkg/content.FileStore`. ### Patches The problem has been patched by the PR linked with this advisory. Users should upgrade their `oras` CLI and packages to `0.9.0`. ### Workarounds For `oras` CLI users, there is no workarounds other than pulling from a trusted artifact provider. For `oras` package users, the workaround is to not use `github.com/deislabs/oras/pkg/content.FileStore`, and use other content stores instead, or pull from a trusted artifact provider. ### References - [Zip Slip](https://github.com/snyk/zip-slip-vulnerability) ### For more information If you have any questions or comments about this advisory: * Open an issue on the [GitHub repo](https://github.com/deislabs/oras) * Email the [list of maintainers](https://github.com/deislabs/oras/blob/main/MAINTAINERS)

CVE-2021-21272 Affected Github.com/deislabs/oras Versions

1 component(s)
Fixed Versions:
0.9.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/deislabs/oras
Go
< 0.9.0
0.9.0

References

Frequently Asked Questions

What is CVE-2021-21272?
CVE-2021-21272 is a security vulnerability in Github.com/deislabs/oras involving Zip slip directory exploit in github.com/deislabs/oras under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which Github.com/deislabs/oras versions are affected?
Affected versions include releases prior to 0.9.0 across affected packages: github.com/deislabs/oras.
What version fixes CVE-2021-21272?
Upgrading to 0.9.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/deislabs/oras affected?
Yes, github.com/deislabs/oras is affected in releases prior to 0.9.0. Upgrade your dependency to 0.9.0 or later.
What is the CVSS score of CVE-2021-21272?
CVE-2021-21272 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:H/A:N.
What CWE is associated with CVE-2021-21272?
CVE-2021-21272 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check Go dependencies for CVE-2021-21272?
Run the dependency tree command: 'inspect dependencies for github.com/deislabs/oras'. 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-g5v4-5x39-vwhx",
  "modified" : "2022-10-25T20:26:42Z",
  "published" : "2022-02-15T00:32:04Z",
  "aliases" : [ "CVE-2021-21272" ],
  "summary" : "Zip slip directory exploit in github.com/deislabs/oras",
  "details" : "### Impact\nThe directory support (#55) allows the downloaded gzipped tarballs to be automatically extracted to the user-specified directory where the tarball can have symbolic links and hard links.\n\nA well-crafted tarball or tarballs allow malicious artifact providers linking, writing, or overwriting specific files on the host filesystem outside of the user-specified directory unexpectedly with the same permissions as the user who runs `oras pull`. \n\nPrecisely, the following users of the affected versions are impacted\n- `oras` CLI users who runs `oras pull`.\n- Go programs, which invokes `github.com/deislabs/oras/pkg/content.FileStore`.\n\n### Patches\nThe problem has been patched by the PR linked with this advisory. Users should upgrade their `oras` CLI and packages to `0.9.0`.\n\n### Workarounds\nFor `oras` CLI users, there is no workarounds other than pulling from a trusted artifact provider.\n\nFor `oras` package users, the workaround is to not use `github.com/deislabs/oras/pkg/content.FileStore`, and use other content stores instead, or pull from a trusted artifact provider.\n\n### References\n- [Zip Slip](https://github.com/snyk/zip-slip-vulnerability)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue on the [GitHub repo](https://github.com/deislabs/oras)\n* Email the [list of maintainers](https://github.com/deislabs/oras/blob/main/MAINTAINERS)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/deislabs/oras"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/deislabs/oras/security/advisories/GHSA-g5v4-5x39-vwhx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21272"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deislabs/oras/commit/96cd90423303f1bb42bd043cb4c36085e6e91e8e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/deislabs/oras"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deislabs/oras/releases/tag/v0.9.0"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/github.com/deislabs/oras/pkg/oras"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2021-0099"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-59" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-21T14:42:50Z",
    "nvd_published_at" : "2021-01-25T19:15:00Z"
  }
}