# CVE-2024-24577: libgit2 is vulnerable to arbitrary code execution due to heap corruption in `git_index_add`

> Attackers can achieve arbitrary code execution via heap corruption in libgit2's git_index_add function using crafted inputs.

- **Severity:** High 8.6 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Feb 2024
- **Updated:** 15 May 2025
- **Also known as:** AZL-34274, BELL-CVE-2024-24577, CLEANSTART-2024-DS47827, DEBIAN-CVE-2024-24577, DLA-3742-1, DSA-5619-1, GHSA-j2v7-4f6v-gpg8, JLSEC-2025-186, OESA-2024-1188, OESA-2024-1201, OESA-2024-1204, OESA-2024-1205, OESA-2024-1206, SUSE-SU-2024:2579-1, SUSE-SU-2024:2583-1, SUSE-SU-2024:2592-1, SUSE-SU-2024:2598-1, SUSE-SU-2024:2599-1, SUSE-SU-2024:2610-1, SUSE-SU-2024:2619-1, SUSE-SU-2024:2656-1, UBUNTU-CVE-2024-24577, openSUSE-SU-2024:14212-1

## What is CVE-2024-24577?

CVE-2024-24577 is a high-severity memory corruption vulnerability in libgit2, published on 6 Feb 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

libgit2 is a portable C implementation of the Git core methods provided as a linkable library with a solid API, allowing to build Git functionality into your application. Using well-crafted inputs to `git_index_add` can cause heap corruption that could be leveraged for arbitrary code execution. There is an issue in the `has_dir_name` function in `src/libgit2/index.c`, which frees an entry that should not be freed. The freed entry is later used and overwritten with potentially bad actor-controlled data leading to controlled heap corruption. Depending on the application that uses libgit2, this could lead to arbitrary code execution. This issue has been patched in version 1.6.5 and 1.7.2.

Weakness: CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer), CWE-122 (Heap-based Buffer Overflow)

## Which versions are affected by CVE-2024-24577?

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `git` | SUSE:Enterprise Storage 7.1 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Enterprise Storage 7.1 | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 2.26.2-150000.59.1 |
| `libgit2` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 0.26.8-150000.3.21.1 |
| `libgit2` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 1.3.0-150400.3.9.1 |
| `git` | SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 1.3.0-150400.3.9.1 |
| `git` | SUSE:Linux Enterprise Micro 5.5 | All versions | 2.35.3-150300.10.42.1 |
| `git` | SUSE:Linux Enterprise Module for Basesystem 15 SP5 | All versions | 2.35.3-150300.10.42.1 |
| `git` | SUSE:Linux Enterprise Module for Basesystem 15 SP6 | All versions | 2.43.0-150600.3.6.1 |
| `git` | SUSE:Linux Enterprise Module for Development Tools 15 SP5 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise Module for Development Tools 15 SP5 | All versions | 1.3.0-150400.3.9.1 |
| `git` | SUSE:Linux Enterprise Module for Development Tools 15 SP6 | All versions | 2.43.0-150600.3.6.1 |
| `git` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 2.26.2-27.75.1 |
| `git` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 2.26.2-150000.59.1 |
| `libgit2` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 0.26.8-150000.3.21.1 |
| `libgit2` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise Server 15 SP4-LTSS | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise Server 15 SP4-LTSS | All versions | 1.3.0-150400.3.9.1 |
| `git` | SUSE:Linux Enterprise Server for SAP Applications 12 SP5 | All versions | 2.26.2-27.75.1 |
| `git` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 2.26.2-150000.59.1 |
| `libgit2` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 0.26.8-150000.3.21.1 |
| `libgit2` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 0.28.4-150200.3.9.1 |
| `git` | SUSE:Linux Enterprise Server for SAP Applications 15 SP4 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Linux Enterprise Server for SAP Applications 15 SP4 | All versions | 1.3.0-150400.3.9.1 |
| `git` | SUSE:Linux Enterprise Software Development Kit 12 SP5 | All versions | 2.26.2-27.75.1 |
| `libgit2` | SUSE:Linux Enterprise Software Development Kit 12 SP5 | All versions | 0.24.1-11.5.1 |
| `git` | SUSE:Manager Proxy 4.3 | All versions | 2.35.3-150300.10.42.1 |
| `git` | SUSE:Manager Server 4.3 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | SUSE:Manager Server Module 4.3 | All versions | 0.28.4-150200.3.9.1 |
| `git` | openSUSE:Leap 15.5 | All versions | 2.35.3-150300.10.42.1 |
| `libgit2` | openSUSE:Leap 15.5 | All versions | 1.3.0-150400.3.9.1 |

Products: Libgit2 Libgit2.

## How do I fix CVE-2024-24577?

Upgrade to a fixed version.

## Is CVE-2024-24577 being exploited?

There is no known exploitation of CVE-2024-24577 in the wild and no public exploit code.

## Other vulnerabilities in libgit2

- [CVE-2024-24575](https://insights.sbomify.com/CVE-2024-24575/): libgit2 is vulnerable to a denial of service attack in `git_revparse_single` (high 7.5)
- [CVE-2023-22742](https://insights.sbomify.com/CVE-2023-22742/): libgit2 fails to verify SSH keys by default (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-24577 and fix it if it is affected.

What it is: CVE-2024-24577 is a high-severity memory corruption vulnerability in libgit2, published on 6 Feb 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-24577 in the wild and no public exploit code.

Affected product: libgit2. No package-level version data is available, so check the vendor advisory linked from the reference page.

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/CVE-2024-24577/ (Markdown: https://insights.sbomify.com/CVE-2024-24577/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-24577
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-24577
- OSV: https://osv.dev/vulnerability/CVE-2024-24577

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-24577/
Summaries are generated and may contain mistakes; the official description above is the record.
