GHSA-p2h2-3vg9-4p87

Suggest an improvement
Source
https://github.com/advisories/GHSA-p2h2-3vg9-4p87
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/11/GHSA-p2h2-3vg9-4p87/GHSA-p2h2-3vg9-4p87.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-p2h2-3vg9-4p87
Aliases
Related
Published
2024-11-14T17:39:01Z
Modified
2024-11-19T19:37:12Z
Severity
  • 8.0 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H CVSS Calculator
Summary
Connecting to a malicious Codespaces via GH CLI could allow command execution on the user's computer
Details

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.
Database specific
{
    "nvd_published_at": "2024-11-14T23:15:05Z",
    "cwe_ids": [
        "CWE-77"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-11-14T17:39:01Z"
}
References

Affected packages

Go / github.com/cli/cli/v2

Package

Name
github.com/cli/cli/v2
View open source insights on deps.dev
Purl
pkg:golang/github.com/cli/cli/v2

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
2.62.0

Database specific

{
    "last_known_affected_version_range": "<= 2.61.0"
}

Go / github.com/cli/cli

Package

Name
github.com/cli/cli
View open source insights on deps.dev
Purl
pkg:golang/github.com/cli/cli

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
2.62.0