CVE-2024-53858
JSON

6.5medium

Recursive repository cloning can leak authentication tokens to non-GitHub submodule hosts in the gh cli

Severity
6.5medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.28% (higher than 21% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-jwcm-9g39-pmcwGO-2024-3296

Description

The gh cli is GitHub’s official command line tool. 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. 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`, and `gh pr checkout`. These GitHub CLI commands invoke git with instructions to retrieve authentication tokens using the `credential.helper` configuration variable for any host encountered. Prior to version `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: 1. `GITHUB_ENTERPRISE_TOKEN`, 2. `GH_ENTERPRISE_TOKEN` and 3. `GITHUB_TOKEN` when the `CODESPACES` environment variable is set. The result being `git` sending authentication tokens when cloning submodules. In version `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. Users are advised to upgrade. Additionally users are advised to revoke authentication tokens used with the GitHub CLI and to review their personal security log and any relevant audit logs for actions associated with their account or enterprise

Affected

Product or packageVersionsReported by
cli cli< 2.63.0CVE List
github clibefore 2.63.0CVE List
github.com/cli/cli/v2 (Go)before 2.63.0GitHub Advisory Database, Go Vulnerability Database
github.com/cli/cli (Go)all versionsGo Vulnerability Database

All scores

GitHub_M6.5medium CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L
GitHub6.5medium CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L

Classification

CWE-200

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

The gh cli is GitHub’s official command line tool. 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. 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`, and `gh pr checkout`. These GitHub CLI commands invoke git with instructions to retrieve authentication tokens using the `credential.helper` configuration variable for any host encountered. Prior to version `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: 1. `GITHUB_ENTERPRISE_TOKEN`, 2. `GH_ENTERPRISE_TOKEN` and 3. `GITHUB_TOKEN` when the `CODESPACES` environment variable is set. The result being `git` sending authentication tokens when cloning submodules. In version `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. Users are advised to upgrade. Additionally users are advised to revoke authentication tokens used with the GitHub CLI and to review their personal security log and any relevant audit logs for actions associated with their account or enterprise

GitHub Advisory Database
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 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:
  3. Review your personal security log and any relevant audit logs for actions associated with your account or enterprise
Go Vulnerability Database

Recursive repository cloning can leak authentication tokens to non-GitHub submodule hosts in github.com/cli/cli

NVD (es)

La CLI de gh es la herramienta de línea de comandos oficial de GitHub. Se ha identificado una vulnerabilidad de seguridad en la CLI de GitHub que podría filtrar tokens de autenticación al clonar repositorios que contienen submódulos `git` alojados fuera de GitHub.com y ghe.com. Esta vulnerabilidad se origina en varios comandos `gh` utilizados para clonar un repositorio con submódulos de un host que no es de GitHub, incluidos `gh repo clone`, `gh repo fork` y `gh pr checkout`. Estos comandos de la CLI de GitHub invocan git con instrucciones para recuperar tokens de autenticación utilizando la variable de configuración `credential.helper` para cualquier host encontrado. Antes de la versión `2.63.0`, los hosts que no sean GitHub.com y ghe.com se tratan como hosts de GitHub Enterprise Server y tienen tokens provenientes de las siguientes variables de entorno antes de recurrir a tokens específicos del host almacenados dentro de un almacenamiento seguro específico del sistema: 1. `GITHUB_ENTERPRISE_TOKEN`, 2. `GH_ENTERPRISE_TOKEN` y 3. `GITHUB_TOKEN` cuando se establece la variable de entorno `CODESPACES`. El resultado es que `git` envía tokens de autenticación al clonar submódulos. En la versión `2.63.0`, estos comandos de la CLI de GitHub limitarán los hosts para los que `gh` actúa como un asistente de credenciales para obtener tokens de autenticación. Además, `GITHUB_TOKEN` solo se usará para GitHub.com y ghe.com. Se recomienda a los usuarios que actualicen. Además, se recomienda a los usuarios revocar los tokens de autenticación utilizados con la CLI de GitHub y revisar su registro de seguridad personal y cualquier registro de auditoría relevante para las acciones asociadas con su cuenta o empresa.

References

Related

Sources

SourceRecordLicence
CVE ListCVE-2024-53858 changed 2024-12-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-jwcm-9g39-pmcw changed 2026-09-10CC-BY-4.0
Go Vulnerability DatabaseGO-2024-3296 changed 2026-02-04CC-BY-4.0
NVDCVE-2024-53858 changed 2026-06-17Public domain