{"id":"CVE-2024-52308","aliases":["CVE-2024-52308","GHSA-p2h2-3vg9-4p87","GO-2024-3269"],"related":["CGA-qhx9-vc73-x5fp"],"kind":"vulnerability","state":"published","title":"Connecting to a malicious Codespaces via GH CLI could allow command execution on the user's computer","summary":"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.\n\nDevelopers 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.\n\nThis 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.\n\nIn `2.62.0`, the remote username information is being validated before being used.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.\n\nDevelopers 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.\n\nThis 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.\n\nIn `2.62.0`, the remote username information is being validated before being used.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nA 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.\n\n### Details\n\nThe 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](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/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#L263) for `gh codespace ssh` or `gh codespace logs` commands.\n\nThis 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.\n\nIn `2.62.0`, the remote username information is being validated before being used.\n\n### Impact\n\nSuccessful exploitation could lead to arbitrary code execution on the user's workstation, potentially compromising the user's data and system.\n\n### Remediation and Mitigation\n\n1. Upgrade `gh` to `2.62.0`\n2. Exercise caution when using custom devcontainer images, prefer default or pre-built devcontainers from trusted sources.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Connecting to a malicious Codespaces via GH CLI could allow command execution on the user's computer in github.com/cli/cli","format":"markdown","source":"go"},{"lang":"es","text":"La versión 2.6.1 y anteriores de la CLI de GitHub son vulnerables a la ejecución remota de código a través de un servidor SSH de codespace malicioso cuando se usan los comandos `gh codespace ssh` o `gh codespace logs`. Esto se ha corregido en la CLI v2.62.0. Los desarrolladores se conectan a codespaces remotos a través de un servidor SSH que se ejecuta dentro del devcontainer, que generalmente se proporciona a través de la [imagen predeterminada de devcontainer]( 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 [recupera detalles de conexión SSH]( 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 ), como el nombre de usuario remoto, que se utiliza al [ejecutar comandos `ssh`]( 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 ) para los comandos `gh codespace ssh` o `gh codespace logs`. Esta vulnerabilidad se produce cuando un contenedor de desarrollo malintencionado de terceros contiene un servidor SSH modificado que inyecta argumentos `ssh` dentro de los detalles de la conexión SSH. Los comandos `gh codespace ssh` y `gh codespace logs` podrían ejecutar código arbitrario en la estación de trabajo del usuario si el nombre de usuario remoto contiene algo como `-oProxyCommand=\"echo hacked\" #`. El indicador `-oProxyCommand` hace que `ssh` ejecute el comando proporcionado mientras que el comentario de shell `#` hace que se ignoren todos los demás argumentos de `ssh`. En `2.62.0`, la información del nombre de usuario remoto se valida antes de usarse.","source":"nvd"}],"published":"2024-11-14T17:39:01.000Z","modified":"2026-09-10T03:50:20.953Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H","score":8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H","score":8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:H","score":8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H","score":9.6,"rating":"CRITICAL"}],"cwes":["CWE-77"],"affected":[{"ranges":[{"version":"<= 2.61.0","status":"affected"}],"vendor":"cli","product":"cli","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","lastAffected":"2.6.1","status":"affected"}],"vendor":"github","product":"cli","cpe":"cpe:2.3:a:github:cli:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.62.0"}],"ecosystem":"Go","package":"github.com/cli/cli/v2","purl":"pkg:golang/github.com/cli/cli/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.62.0"}],"ecosystem":"Go","package":"github.com/cli/cli","purl":"pkg:golang/github.com/cli/cli","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/cli/cli","purl":"pkg:golang/github.com/cli/cli","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.62.0"}],"ecosystem":"Go","package":"github.com/cli/cli/v2","purl":"pkg:golang/github.com/cli/cli/v2","source":"go"},{"ranges":[{"status":"affected","fixed":"2.62.0"}],"vendor":"github","product":"cli","cpe":"cpe:2.3:a:github:cli:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/cli/cli/security/advisories/GHSA-p2h2-3vg9-4p87","tags":["advisory","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-52308","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/cli/cli","tags":["package"],"sources":["ghsa"]},{"url":"https://pkg.go.dev/vuln/GO-2024-3269","tags":["web"],"sources":["ghsa"]}],"credits":["RyotaK from Flatt Security Inc."],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2024-11-15T19:31:52.795Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-52308","url":"https://www.cve.org/CVERecord?id=CVE-2024-52308","licence":"CVE Terms of Use","modified":"2024-11-15T19:33:42.842Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-p2h2-3vg9-4p87","url":"https://github.com/advisories/GHSA-p2h2-3vg9-4p87","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:20.953Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-3269","url":"https://pkg.go.dev/vuln/GO-2024-3269","licence":"CC-BY-4.0","modified":"2026-02-04T04:11:55.504Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-52308","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-52308","licence":"Public domain","modified":"2026-06-17T08:06:59.113Z"}],"updatedAt":"2026-11-25T22:58:48.282Z","epss":{"score":0.00906,"percentile":0.60918,"date":"2026-12-01T12:00:22.000Z"}}