CliApplication · GitHub

CVE-2024-52308

CRITICAL · 9.6 CVSS v3.1 Published 2024-11-14
Fix available
A fix is available. Upgrade to 2.62.0 or later.
See remediation →
100/100
Remediation priority · Urgent
Remotely reachable No privileges

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
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. This has been patched in the cli v2.62.0. Developers connect to remote codespaces through an SSH server running within the devcontainer, which is generally provided through the [default devcontainer image]( https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-... https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-the-default-dev-container-configuration) . GitHub CLI [retrieves SSH connection details]( https://github.com/cli/cli/blob/30066b0042d0c5928d959e288144300cb28196c9/internal/codespaces/rpc/inv... https://github.com/cli/cli/blob/30066b0042d0c5928d959e288144300cb28196c9/internal/codespaces/rpc/invoker.go#L230-L244 ), such as remote username, which is used in [executing `ssh` commands]( https://github.com/cli/cli/blob/e356c69a6f0125cfaac782c35acf77314f18908d/pkg/cmd/codespace/ssh.go#L2... https://github.com/cli/cli/blob/e356c69a6f0125cfaac782c35acf77314f18908d/pkg/cmd/codespace/ssh.go#L263 ) for `gh codespace ssh` or `gh codespace logs` commands. This exploit occurs when a malicious third-party devcontainer contains a modified SSH server that injects `ssh` arguments within the SSH connection details. `gh codespace ssh` and `gh codespace logs` commands could execute arbitrary code on the user's workstation if the remote username contains something like `-oProxyCommand="echo hacked" #`. The `-oProxyCommand` flag causes `ssh` to execute the provided command while `#` shell comment causes any other `ssh` arguments to be ignored. In `2.62.0`, the remote username information is being validated before being used.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

GitHub CLI versions 2.6.1 and earlier are vulnerable to RCE when processing SSH connection details from codespaces. The CLI retrieves a remote username from the codespace's SSH server and passes it directly to the ssh command without validation. A malicious devcontainer can inject ssh arguments like `-oProxyCommand="<arbitrary command>" #` into the username field, causing arbitrary code execution on the user's workstation when running `gh codespace ssh` or `gh codespace logs`.

MitigationUpgrade GitHub CLI to version 2.62.0 or later, which validates the remote username before using it in SSH commands. Avoid using untrusted or third-party devcontainer configurations with codespaces.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

Affected products & versions What the vendor confirmedThe version ranges the vendor confirmed as vulnerable. If your version sits inside a range here, treat yourself as exposed until you have upgraded.

NVD · CPE data
CliApplication
Affected:< 2.62.0

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Check GitHub CLI version
    Run `gh --version` and compare the output to the affected range (< 2.62.0)
    Affected if The installed version is lower than 2.62.0
  2. Verify codespace extension is installed
    Run `gh extension list` or check if `gh codespace --help` returns valid output
    Affected if The codespace extension is present and functional
  3. Check for .devcontainer configurations
    Inspect the filesystem for .devcontainer/devcontainer.json files in projects using codespaces
    Affected if Untrusted or third-party devcontainer configurations are in use
  4. Review codespace ssh command history
    Check shell history or logs for usage of `gh codespace ssh` or `gh codespace logs` commands
    Affected if Either of these commands have been executed against a potentially untrusted codespace

You are affected if you run a GitHub CLI version below 2.62.0 and have used `gh codespace ssh` or `gh codespace logs` with untrusted or third-party devcontainer configurations.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Upgrade available Upgrade to 2.62.0 or later
Fixed in 2.62.0
Interim mitigation

Upgrade GitHub CLI to version 2.62.0 or later, which validates the remote username before using it in SSH commands. Avoid using untrusted or third-party devcontainer configurations with codespaces.

Recommended fix High confidence

2.62.0

  1. Check current gh CLI version by running `gh --version`
  2. Upgrade GitHub CLI to version 2.62.0 or later using your system's package manager or the official installer (e.g., `brew upgrade gh`, `choco upgrade gh`, or download from https://github.com/cli/cli/releases
  3. Verify the upgrade was successful by running `gh --version` and confirming the installed version is 2.62.0 or higher

Generated from the published advisory — verify against the referenced sources before acting.

Fix this in Cli Scoped from the published advisory
  • Consultation1.0 h
  • Testing1.0 h
  • Review / QA1.0 h
3.0 hours of engineering $750
Get the upgrade done

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $1,200.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2024-52308 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2024-52308 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data