/

CVE-2026-53587

Severity:

HIGH RISK

(7.5)

Out-of-Bounds Read (CWE-125) in libgit2 Smart Protocol

CVE-2026-53587

Awaiting Analysis

Vulnerability type

Category:

Out-of-Bounds Read

CWE:

CWE-20, CWE-125, CWE-126, CWE-1284

Impact:

Client-Side Denial of Service

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A bounds-validation flaw in libgit2 can cause a Git client to read beyond the end of a smart-protocol packet while processing a server's refs advertisement. A malicious Git server may exploit this condition to crash clients that connect over HTTP, HTTPS, SSH, or the Git protocol.

Affected context

The vulnerability occurs in libgit2 clients that process smart-protocol pkt-line capability data from an untrusted Git server. It becomes risky when the capability buffer is shorter than the parser assumes and packet-boundary checks are not performed before fixed-size comparisons and subsequent length calculations.

Exploit preconditions

  • Attack surface: Git transport protocol handling in applications linked

against libgit2

  • Required access: Ability to operate or control a Git server that the

target client contacts

  • Trigger point: Processing the first refs-advertisement packet - Why exploitation is possible: A malformed capability field can cause a

fixed-size comparison to read past the packet, followed by an underflowed

length calculation and an out-of-bounds heap walk

Why this happens

The parser performs a fixed-size string comparison without first confirming that the pkt-line contains enough bytes for that operation. When a server-provided capability value is truncated or positioned at a packet boundary, pointer advancement can move beyond the valid buffer. A later length calculation may underflow, allowing a memory-search operation to traverse outside the allocated object. This behavior maps primarily to CWE-125, Out-of-Bounds Read, and is also related to improper input validation and incorrect buffer-length handling.

Potential impact

  • A malicious server may crash a connected Git client
  • Applications could experience denial of service during repository access
  • Repeated connections could cause service instability
  • Memory-safety failures could expose additional risk if combined with other bugs

General mitigation guidance

Mitigation generally focuses on ensuring every parser operation is bounded by the actual pkt-line length. Defensive patterns include validating packet sizes before fixed-width comparisons, using overflow- and underflow-safe length arithmetic, rejecting malformed capability advertisements, and centralizing checked buffer-access helpers. Applications should use maintained libgit2 releases that contain the parser correction, reduce trust in remote protocol data, and run Git operations with least privilege and suitable process isolation where practical.

How teams detect issues like this

Detection can include static analysis for fixed-size reads that lack prior length checks, arithmetic on attacker-controlled buffer lengths, and memchr-like calls whose bounds derive from unchecked subtraction. Code review should examine packet-parser state transitions, pointer advancement, and integer overflow or underflow handling. Fuzzing smart-protocol refs-advertisement packets and enforcing memory-safety testing in CI can help identify malformed-input crashes. Automated security review tools may also flag unchecked buffer boundaries and suspicious length calculations.

Sources

SourceLink
github.comgithub.com/libgit2/libgit2/commit/2c0ce8c0132ac38ab0db28239462a671e2e5440e
github.comgithub.com/libgit2/libgit2/commit/affda60c10fcef16723451c0d7dc71b71dc20ad3
github.comgithub.com/libgit2/libgit2/commit/d7a9fb87f504434e9f45228678953c4fa56e7640
github.comgithub.com/libgit2/libgit2/releases/tag/v1.8.6
github.comgithub.com/libgit2/libgit2/releases/tag/v1.9.5
github.comgithub.com/libgit2/libgit2/security/advisories/GHSA-pm24-4jhq-3xvm

Frequently asked

questions

Yes, in the relevant usage scenario, a malicious Git server can provide a

malformed refs-advertisement packet to a client. Exploitation requires the

client to connect to that server using a supported Git transport.

The attacker generally needs control of, or the ability to impersonate or

redirect the client to, a Git server that the application contacts. Local

access to the client is not inherently required.

Use a maintained libgit2 release containing the parser fix and ensure packet

parsers validate available lengths before every read, pointer advance, and

length calculation.

Combine strict protocol validation, overflow-safe arithmetic, fuzz testing

with malformed packets, memory-safety checks, and least-privilege execution

for applications that process untrusted Git repositories.

Find out what's already
exploitable in your codebase.