Skip to main content
Vulnerability Database/CVE-2024-54132

CVE-2024-54132: GitHub CLI Path Traversal Vulnerability

CVE-2024-54132 is a path traversal flaw in GitHub CLI that allows malicious workflow artifacts to write files outside intended directories. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-54132 Overview

CVE-2024-54132 is a path traversal vulnerability in GitHub CLI, GitHub's official command line tool. The flaw allows a malicious GitHub Actions workflow artifact to create or overwrite files outside the intended destination directory when retrieved via gh run download. The vulnerability occurs when an artifact is named .., causing extracted files to land exactly one directory above the path specified by the --dir flag. GitHub fixed the issue in version 2.63.1. The weakness is classified as CWE-22 (Improper Limitation of a Pathname to a Restricted Directory).

Critical Impact

An attacker publishing a workflow artifact named .. can write files one directory above the intended --dir target, enabling arbitrary file overwrite on systems that download untrusted artifacts.

Affected Products

  • GitHub CLI (gh) versions prior to 2.63.1
  • The gh run download command path specifically
  • Any CI/CD workflow or developer workstation consuming untrusted GitHub Actions artifacts

Discovery Timeline

  • 2024-12-04 - CVE-2024-54132 published to the National Vulnerability Database
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-54132

Vulnerability Analysis

The vulnerability resides in the artifact download logic of GitHub CLI, specifically in pkg/cmd/run/download/download.go and the archive extraction helper filepathDescendsFrom in pkg/cmd/run/download/zip.go. The CLI combines the artifact name with the user-supplied --dir value to compute an output path. When an artifact is named .., path normalization causes extracted files to be written one directory level above the intended target.

The original containment check used simple string prefix comparison after cleaning paths. That approach failed to reject artifacts whose cleaned path resolved to . or .., allowing extraction to escape the destination directory. The impact is limited to file integrity (VI:L) with no direct confidentiality or availability consequence, but overwriting shell profiles, SSH authorized_keys, or CI configuration files can enable follow-on code execution.

Root Cause

The root cause is improper validation of the artifact name as a directory component. The filepathDescendsFrom function did not explicitly reject the special values . and .., and relied on prefix matching rather than canonical relative path analysis. A multi-artifact download without isolation compounded the issue by writing all artifacts into the same computed path.

Attack Vector

Exploitation requires a victim to run gh run download against a workflow run that contains an attacker-controlled artifact named ... The attacker needs permission to publish artifacts in a workflow the victim will fetch, for example through a pull request from a fork in repositories that build untrusted contributions. No authentication is required on the victim side beyond the normal gh session.

go
// Patch excerpt: pkg/cmd/run/download/download.go
 opts.IO.StartProgressIndicator()
 defer opts.IO.StopProgressIndicator()

-// track downloaded artifacts and avoid re-downloading any of the same name
+// track downloaded artifacts and avoid re-downloading any of the same name, isolate if multiple artifacts
 downloaded := set.NewStringSet()
+isolateArtifacts := isolateArtifacts(wantNames, wantPatterns)
+
 for _, a := range artifacts {
     if a.Expired {
         continue

Source: GitHub CLI commit 1136764c

go
// Patch excerpt: pkg/cmd/run/download/zip.go
func filepathDescendsFrom(p, dir string) bool {
+   // Regardless of the logic below, `p` is never allowed to be current directory `.` or parent directory `..`
+   // however we check explicitly here before filepath.Rel() which doesn't cover all cases.
    p = filepath.Clean(p)
-   dir = filepath.Clean(dir)
-   if dir == "." && !filepath.IsAbs(p) {
-       return !strings.HasPrefix(p, ".."+string(filepath.Separator))
+
+   if p == "." || p == ".." {
+       return false
    }
-   if !strings.HasSuffix(dir, string(filepath.Separator)) {
-       dir += string(filepath.Separator)
+
+   relativePath, err := filepath.Rel(dir, p)
+   if err != nil {
+       return false
    }
-   return strings.HasPrefix(p, dir)
+   return !strings.HasPrefix(relativePath, "..")
 }

Source: GitHub CLI commit 1136764c

Detection Methods for CVE-2024-54132

Indicators of Compromise

  • Workflow artifacts named .., ., or containing path separators in their names.
  • Files created or modified one directory above the --dir target shortly after a gh run download invocation.
  • Unexpected writes to shell profiles, SSH key files, or CI configuration directories by the gh process.

Detection Strategies

  • Inventory the gh binary version across developer workstations and CI runners; flag any version below 2.63.1.
  • Audit GitHub Actions workflow runs for artifacts with suspicious names using the REST API endpoint /repos/{owner}/{repo}/actions/artifacts.
  • Correlate process telemetry for gh run download with subsequent file writes outside the specified destination path.

Monitoring Recommendations

  • Enable file integrity monitoring on CI runner working directories and home directories of accounts that execute gh.
  • Log all gh command invocations in CI pipelines and ship them to a central log store for retrospective hunting.
  • Alert on new or modified executables and dotfiles in parent directories of known artifact download paths.

How to Mitigate CVE-2024-54132

Immediate Actions Required

  • Upgrade GitHub CLI to version 2.63.1 or later on all workstations, build agents, and container images.
  • Review recent gh run download activity against repositories that accept pull requests from forks or external contributors.
  • Restrict workflows that publish artifacts from untrusted contexts and require review before artifact consumption.

Patch Information

The fix landed in GitHub CLI 2.63.1. The patch adds explicit rejection of . and .. paths in filepathDescendsFrom, replaces prefix matching with filepath.Rel based containment, and introduces per-artifact isolation when multiple artifacts are downloaded. See the GitHub Security Advisory GHSA-2m9h-r57g-45pj and the upstream commit for full details.

Workarounds

  • Avoid running gh run download against workflow runs produced by untrusted pull requests until the CLI is patched.
  • Execute gh run download inside an ephemeral container or sandbox with no write access to sensitive host paths.
  • Specify an isolated, non-shared --dir target on a dedicated filesystem and verify extracted paths before use.
bash
# Verify installed version and upgrade
gh --version

# macOS (Homebrew)
brew update && brew upgrade gh

# Debian/Ubuntu
sudo apt update && sudo apt install --only-upgrade gh

# Windows (winget)
winget upgrade --id GitHub.cli

# Confirm patched version
gh --version   # expect 2.63.1 or later

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.