# GHSA-j39j-6gw9-jw6h: git2 has potential undefined behavior when dereferencing Buf struct

- Severity: Low (CVSS:4.0, scored by GitHub) `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2026-02-02T12:00:00.000Z
- Modified: 2026-09-10T03:50:35.308Z
- Also known as: RUSTSEC-2026-0008
- Weaknesses: CWE-476

## Description

If the Buf struct is dereferenced immediately after calling new() or default() on the Buf struct, a null pointer is passed to the unsafe function slice::from_raw_parts. According to the safety section documentation of the function, data must be non-null and aligned even for zero-length slices or slices of ZSTs. Thus, passing a null pointer will lead to undefined behavior.

(As written by GitHub Advisory Database.)

## Affected

- git2 (crates.io): before 0.20.4; from 0.0.0-0 before 0.20.4

## References

- <https://github.com/rust-lang/git2-rs/issues/1211> (web)
- <https://github.com/rust-lang/git2-rs/pull/1213> (web)
- <https://github.com/rust-lang/git2-rs/commit/9e160f15bd056f82143109bb330573381e5de719> (web)
- <https://github.com/rust-lang/git2-rs> (package)
- <https://rustsec.org/advisories/RUSTSEC-2026-0008.html> (advisory, web)
- <https://crates.io/crates/git2> (package)

## Sources

- GitHub Advisory Database: [GHSA-j39j-6gw9-jw6h](https://github.com/advisories/GHSA-j39j-6gw9-jw6h), CC-BY-4.0, modified 2026-09-10
- RustSec Advisory Database: [RUSTSEC-2026-0008](https://rustsec.org/advisories/RUSTSEC-2026-0008.html), CC0-1.0, modified 2026-02-05

---

Page: https://cve.day/GHSA-j39j-6gw9-jw6h · Whole record: https://cve.day/GHSA-j39j-6gw9-jw6h.json · Rebuilt by cve.day 2026-11-25T22:56:43.301Z
