CVE-2024-52308: Connecting to a malicious Codespaces via GH CLI could allow command execution on the user's computer
Summary A security vulnerability has been identified in GitHub CLI that could allow remote code execution (RCE) when users connect to a malicious Codespace SSH server and use the gh codespace ssh or gh codespace logs commands. Details The vulnerability stems from the way GitHub CLI handles SSH connection details when executing commands.
Published Nov 14, 2024 · Updated Nov 19, 2024
Affected packages
github.com/cli/cli/v2
- Ecosystem
- Go
- Affected
- <= 2.61.0
- Fixed in
- 2.62.0
- Check
go list -m github.com/cli/cli/v2
github.com/cli/cli
- Ecosystem
- Go
- Affected
- < 2.62.0
- Fixed in
- 2.62.0
- Check
go list -m github.com/cli/cli
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
A security vulnerability has been identified in GitHub CLI that could allow remote code execution (RCE) when users connect to a malicious Codespace SSH server and use the gh codespace ssh or gh codespace logs commands.
Details
The vulnerability stems from the way GitHub CLI handles SSH connection details when executing commands. When developers connect to remote Codespaces, they typically use a SSH server running within a devcontainer, often provided through the default devcontainer image. GitHub CLI retrieves SSH connection details, such as remote username, which is used in executing `ssh` commands 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.
Impact
Successful exploitation could lead to arbitrary code execution on the user's workstation, potentially compromising the user's data and system.
Remediation and Mitigation
- Upgrade
ghto2.62.0 - Exercise caution when using custom devcontainer images, prefer default or pre-built devcontainers from trusted sources.
Credited to sarahbarili, cmbrose, BlueSzy, andyfeller, BagToad, Ry0taK.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-64652
GitHub CLI partially discloses authentication tokens in `gh auth status` output
low3.3Oct 15, 2026CVE-2026-64653
GitHub CLI allows path traversal through unescaped request URL components
low2.1Oct 15, 2026CVE-2026-64655
GitHub CLI allows attestation verification bypass through unescaped regex metacharacters
low2.1Oct 15, 2026CVE-2026-48501
GitHub CLI has an incorrect authorization header in API requests to TUF repository mirrors via `gh attestation`, `gh release verify`, and `gh release verify-asset` commands
high7.4May 29, 2026CVE-2026-45803
GitHub CLI: GitHub Actions log output in `gh run view` allows terminal escape sequence injection
low3.5No fixMay 19, 2026CVE-2025-25204
`gh attestation verify` returns incorrect exit code during verification if no attestations are present
medium6.3Feb 14, 2025
