CVE-2024-54132: Github.com/cli/cli/v2 Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-2m9h-r57g-45pj
CWE-22
Published
Advisory Summary

CVE-2024-54132 is a MODERATE path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/cli/cli/v2 libraries in the Go ecosystem. The issue involves downloading malicious github actions workflow artifact results in path traversal vulnerability. Remediation is available by upgrading affected packages to version 2.63.1.

CVE-2024-54132 at a Glance

CVE Identifier CVE-2024-54132
GHSA Identifier GHSA-2m9h-r57g-45pj
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Github.com/cli/cli/v2
Package Ecosystem Go
Published Date
Last Updated

How to Fix CVE-2024-54132

To remediate this vulnerability, upgrade all affected Github.com/cli/cli/v2 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/cli/cli/v2 fixed: 2.63.1
Upgrade github.com/cli/cli/v2 to 2.63.1
github.com/cli/cli fixed: Latest secure release
Upgrade github.com/cli/cli to Latest secure release
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/cli/cli/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-54132, inspect your project dependencies for Github.com/cli/cli/v2:

inspect dependencies for github.com/cli/cli/v2

Analyze the terminal output to locate any version of Github.com/cli/cli/v2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.63.1), 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 Github.com/cli/cli/v2, 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 A security vulnerability has been identified in GitHub CLI that could create or overwrite files in unintended directories when users download a malicious GitHub Actions workflow artifact through `gh run download`. ### Details This vulnerability stems from a GitHub Actions workflow artifact named `..` when downloaded using `gh run download`. The artifact name and `--dir` flag are used to determine the artifact’s download path. When the artifact is named `..`, the resulting files within the artifact are extracted exactly 1 directory higher than the specified `--dir` flag value. In `2.63.1`, `gh run download` will not download artifacts named `..` and `.` and instead exit with the following error message: ``` error downloading ..: would result in path traversal ``` ### Impact Successful exploitation heightens the risk of local path traversal attack vectors exactly 1 directory higher than intended. ### Remediation and Mitigation 1. Upgrade `gh` to `2.63.1` 2. Implement additional validation to ensure artifact filenames do not contain potentially dangerous patterns, such as `..`, to prevent path traversal risks.

CVE-2024-54132 Affected Github.com/cli/cli/v2 Versions

2 component(s)
Fixed Versions:
2.63.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/cli/cli/v2
Go
< 2.63.1
2.63.1
github.com/cli/cli
Go
≤ 1.14.0

References

Frequently Asked Questions

What is CVE-2024-54132?
CVE-2024-54132 is a security vulnerability in Github.com/cli/cli/v2 involving Downloading malicious GitHub Actions workflow artifact results in path traversal vulnerability under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Github.com/cli/cli/v2 versions are affected?
Affected versions include releases prior to 2.63.1 across affected packages: github.com/cli/cli/v2, github.com/cli/cli.
What version fixes CVE-2024-54132?
Upgrading to 2.63.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/cli/cli/v2 affected?
Yes, github.com/cli/cli/v2 is affected in releases prior to 2.63.1. Upgrade your dependency to 2.63.1 or later.
Is github.com/cli/cli affected?
Yes, github.com/cli/cli is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with CVE-2024-54132?
CVE-2024-54132 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 Go dependencies for CVE-2024-54132?
Run the dependency tree command: 'inspect dependencies for github.com/cli/cli/v2'. 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-2m9h-r57g-45pj",
  "modified" : "2024-12-04T22:17:31Z",
  "published" : "2024-12-04T15:32:45Z",
  "aliases" : [ "CVE-2024-54132" ],
  "summary" : "Downloading malicious GitHub Actions workflow artifact results in path traversal vulnerability",
  "details" : "### Summary\n\nA security vulnerability has been identified in GitHub CLI that could create or overwrite files in unintended directories when users download a malicious GitHub Actions workflow artifact through `gh run download`. \n\n### Details\n\nThis vulnerability stems from a GitHub Actions workflow artifact named `..` when downloaded using `gh run download`.  The artifact name and `--dir` flag are used to determine the artifact’s download path.  When the artifact is named `..`, the resulting files within the artifact are extracted exactly 1 directory higher than the specified `--dir` flag value.\n\nIn `2.63.1`, `gh run download` will not download artifacts named `..` and `.` and instead exit with the following error message:\n\n```\nerror downloading ..: would result in path traversal\n```\n\n### Impact\n\nSuccessful exploitation heightens the risk of local path traversal attack vectors exactly 1 directory higher than intended.\n\n### Remediation and Mitigation\n\n1. Upgrade `gh` to `2.63.1`\n2. Implement additional validation to ensure artifact filenames do not contain potentially dangerous patterns, such as `..`, to prevent path traversal risks.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/U:Green"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/cli/cli/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.63.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/cli/cli"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.14.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cli/cli/security/advisories/GHSA-2m9h-r57g-45pj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-54132"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cli/cli/commit/1136764c369aaf0cae4ec2ee09dc35d871076932"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cli/cli"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-04T15:32:45Z",
    "nvd_published_at" : "2024-12-04T16:15:26Z"
  }
}