Remote Code Execution Vulnerability in GitHub CLI (gh) Prior to v2.62.0

gh Updated 02 Oct 2025

Summary

14/11/2024
N/A
No i
Critical
9.6

CVE-2024-52308: The GitHub CLI version 2.6.1 and earlier are vulnerable to remote code execution through a malicious codespace SSH server when using gh codespace ssh or gh codespace logs commands. Affects gh versions < cd3f2ad064fbeca17d330e321fef0591eaa0fea5. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

GitHub CLI (gh) is a command-line tool that allows developers to interact with GitHub from the terminal. It provides functionalities such as creating issues, managing pull requests, and accessing GitHub Codespaces. The tool is widely used for its ability to streamline workflows and enhance productivity. However, versions 2.6.1 and earlier are vulnerable to a remote code execution flaw when using specific commands related to Codespaces.

Vulnerability Detail

The vulnerability arises from the way GitHub CLI retrieves SSH connection details from a potentially malicious devcontainer. When users execute the 'gh codespace ssh' or 'gh codespace logs' commands, the CLI uses the remote username to establish an SSH connection. If a malicious devcontainer modifies the SSH server to inject arguments into the remote username, it can lead to arbitrary code execution on the user's workstation. For instance, a remote username like '-oProxyCommand="echo hacked" #' can exploit this flaw, allowing attackers to execute unintended commands.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary measure, users should avoid connecting to untrusted or unknown devcontainers until they have updated to the patched version of GitHub CLI. Additionally, users can manually validate SSH connection details before executing commands.

Conclusion

The remote code execution vulnerability in GitHub CLI versions 2.6.1 and earlier poses a significant risk to users connecting to potentially malicious devcontainers. It is crucial to update to version 2.62.0 or later to mitigate this risk. Users should also exercise caution when connecting to unknown environments.

See every vulnerability recorded for gh →

Share this vulnerability

FAQ

The vulnerability can lead to remote code execution on the user's machine, allowing attackers to execute arbitrary commands.

You can check your GitHub CLI version by running 'gh --version' in your terminal. If it is 2.6.1 or earlier, it is affected.

If you cannot update immediately, avoid using 'gh codespace ssh' or 'gh codespace logs' commands with untrusted devcontainers.

Yes, you can use Vulert, which monitors and alerts for open-source vulnerabilities in your software using a manifest file like package-lock.json.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.

Related vulnerabilities

Recent vulnerabilities recorded for gh.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback