CVE-2026-71557: go-git: Malicious reference names may modify files outside the reference storage
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. 🙇
Other sources
go-git is an extensible git implementation library written in pure Go. Prior to 5.19.2 and 6.0.0-alpha.5, reference names are not sanitized before being used to construct on-disk paths under the reference storage directory, so a maliciously crafted reference name (for example containing directory-traversal sequences) can cause go-git to write files outside the intended reference storage directory. Versions 5.19.2 and 6.0.0-alpha.5 fix the issue.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/go-git/go-git/v6to a version that resolves this vulnerability.Fixed in 6.0.0-alpha.5 - Upgrade
Upgrade
go/github.com/go-git/go-git/v5to a version that resolves this vulnerability.Fixed in 5.19.2 - Upgrade
Upgrade
go-gitto a version that resolves this vulnerability.Fixed in 5.19.2 - Upgrade
Upgrade
go-gitto a version that resolves this vulnerability.Fixed in 6.0.0-alpha.5 - Compensating control
For applications using filesystem-backed storage (go-git `storage/filesystem` with `dotgit` reference storage), avoid cloning from or fetching from untrusted Git servers until an upgrade is possible.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-71557?
The severity of CVE-2026-71557 is medium with a score of 6.3.
How do I fix CVE-2026-71557?
To fix CVE-2026-71557, update to go-git version 5.19.2 or 6.0.0-alpha.5 or newer.
What type of vulnerability is CVE-2026-71557?
CVE-2026-71557 is a path traversal vulnerability that allows malicious reference names to alter files outside the intended reference storage.
What can an attacker achieve with CVE-2026-71557?
An attacker can potentially modify files on the disk by using a crafted reference name that exploits the path traversal flaw.
In which software is CVE-2026-71557 found?
CVE-2026-71557 is found in the go-git software, which is a Go library for Git implementations.