CVE-2019-8320: Rubygems update RubyGems Delete Directory Using Symlink Vulnerability

HIGH
Advisory Identifier: GHSA-5x32-c9mf-49cc
CVSS 7.4
CWE-22
Published
Advisory Summary

CVE-2019-8320 is a HIGH (CVSS 7.4) rubygems delete directory using symlink vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Rubygems update libraries in the RubyGems ecosystem. The issue involves rubygems delete directory using symlink when decompressing tar. Remediation is available by upgrading affected packages to version 2.7.9, 3.0.3.

CVE-2019-8320 at a Glance

CVE Identifier CVE-2019-8320
GHSA Identifier GHSA-5x32-c9mf-49cc
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Rubygems update
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 7.4

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

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

How to Fix CVE-2019-8320

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

rubygems-update fixed: 2.7.9
Upgrade rubygems-update to 2.7.9
rubygems-update fixed: 3.0.3
Upgrade rubygems-update to 3.0.3
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 rubygems-update

How to Check if You Are Affected

To determine whether your application is affected by CVE-2019-8320, inspect your project dependencies for Rubygems update:

inspect dependencies for rubygems-update

Analyze the terminal output to locate any version of Rubygems update in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.7.9), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Rubygems update, 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

A Directory Traversal issue was discovered in RubyGems 2.7.6 and later through 3.0.2. Before making new directories or touching files (which now include path-checking code for symlinks), it would delete the target destination. If that destination was hidden behind a symlink, a malicious gem could delete arbitrary files on the user's machine, presuming the attacker could guess at paths. Given how frequently gem is run as sudo, and how predictable paths are on modern systems (/tmp, /usr, etc.), this could likely lead to data loss or an unusable system.

CVE-2019-8320 Affected Rubygems update Versions

2 component(s)
Fixed Versions:
2.7.93.0.3
Product / Package Ecosystem Affected Versions Fixed Version
rubygems-update
RubyGems
≥ 2.7.6
< 2.7.9
2.7.9
rubygems-update
RubyGems
≥ 3.0.0
< 3.0.3
3.0.3

References

Frequently Asked Questions

What is CVE-2019-8320?
CVE-2019-8320 is a security vulnerability in Rubygems update involving RubyGems Delete directory using symlink when decompressing tar under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Rubygems update versions are affected?
Affected versions include releases prior to 2.7.9, 3.0.3 across affected packages: rubygems-update.
What version fixes CVE-2019-8320?
Upgrading to 2.7.9, 3.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is rubygems-update affected?
Yes, rubygems-update is affected in releases prior to 2.7.9, 3.0.3. Upgrade your dependency to 2.7.9, 3.0.3 or later.
What is the CVSS score of CVE-2019-8320?
CVE-2019-8320 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2019-8320?
CVE-2019-8320 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check RubyGems dependencies for CVE-2019-8320?
Run the dependency tree command: 'inspect dependencies for rubygems-update'. 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-5x32-c9mf-49cc",
  "modified" : "2023-08-28T13:16:23Z",
  "published" : "2019-06-20T16:06:15Z",
  "aliases" : [ "CVE-2019-8320" ],
  "summary" : "RubyGems Delete directory using symlink when decompressing tar",
  "details" : "A Directory Traversal issue was discovered in RubyGems 2.7.6 and later through 3.0.2. Before making new directories or touching files (which now include path-checking code for symlinks), it would delete the target destination. If that destination was hidden behind a symlink, a malicious gem could delete arbitrary files on the user's machine, presuming the attacker could guess at paths. Given how frequently gem is run as sudo, and how predictable paths are on modern systems (/tmp, /usr, etc.), this could likely lead to data loss or an unusable system.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "rubygems-update"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.7.6"
      }, {
        "fixed" : "2.7.9"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "rubygems-update"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-8320"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/317321"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2019:1429"
  }, {
    "type" : "WEB",
    "url" : "https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rubygems/rubygems"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rubygems-update/CVE-2019-8320.yml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2020/08/msg00027.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2019-07/msg00036.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2019-06-20T16:02:48Z",
    "nvd_published_at" : null
  }
}