CVE-2024-53858: Github.com/cli/cli/v2 Recursive Repository Cloning Can Leak Vulnerability

MODERATE
Advisory Identifier: GHSA-jwcm-9g39-pmcw
CVSS 6.5
CWE-200
Published
Advisory Summary

CVE-2024-53858 is a MODERATE (CVSS 6.5) recursive repository cloning can leak vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Github.com/cli/cli/v2 libraries in the Go ecosystem. The issue involves recursive repository cloning can leak authentication tokens to non-github submodule hosts. Remediation is available by upgrading affected packages to version 2.63.0.

CVE-2024-53858 at a Glance

CVE Identifier CVE-2024-53858
GHSA Identifier GHSA-jwcm-9g39-pmcw
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Github.com/cli/cli/v2
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 6.5

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

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

How to Fix CVE-2024-53858

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.0
Upgrade github.com/cli/cli/v2 to 2.63.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/cli/cli/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-53858, 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.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-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. 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 the GitHub CLI that could leak authentication tokens when cloning repositories containing `git` submodules hosted outside of GitHub.com and ghe.com. ### Details This vulnerability stems from several `gh` commands used to clone a repository with submodules from a non-GitHub host including `gh repo clone`, `gh repo fork`, `gh pr checkout`. These GitHub CLI commands invoke `git` with instructions to retrieve authentication tokens using the [`credential.helper`](https://git-scm.com/docs/gitcredentials) configuration variable for any host encountered. Prior to `2.63.0`, hosts other than GitHub.com and ghe.com are treated as GitHub Enterprise Server hosts and have tokens sourced from the following environment variables before falling back to host-specific tokens stored within system-specific secured storage: - `GITHUB_ENTERPRISE_TOKEN` - `GH_ENTERPRISE_TOKEN` - `GITHUB_TOKEN` _when `CODESPACES` environment variable is set_ The result being `git` sending authentication tokens when cloning submodules. In `2.63.0`, these GitHub CLI commands will limit the hosts for which `gh` acts as a credential helper to source authentication tokens. Additionally, `GITHUB_TOKEN` will only be used for GitHub.com and ghe.com. ### Impact Successful exploitation could lead to a third-party using leaked authentication tokens to access privileged resources. ### Remediation and mitigation 1. Upgrade `gh` to `2.63.0` 2. Revoke authentication tokens used with the GitHub CLI: - [Personal access tokens](https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) - [GitHub CLI OAuth app](https://docs.github.com/en/apps/using-github-apps/reviewing-and-revoking-authorization-of-github-apps#reviewing-your-authorized-github-apps) 3. Review your personal [security log](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-security-log) and any relevant [audit logs](https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/identifying-audit-log-events-performed-by-an-access-token) for actions associated with your account or enterprise

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

1 component(s)
Fixed Versions:
2.63.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/cli/cli/v2
Go
< 2.63.0
2.63.0

References

Frequently Asked Questions

What is CVE-2024-53858?
CVE-2024-53858 is a security vulnerability in Github.com/cli/cli/v2 involving Recursive repository cloning can leak authentication tokens to non-GitHub submodule hosts under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Github.com/cli/cli/v2 versions are affected?
Affected versions include releases prior to 2.63.0 across affected packages: github.com/cli/cli/v2.
What version fixes CVE-2024-53858?
Upgrading to 2.63.0 (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.0. Upgrade your dependency to 2.63.0 or later.
What is the CVSS score of CVE-2024-53858?
CVE-2024-53858 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2024-53858?
CVE-2024-53858 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check Go dependencies for CVE-2024-53858?
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-jwcm-9g39-pmcw",
  "modified" : "2024-12-02T18:03:39Z",
  "published" : "2024-11-27T21:43:05Z",
  "aliases" : [ "CVE-2024-53858" ],
  "summary" : "Recursive repository cloning can leak authentication tokens to non-GitHub submodule hosts",
  "details" : "### Summary\n\nA security vulnerability has been identified in the GitHub CLI that could leak authentication tokens when cloning repositories containing `git` submodules hosted outside of GitHub.com and ghe.com.\n\n### Details\n\nThis vulnerability stems from several `gh` commands used to clone a repository with submodules from a non-GitHub host including `gh repo clone`, `gh repo fork`, `gh pr checkout`. These GitHub CLI commands invoke `git` with instructions to retrieve authentication tokens using the [`credential.helper`](https://git-scm.com/docs/gitcredentials) configuration variable for any host encountered.\n\nPrior to `2.63.0`, hosts other than GitHub.com and ghe.com are treated as GitHub Enterprise Server hosts and have tokens sourced from the following environment variables before falling back to host-specific tokens stored within system-specific secured storage:\n\n- `GITHUB_ENTERPRISE_TOKEN`\n- `GH_ENTERPRISE_TOKEN`\n- `GITHUB_TOKEN` _when `CODESPACES` environment variable is set_\n\nThe result being `git` sending authentication tokens when cloning submodules.\n\nIn `2.63.0`, these GitHub CLI commands will limit the hosts for which `gh` acts as a credential helper to source authentication tokens. Additionally, `GITHUB_TOKEN` will only be used for GitHub.com and ghe.com.\n\n### Impact\n\nSuccessful exploitation could lead to a third-party using leaked authentication tokens to access privileged resources.\n\n### Remediation and mitigation\n\n1. Upgrade `gh` to `2.63.0`\n2. Revoke authentication tokens used with the GitHub CLI: \n    - [Personal access tokens](https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)\n    - [GitHub CLI OAuth app](https://docs.github.com/en/apps/using-github-apps/reviewing-and-revoking-authorization-of-github-apps#reviewing-your-authorized-github-apps)\n3. Review your personal [security log](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/reviewing-your-security-log) and any relevant [audit logs](https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/identifying-audit-log-events-performed-by-an-access-token) for actions associated with your account or enterprise",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/cli/cli/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.63.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.62.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cli/cli/security/advisories/GHSA-jwcm-9g39-pmcw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-53858"
  }, {
    "type" : "WEB",
    "url" : "https://git-scm.com/docs/gitcredentials"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cli/cli"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-27T21:43:05Z",
    "nvd_published_at" : "2024-11-27T22:15:05Z"
  }
}