CVE-2026-71557: go-git Malicious Reference Names May Modify Vulnerability

MODERATE
Advisory Identifier: GHSA-qgq7-7hm3-q39j
CVSS 6.3
CWE-22
Published
Advisory Summary

CVE-2026-71557 is a MODERATE (CVSS 6.3) malicious reference names may modify vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting go-git libraries in the Go ecosystem. The issue involves malicious reference names may modify files outside the reference storage. Remediation is available by upgrading affected packages to version 5.19.2, 6.0.0-alpha.5.

CVE-2026-71557 at a Glance

CVE Identifier CVE-2026-71557
GHSA Identifier GHSA-qgq7-7hm3-q39j
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product go-git
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 6.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-71557

To remediate this vulnerability, upgrade all affected go-git dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/go-git/go-git/v5 fixed: 5.19.2
Upgrade github.com/go-git/go-git/v5 to 5.19.2
github.com/go-git/go-git/v6 fixed: 6.0.0-alpha.5
Upgrade github.com/go-git/go-git/v6 to 6.0.0-alpha.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/go-git/go-git/v5

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-71557, inspect your project dependencies for go-git:

inspect dependencies for github.com/go-git/go-git/v5

Analyze the terminal output to locate any version of go-git in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.19.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In go-git, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact A path traversal issue in `go-git` could allow malicious reference names to access files outside the repository's intended reference storage. Loose references are stored under `.git/<reference-name>`. The reference name was previously used as a path without verifying that the resolved path remained within the reference storage. A name such as `refs/heads/../../config` could therefore resolve to unrelated repository metadata such as `.git/config` or `.git/HEAD`. A malicious Git server could advertise such a reference name. The name may also survive refspec mapping; for example, it could be mapped to `refs/remotes/origin/../../config` during a clone or fetch operation. This vulnerability affects filesystem-backed repositories using the `storage/filesystem` package and its `dotgit` reference storage. Users relying exclusively on the in-memory storage implementation, `storage/memory`, are not affected, because reference names are not resolved as filesystem paths. Exploitation requires an application using `go-git` with filesystem-backed storage to interact with a malicious Git server or otherwise process attacker-controlled reference names. ### Patches The issue has been addressed by validating reference names at the `dotgit` storage entry points and rejecting names whose resolved paths could escape the reference storage. Users of filesystem-backed storage should upgrade to a patched version. ### Workarounds Applications that exclusively use `storage/memory` are not affected and do not require a workaround for this vulnerability. For applications using filesystem-backed storage, avoid cloning from or fetching from untrusted Git servers until an upgrade is possible. Applications that directly construct or process reference names may also validate them before passing them to filesystem-backed `go-git` storage. Application-level validation should only be considered a temporary mitigation and does not replace upgrading to a patched version. ### References - Fixes: - https://github.com/go-git/go-git/pull/2247 - https://github.com/go-git/go-git/pull/2254 ### Credits Thanks to @Saku0512 for reporting this issue and @Sahana2524 for proposing the initial fix. 🙇

CVE-2026-71557 Affected go-git Versions

2 component(s)
Fixed Versions:
5.19.26.0.0-alpha.5
Product / Package Ecosystem Affected Versions Fixed Version
github.com/go-git/go-git/v5
Go
< 5.19.2
5.19.2
github.com/go-git/go-git/v6
Go
< 6.0.0-alpha.5
6.0.0-alpha.5

References

Frequently Asked Questions

What is CVE-2026-71557?
CVE-2026-71557 is a security vulnerability in go-git involving Malicious reference names may modify files outside the reference storage under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which go-git versions are affected?
Affected versions include releases prior to 5.19.2, 6.0.0-alpha.5 across affected packages: github.com/go-git/go-git/v5, github.com/go-git/go-git/v6.
What version fixes CVE-2026-71557?
Upgrading to 5.19.2, 6.0.0-alpha.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/go-git/go-git/v5 affected?
Yes, github.com/go-git/go-git/v5 is affected in releases prior to 5.19.2. Upgrade your dependency to 5.19.2 or later.
Is github.com/go-git/go-git/v6 affected?
Yes, github.com/go-git/go-git/v6 is affected in releases prior to 6.0.0-alpha.5. Upgrade your dependency to 6.0.0-alpha.5 or later.
What is the CVSS score of CVE-2026-71557?
CVE-2026-71557 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:L.
What CWE is associated with CVE-2026-71557?
CVE-2026-71557 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check Go dependencies for CVE-2026-71557?
Run the dependency tree command: 'inspect dependencies for github.com/go-git/go-git/v5'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qgq7-7hm3-q39j",
  "modified" : "2026-08-07T16:41:51Z",
  "published" : "2026-08-07T16:41:51Z",
  "aliases" : [ "CVE-2026-71557" ],
  "summary" : "go-git: Malicious reference names may modify files outside the reference storage",
  "details" : "### Impact\nA path traversal issue in `go-git` could allow malicious reference names to access files outside the repository's intended reference storage.\n\nLoose references are stored under `.git/<reference-name>`. The reference name was previously used as a path without verifying that the resolved path remained within the reference storage. A name such as `refs/heads/../../config` could therefore resolve to unrelated repository metadata such as `.git/config` or `.git/HEAD`.\n\nA malicious Git server could advertise such a reference name. The name may also survive refspec mapping; for example, it could be mapped to `refs/remotes/origin/../../config` during a clone or fetch operation.\n\nThis vulnerability affects filesystem-backed repositories using the `storage/filesystem` package and its `dotgit` reference storage. Users relying exclusively on the in-memory storage implementation, `storage/memory`, are not affected, because reference names are not resolved as filesystem paths.\n\nExploitation requires an application using `go-git` with filesystem-backed storage to interact with a malicious Git server or otherwise process attacker-controlled reference names.\n\n### Patches\nThe issue has been addressed by validating reference names at the `dotgit` storage entry points and rejecting names whose resolved paths could escape the reference storage.\n\nUsers of filesystem-backed storage should upgrade to a patched version.\n\n### Workarounds\nApplications that exclusively use `storage/memory` are not affected and do not require a workaround for this vulnerability.\n\nFor applications using filesystem-backed storage, avoid cloning from or fetching from untrusted Git servers until an upgrade is possible.\n\nApplications that directly construct or process reference names may also validate them before passing them to filesystem-backed `go-git` storage. Application-level validation should only be considered a temporary mitigation and does not replace upgrading to a patched version.\n\n### References\n- Fixes:\n  - https://github.com/go-git/go-git/pull/2247\n  - https://github.com/go-git/go-git/pull/2254\n\n### Credits\n\nThanks to @Saku0512 for reporting this issue and @Sahana2524 for proposing the initial fix. 🙇",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/go-git/go-git/v5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.19.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.19.1"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/go-git/go-git/v6"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.0.0-alpha.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.0.0-alpha.4"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/security/advisories/GHSA-qgq7-7hm3-q39j"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/pull/2247"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/pull/2254"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/commit/4a0e66d555de5f9a30c31e2df64f445f42bd01e7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/commit/da9f7d8a0e98b475600177348d6ece384a370f36"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/go-git/go-git"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/releases/tag/v5.19.2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/releases/tag/v6.0.0-alpha.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-07T16:41:51Z",
    "nvd_published_at" : null
  }
}