GHSA-j39j-6gw9-jw6h
JSON

low

git2 has potential undefined behavior when dereferencing Buf struct

Severity
low CVSS:4.0 by GitHub
Published
Last changed
Also known as
RUSTSEC-2026-0008

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.

Affected

Product or packageVersionsReported by
git2 (crates.io)before 0.20.4, from 0.0.0-0 before 0.20.4GitHub Advisory Database, RustSec Advisory Database

Classification

What each source says

GitHub Advisory Database

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.

RustSec Advisory Database

if we dereference the Buf struct right after calling new() or default() on Buf struct, it passes Null Pointer to the unsafe function slice::from_raw_parts. Based on the safety section documentation of function, data must be non-null and aligned even for zero-length slices or slices of ZSTs. Thus, passing Null Pointer will lead to undefined behavior.

References

Sources

SourceRecordLicence
GitHub Advisory DatabaseGHSA-j39j-6gw9-jw6h changed 2026-09-10CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2026-0008 changed 2026-02-05CC0-1.0