Descrizione

Affected versions of Git have a heap buffer overflow in the three-way merge code (xdiff), which an attacker can trigger through a repository they control. When Git merges a file, it first adds up the size of the merged output, allocates a buffer of that size, and then writes the output into it. That total was kept in a 32-bit signed integer. The conflict-marker-size attribute, which can be set from a committed .gitattributes file, accepts any positive integer, and the markers are written several times for every conflict. A small file with a huge marker size and many separate conflicts can therefore push the total past 4 GiB, so the integer wraps to a small value and Git writes attacker-controlled merge output past the end of a buffer that is too small. At minimum this crashes Git, and because the overflow is large and its contents are largely attacker-controlled, worse heap corruption is possible. Any command that does a textual three-way merge can trigger it, such as git-merge(1), git-rebase(1), git-cherry-pick(1), and git-merge-tree(1). The latter is most likely a target for Git forges, which might use git-merge-tree(1) on the server-side to check mergeability. When the server reads attributes from trees in the repository (for example through attr.tree or --attr-source), any user who can push branches and request that they be merged (for example by opening a pull or merge request) can trigger the overflow without anyone else doing anything, and the data they push is small because the oversized output only appears during the merge. The problem has been patched by computing the size as size_t and checking every addition for overflow, so Git stops with an error instead of overflowing. Servers that cannot upgrade right away can add * conflict-marker-size=7 to each repository's info/attributes as a workaround, which overrides any in-tree .gitattributes, or turn off server-side mergeability checks for untrusted repositories.

Testo originale del record CVE (in inglese).

Come correggere

Priorità: Media — correggere nel prossimo ciclo di patch. Motivazione: CVSS 7.5, EPSS 0.4% (percentile 35).

Versioni da aggiornare

  • Git Git: vulnerabili le versioni precedenti alla 2.49.1 → aggiornare alla 2.49.1 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.50.0-rc0 precedenti alla 2.50.2 → aggiornare alla 2.50.2 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.51.0-rc0 precedenti alla 2.51.3 → aggiornare alla 2.51.3 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.52.0-rc0 precedenti alla 2.52.1 → aggiornare alla 2.52.1 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.53.0-rc0 precedenti alla 2.53.1 → aggiornare alla 2.53.1 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.54.0-rc0 precedenti alla 2.54.1 → aggiornare alla 2.54.1 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.55.0-rc0 precedenti alla 2.55.1 → aggiornare alla 2.55.1 o successiva.
  • Git Git: vulnerabili le versioni dalla 2.56.0-rc0 precedenti alla 2.56.1 → aggiornare alla 2.56.1 o successiva.

Indicazioni del vendor

Soluzione (testo originale del vendor):

Upgrade to versions 2.50.2, 2.51.3, 2.52.1, 2.53.1, 2.54.1, 2.55.1, 2.56.1 or above.

Mitigazioni temporanee

Da applicare solo se non è possibile aggiornare subito:

  • Ridurre la superficie esposta (disattivare servizi e funzionalità inutilizzati), mantenere attive le protezioni del sistema operativo (ASLR, DEP/NX) e segmentare la rete.

Verifica

  1. Individuare tutti gli asset con il prodotto interessato (inventario, scanner di vulnerabilità, CMDB).
  2. Confrontare la versione installata con quelle indicate sopra.
  3. Applicare l'aggiornamento in un ambiente di test, poi in produzione; riavviare i servizi se richiesto.
  4. Ripetere la scansione per confermare la correzione.

Configurazioni interessate

VendorProdottoVersioni vulnerabiliCorretta in
Git Git < 2.49.1 2.49.1
Git Git ≥ 2.50.0-rc0 < 2.50.2 2.50.2
Git Git ≥ 2.51.0-rc0 < 2.51.3 2.51.3
Git Git ≥ 2.52.0-rc0 < 2.52.1 2.52.1
Git Git ≥ 2.53.0-rc0 < 2.53.1 2.53.1
Git Git ≥ 2.54.0-rc0 < 2.54.1 2.54.1
Git Git ≥ 2.55.0-rc0 < 2.55.1 2.55.1
Git Git ≥ 2.56.0-rc0 < 2.56.1 2.56.1

Riferimenti