Skip to content
Heist/ feed
Back to feed
High

libgit2 is vulnerable to arbitrary code execution due to heap corruption in `git_index_add`

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2024-24577
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 03:05 UTC · Revision 1

Source evidence

libgit2 is vulnerable to arbitrary code execution due to heap corruption in `git_index_add`

core-osv · Original source

Published 6 Feb 2024, 21:36 UTC

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.

osv:CVE-2024-24577
Complete source record
{
  "id": "0ca33ae0abc8860a179e11cfc6bc5daada6d4c5103fc046b1f445c874a996bc1",
  "url": "https://osv.dev/vulnerability/CVE-2024-24577",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "libgit2 is vulnerable to arbitrary code execution due to heap corruption in `git_index_add`",
    "summary": "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.",
    "evidence": "osv:CVE-2024-24577",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2024-24577",
      "aliases": [
        "CVE-2024-24577",
        "GHSA-j2v7-4f6v-gpg8"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/libgit2/libgit2",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "155578578b78efc6bae7383a708d470eb206e36a"
                },
                {
                  "introduced": "3e2baa6d0bfb42f9016e24cba1733a6ae26a8ae6"
                },
                {
                  "fixed": "a418d9d4ab87bae16b87d8f37143a4687ae0e4b2"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:libgit2:libgit2:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.6.5"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:libgit2:libgit2:*:*:*:*:*:*:*:*",
                    "range": [
                      {
                        "introduced": "1.7.0"
                      },
                      {
                        "fixed": "1.7.2"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "155578578b78efc6bae7383a708d470eb206e36a"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "v1.6.5"
                  },
                  {
                    "range": [
                      {
                        "fixed": "a418d9d4ab87bae16b87d8f37143a4687ae0e4b2"
                      }
                    ],
                    "source": "REFERENCES_TAG",
                    "original_tag": "v1.7.2"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v1.6.4",
            "v1.7.1",
            "v1.7.0",
            "v1.6.3",
            "v1.6.2",
            "v1.6.1",
            "v1.5.0",
            "v1.3.0",
            "v1.4.0",
            "v1.2.0",
            "v1.1.0",
            "v1.0.0",
            "v0.99.0",
            "v0.28.0-rc1",
            "v0.28.0",
            "v0.27.0",
            "v0.27.0-rc3",
            "v0.26.0-rc2",
            "v0.26.0",
            "v0.27.0-rc1",
            "v0.27.0-rc2",
            "v0.26.0-rc1",
            "v0.24.0",
            "v0.24.0-rc1",
            "v0.23.0",
            "v0.23.0-rc2",
            "v0.23.0-rc1",
            "v0.22.0",
            "v0.22.0-rc2",
            "v0.22.0-rc1",
            "v0.21.0",
            "v0.18.0",
            "v0.17.0",
            "v0.16.0",
            "v0.15.0",
            "v0.14.0",
            "v0.13.0",
            "v0.12.0",
            "v0.11.0",
            "v0.10.0",
            "v0.8.0",
            "v0.3.0",
            "v0.2.0",
            "v0.1.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-24577.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:32.832578349Z",
      "provider": "osv",
      "references": [
        "https://github.com/libgit2/libgit2/releases/tag/v1.6.5",
        "https://github.com/libgit2/libgit2/releases/tag/v1.7.2",
        "https://lists.debian.org/debian-lts-announce/2024/02/msg00012.html",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4M3P7WIEPXNRLBINQRJFXUSTNKBCHYC7/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7CNDW3PF6NHO7OXNM5GN6WSSGAMA7MZE/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/S635BGHHZUMRPI7QOXOJ45QHDD5FFZ3S/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/Z6MXOX7I43OWNN7R6M54XLG6U5RXY244/",
        "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZGNHOEE2RBLH7KCJUPUNYG4CDTW4HTBT/",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/24xxx/CVE-2024-24577.json",
        "https://github.com/libgit2/libgit2/security/advisories/GHSA-j2v7-4f6v-gpg8",
        "https://nvd.nist.gov/vuln/detail/CVE-2024-24577"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-122"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/24xxx/CVE-2024-24577.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-24577",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 499888,
  "published_at": "2024-02-06T21:36:12.517+00:00"
}