libgit2-sys affected by memory corruption, denial of service, and arbitrary code execution in libgit2GHSA-22q8-ghmq-63vf
HIGHFix: rust-lang/git2-rs#1017GHSA-22q8-ghmq-63vf is a high-severity (CVSS 8.6) remote code execution vulnerability in libgit2-sys. A fix is available for libgit2-sys — see the affected versions and patch details below.
Real-World Exposure
libgit2-sysReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects crates.io packages — download data is not available via public APIs for these ecosystems.
Description
The libgit2 project fixed three security issues in the 1.7.2 release. These issues are:
- The
git_revparse_singlefunction can potentially enter an infinite loop on a well-crafted input, potentially causing a Denial of Service. This function is exposed in thegit2crate via theRepository::revparse_singlemethod. - The
git_index_addfunction may cause heap corruption and possibly lead to arbitrary code execution. This function is exposed in thegit2crate via theIndex::addmethod. - The smart transport negotiation may experience an out-of-bounds read when a remote server did not advertise capabilities.
The libgit2-sys crate bundles libgit2, or optionally links to a system libgit2 library. In either case, versions of the libgit2 library less than 1.7.2 are vulnerable. The 0.16.2 release of libgit2-sys bundles the fixed version of 1.7.2, and requires a system libgit2 version of at least 1.7.2.
It is recommended that all users upgrade.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🦀crates.io | libgit2-sys | all versions | 0.16.2cargo update -p libgit2-sys --precise 0.16.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for libgit2-sys, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update libgit2-sys to 0.16.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-22q8-ghmq-63vf is resolved across your whole dependency graph.
Workarounds
Stop feeding it untrusted input: reject or quarantine files and payloads from unverified sources until you can upgrade, restrict accepted formats to the ones you actually need, and run the parsing or decoding step in a least-privileged sandbox or short-lived worker so a crash or corrupted read cannot reach the rest of the process.
Frequently Asked Questions
Is GHSA-22q8-ghmq-63vf in your dependencies?
Find it across crates.io, including transitive dependencies.