# CVE-2024-53859: go-gh `auth.TokenForHost` violates GitHub host security boundary within a codespace

> Attackers can leak GitHub authentication tokens to unintended hosts within a codespace, potentially leading to account takeover.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 27 Nov 2024
- **Updated:** 3 Dec 2024
- **Also known as:** AZL-53453, DEBIAN-CVE-2024-53859, GHSA-55v3-xh23-96gh, GO-2024-3295, UBUNTU-CVE-2024-53859, USN-7362-1

## What is CVE-2024-53859?

CVE-2024-53859 is a medium-severity vulnerability in cli go-gh, published on 27 Nov 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

go-gh is a Go module for interacting with the `gh` utility and the GitHub API from the command line. A security vulnerability has been identified in `go-gh` that could leak authentication tokens intended for GitHub hosts to non-GitHub hosts when within a codespace. `go-gh` sources authentication tokens from different environment variables depending on the host involved: 1. `GITHUB_TOKEN`, `GH_TOKEN` for GitHub.com and ghe.com and 2. `GITHUB_ENTERPRISE_TOKEN`, `GH_ENTERPRISE_TOKEN` for GitHub Enterprise Server. Prior to version `2.11.1`, `auth.TokenForHost` could source a token from the `GITHUB_TOKEN` environment variable for a host other than GitHub.com or ghe.com when within a codespace. In version `2.11.1`, `auth.TokenForHost` will only source a token from the `GITHUB_TOKEN` environment variable for GitHub.com or ghe.com hosts. Successful exploitation could send authentication token to an unintended host. This issue has been addressed in version 2.11.1 and all users are advised to upgrade. Users are also advised to regenerate authentication tokens and to review their personal security log and any relevant audit logs for actions associated with their account or enterprise.

Weakness: CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor)

## Which versions are affected by CVE-2024-53859?

6 open source packages ship an affected version, including github.com/cli/go-gh and github.com/cli/go-gh/v2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/cli/go-gh` | Go | All versions | None |
| `github.com/cli/go-gh` | Go | All versions | None |
| `github.com/cli/go-gh` | Go | All versions | None |
| `github.com/cli/go-gh/v2` | Go | All versions | 2.11.1 |
| `github.com/cli/go-gh/v2` | Go | All versions | 2.11.1 |
| `github.com/cli/go-gh/v2` | Go | All versions | 2.11.1 |

Products: Cli Go-Gh.

## How do I fix CVE-2024-53859?

Upgrade to a fixed version.

## Is CVE-2024-53859 being exploited?

There is no known exploitation of CVE-2024-53859 in the wild and no public exploit code.

## Other vulnerabilities in cli go-gh

- [CVE-2025-48938](https://insights.sbomify.com/CVE-2025-48938/): Prevent GitHub CLI and extensions from executing arbitrary commands from compromised GitHub Enterprise Server (low 2.6)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-53859 and fix it if it is affected.

What it is: CVE-2024-53859 is a medium-severity vulnerability in cli go-gh, published on 27 Nov 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-53859 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/cli/go-gh (Go): affected all versions; no fix listed
- github.com/cli/go-gh (Go): affected all versions; no fix listed
- github.com/cli/go-gh (Go): affected all versions; no fix listed
- github.com/cli/go-gh/v2 (Go): affected all versions; fixed in 2.11.1
- github.com/cli/go-gh/v2 (Go): affected all versions; fixed in 2.11.1
- github.com/cli/go-gh/v2 (Go): affected all versions; fixed in 2.11.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-53859/ (Markdown: https://insights.sbomify.com/CVE-2024-53859/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-53859
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-53859
- OSV: https://osv.dev/vulnerability/CVE-2024-53859

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-53859/
Summaries are generated and may contain mistakes; the official description above is the record.
