Connecting to a malicious Codespaces via GH CLI could allow command execution on the user's computer
Published 14 Nov 2024 · Updated 10 Sept 2026
Is your project on an affected github.com/cli/cli/v2?
Look after several Go apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected packages
- Affected
- <2.62.0
- Fixed in
- 2.62.0
go get github.com/cli/cli/v2@v2.62.0- Affected
- <2.62.0
- Fixed in
- 2.62.0
go get github.com/cli/cli@v2.62.0Details
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
1. Upgrade gh to 2.62.0
2. Exercise caution when using custom devcontainer images, prefer default or pre-built devcontainers from trusted sources.
Is GHSA-p2h2-3vg9-4p87 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected github.com/cli/cli/v2, and gives you the command that fixes it.
More advisories for github.com/cli/cli/v2
- LowCVE-2026-64653GitHub CLI allows path traversal through unescaped request URL components in github.com/cli/cli · 19 Oct 2026
- LowCVE-2026-64652GitHub CLI partially discloses authentication tokens in `gh auth status` output in github.com/cli/cli · 19 Oct 2026
- LowCVE-2026-64655GitHub CLI allows attestation verification bypass through unescaped regex metacharacters in github.com/cli/cli · 19 Oct 2026
- LowCVE-2026-64655GitHub CLI allows attestation verification bypass through unescaped regex metacharacters · 15 Oct 2026
- LowCVE-2026-64653GitHub CLI allows path traversal through unescaped request URL components · 15 Oct 2026
- LowCVE-2026-64652GitHub CLI partially discloses authentication tokens in `gh auth status` output · 15 Oct 2026
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.