CVE-2026-45571: go-git Crafted Repositories May Modify Main Vulnerability

MODERATE
Advisory Identifier: GHSA-crhj-59gh-8x96
CVSS 5.4
CWE-22
Published
Advisory Summary

CVE-2026-45571 is a MODERATE (CVSS 5.4) crafted repositories may modify main 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 crafted repositories may modify main and submodule .git directories. Remediation is available by upgrading affected packages to version 5.19.1, 6.0.0-alpha.4.

CVE-2026-45571 at a Glance

CVE Identifier CVE-2026-45571
GHSA Identifier GHSA-crhj-59gh-8x96
Severity MODERATE
CVSS v3.1 Base Score 5.4
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: 5.4

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

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

How to Fix CVE-2026-45571

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.1
Upgrade github.com/go-git/go-git/v5 to 5.19.1
github.com/go-git/go-git/v6 fixed: 6.0.0-alpha.4
Upgrade github.com/go-git/go-git/v6 to 6.0.0-alpha.4
github.com/go-git/go-git fixed: Latest secure release
Upgrade github.com/go-git/go-git to Latest secure release
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-45571, 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.1), 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 validation issue in `go-git` could allow crafted repository data to affect files outside the intended checkout target, including the repository's `.git` directory. These validations were introduced in upstream Git years ago, so the vulnerability arose from go-git drifting from those checks. Some attack vectors were platform-specific: certain payloads affected only Windows users, others affected only macOS users, and some applied across all supported platforms. Using non-descendant `go-billy` filesystem instances, or different filesystem types, for the `Storer` and `Worktree` may provide some isolation against `.git` directory manipulation. For example, users that store the `.git` directory through `memfs` while using `osfs` for the worktree are not affected by this vulnerability in the main repository, because repository metadata is not materialized inside the worktree filesystem. However, this isolation does not necessarily apply when the repository contains submodules, since submodule dotgit directories may still be represented or materialized within the worktree context. It is important to note that exploitation requires a maliciously crafted repository payload. Users should always exercise caution when interacting with repositories or Git servers they do not trust. ### Patches Users should upgrade to a patched version in order to mitigate this vulnerability. Versions prior to `v5` are likely to be affected, users are recommended to upgrade to a supported go-git version. ### Credits Thanks to @kodareef5, @AyushParkara and @N0zoM1z0 for reporting this to the go-git project in three separate reports. 🙇

CVE-2026-45571 Affected go-git Versions

3 component(s)
Fixed Versions:
5.19.16.0.0-alpha.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/go-git/go-git/v5
Go
< 5.19.1
5.19.1
github.com/go-git/go-git/v6
Go
< 6.0.0-alpha.4
6.0.0-alpha.4
github.com/go-git/go-git
Go
≤ 44.7.0

References

Frequently Asked Questions

What is CVE-2026-45571?
CVE-2026-45571 is a security vulnerability in go-git involving Crafted repositories may modify main and submodule .git directories 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.1, 6.0.0-alpha.4 across affected packages: github.com/go-git/go-git/v5, github.com/go-git/go-git/v6, github.com/go-git/go-git.
What version fixes CVE-2026-45571?
Upgrading to 5.19.1, 6.0.0-alpha.4 (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.1. Upgrade your dependency to 5.19.1 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.4. Upgrade your dependency to 6.0.0-alpha.4 or later.
What is the CVSS score of CVE-2026-45571?
CVE-2026-45571 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2026-45571?
CVE-2026-45571 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-45571?
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-crhj-59gh-8x96",
  "modified" : "2026-06-08T23:43:04Z",
  "published" : "2026-05-19T15:38:39Z",
  "aliases" : [ "CVE-2026-45571" ],
  "summary" : "go-git: Crafted repositories may modify main and submodule .git directories",
  "details" : "### Impact\nA path validation issue in `go-git` could allow crafted repository data to affect files outside the intended checkout target, including the repository's `.git` directory.\n\nThese validations were introduced in upstream Git years ago, so the vulnerability arose from go-git drifting from those checks. Some attack vectors were platform-specific: certain payloads affected only Windows users, others affected only macOS users, and some applied across all supported platforms.\n\nUsing non-descendant `go-billy` filesystem instances, or different filesystem types, for the `Storer` and `Worktree` may provide some isolation against `.git` directory manipulation. For example, users that store the `.git` directory through `memfs` while using `osfs` for the worktree are not affected by this vulnerability in the main repository, because repository metadata is not materialized inside the worktree filesystem.\n\nHowever, this isolation does not necessarily apply when the repository contains submodules, since submodule dotgit directories may still be represented or materialized within the worktree context.\n\nIt is important to note that exploitation requires a maliciously crafted repository payload. Users should always exercise caution when interacting with repositories or Git servers they do not trust.\n\n### Patches\nUsers should upgrade to a patched version in order to mitigate this vulnerability. Versions prior to `v5` are likely to be affected, users are recommended to upgrade to a supported go-git version.\n\n### Credits\nThanks to @kodareef5, @AyushParkara and @N0zoM1z0 for reporting this to the go-git project in three separate reports. 🙇",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/go-git/go-git/v5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.19.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.19.0"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/go-git/go-git/v6"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.0.0-alpha.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.0.0-alpha.3"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/go-git/go-git"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "44.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/go-git/go-git/security/advisories/GHSA-crhj-59gh-8x96"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-45571"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/go-git/go-git"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-19T15:38:39Z",
    "nvd_published_at" : "2026-05-27T15:16:30Z"
  }
}