GHSA-j39j-6gw9-jw6h: Git2 Git2 Has Potential Undefined Behavior Vulnerability

LOW
CWE-476
Published
Advisory Summary

GHSA-j39j-6gw9-jw6h is a LOW git2 has potential undefined behavior vulnerability (CWE-476: NULL Pointer Dereference) affecting Git2 libraries in the crates.io ecosystem. The issue involves git2 has potential undefined behavior when dereferencing buf struct. Remediation is available by upgrading affected packages to version 0.20.4.

GHSA-j39j-6gw9-jw6h at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-j39j-6gw9-jw6h
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-476: NULL Pointer Dereference
Affected Product Git2
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix GHSA-j39j-6gw9-jw6h

To remediate this vulnerability, upgrade all affected Git2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

git2 fixed: 0.20.4
Upgrade git2 to 0.20.4
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 git2

How to Check if You Are Affected

To determine whether your application is affected by GHSA-j39j-6gw9-jw6h, inspect your project dependencies for Git2:

inspect dependencies for git2

Analyze the terminal output to locate any version of Git2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.20.4), 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-476: NULL Pointer Dereference, where the product dereferences a pointer that it expects to be valid but is null. In Git2, 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

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.

GHSA-j39j-6gw9-jw6h Affected Git2 Versions

1 component(s)
Fixed Versions:
0.20.4
Product / Package Ecosystem Affected Versions Fixed Version
git2
crates.io
< 0.20.4
0.20.4

References

Frequently Asked Questions

What is GHSA-j39j-6gw9-jw6h?
GHSA-j39j-6gw9-jw6h is a security vulnerability in Git2 involving git2 has potential undefined behavior when dereferencing Buf struct under CWE-476: NULL Pointer Dereference.
Which Git2 versions are affected?
Affected versions include releases prior to 0.20.4 across affected packages: git2.
What version fixes GHSA-j39j-6gw9-jw6h?
Upgrading to 0.20.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is git2 affected?
Yes, git2 is affected in releases prior to 0.20.4. Upgrade your dependency to 0.20.4 or later.
What CWE is associated with GHSA-j39j-6gw9-jw6h?
GHSA-j39j-6gw9-jw6h is classified under CWE-476: NULL Pointer Dereference (The product dereferences a pointer that it expects to be valid but is NULL.).
How can I check crates.io dependencies for GHSA-j39j-6gw9-jw6h?
Run the dependency tree command: 'inspect dependencies for git2'. 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-j39j-6gw9-jw6h",
  "modified" : "2026-02-04T20:36:04Z",
  "published" : "2026-02-04T20:36:04Z",
  "aliases" : [ ],
  "summary" : "git2 has potential undefined behavior when dereferencing Buf struct ",
  "details" : "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.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "git2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.20.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/git2-rs/issues/1211"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/git2-rs/pull/1213"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rust-lang/git2-rs/commit/9e160f15bd056f82143109bb330573381e5de719"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rust-lang/git2-rs"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2026-0008.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-476" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-04T20:36:04Z",
    "nvd_published_at" : null
  }
}