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

> A null pointer dereference in the git2 Rust library can cause undefined behavior and potential crashes when using the Buf struct.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 2 Feb 2026
- **Also known as:** RUSTSEC-2026-0008

## What is GHSA-j39j-6gw9-jw6h?

GHSA-j39j-6gw9-jw6h is a vulnerability in git2, published on 2 Feb 2026. 

### Official 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.

## Which versions are affected by GHSA-j39j-6gw9-jw6h?

3 open source packages ship an affected version, including git2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `git2` | crates.io | All versions | 0.20.4 |
| `git2` | crates.io | All versions | 0.20.4 |
| `git2` | crates.io | From 0.0.0-0 | 0.20.4 |

## How do I fix GHSA-j39j-6gw9-jw6h?

Upgrade git2 to 0.20.4 or later.

## Is GHSA-j39j-6gw9-jw6h being exploited?

There is no known exploitation of GHSA-j39j-6gw9-jw6h in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-j39j-6gw9-jw6h and fix it if it is affected.

What it is: GHSA-j39j-6gw9-jw6h is a vulnerability in git2, published on 2 Feb 2026. 
Exploitation: There is no known exploitation of GHSA-j39j-6gw9-jw6h in the wild and no public exploit code.

Affected packages and fixed versions:
- git2 (crates.io): affected all versions; fixed in 0.20.4
- git2 (crates.io): affected all versions; fixed in 0.20.4
- git2 (crates.io): affected from 0.0.0-0; fixed in 0.20.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-j39j-6gw9-jw6h/ (Markdown: https://insights.sbomify.com/GHSA-j39j-6gw9-jw6h/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-j39j-6gw9-jw6h

---
From sbomify Insights: https://insights.sbomify.com/GHSA-j39j-6gw9-jw6h/
Summaries are generated and may contain mistakes; the official description above is the record.
