GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data section

Abierto Apto para principiantes
#2,498 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@pranayr710 ya está trabajando en esto.

Desde el 24/11/2026.

  • #2499 de @pranayr710 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c
Área
backend, security

Línea de trabajo

El desbordamiento está en parse_ad_cdp() en src/lib_ccx/ccx_gxf.c, en la sección de datos cc 0x72, donde el bucle copia cc_count * 3 bytes sin comprobar los bytes restantes en cdp. Lee ccdp_find_data() en src/lib_ccx/mp4.c para la comprobación de límites que hay que replicar. Hecho significa que el paquete se rechaza cuando cc_count * 3 supera la longitud restante, y el archivo de reproducción de ASan ya no falla mientras los CDP bien formados siguen parseándose.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

parse_ad_cdp() in src/lib_ccx/ccx_gxf.c reads a cc_count value straight from a GXF Caption Distribution Packet and then copies cc_count * 3 bytes out of the CDP buffer without checking that those bytes are actually inside the buffer. A crafted GXF file triggers a heap-buffer-overflow (read, and a copy into data->buffer).

Root cause

In the 0x72 (cc data) section handler:

cc_count = *cdp++ & 0x1f;              /* 0..31, straight from the file   */
debug("cc_count: %d\n", cc_count);

for (int i = 0; i < cc_count * 3; i++) /* up to 93 bytes                  */
{
    data->buffer[data->len + i] = cdp[i];   /* <-- reads past end of cdp  */
}
data->len += cc_count * 3;
cdp += cc_count * 3;

The only length check in the function is cdp_length == len on the whole packet (and len >= 11). Nothing ties cc_count * 3 to the number of bytes actually remaining in cdp. With a minimal CDP (len == 11) and cc_count == 0x1f, the loop reads cdp[0..92] from an ~12-byte heap buffer — ~80 bytes past the end.

Interestingly, the sibling CDP parser for MP4 already does this correctly — ccdp_find_data() in src/lib_ccx/mp4.c validates both the discrete cc_count values and that cc_count * 3 <= len before returning. The GXF path simply never got that guard.

Call path
ccx_gxf_get_more_data -> read_packet -> parse_media (ancillary)
  -> parse_ad_packet -> parse_ad_field -> parse_ad_pyld -> parse_ad_cdp

Every byte on that path, including cc_count, is attacker-controlled file content.

AddressSanitizer output
==8==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000527c ...
    #0 ... in parse_ad_cdp ../src/lib_ccx/ccx_gxf.c:562
SUMMARY: AddressSanitizer: heap-buffer-overflow ../src/lib_ccx/ccx_gxf.c:562 in parse_ad_cdp
Reproduction

A 340-byte GXF file reaches the vulnerable branch. Minimal generator:

# (attached in the PR) builds a MAP packet that registers an ancillary
# track, then a MEDIA ancillary packet whose CDP has a 0x72 section with
# cc_count = 0x1f but only an 11-byte CDP buffer.
ccextractor gxf_ccount.gxf -o out.srt

Built with -fsanitize=address this crashes in parse_ad_cdp. A well-formed CDP (cc_count in {10,20,25,30} with the bytes present) is processed normally and is not affected.

Affected code

src/lib_ccx/ccx_gxf.c, current master (the GXF demuxer is live C — not shadowed by the Rust port).

Fix

Reject the packet when cc_count * 3 exceeds the bytes remaining in the CDP buffer, mirroring the existing mp4.c check. PR follows.


Found while auditing the length/count handling in the container demuxers. Analysis and the ASan reproduction were done with AI assistance; the report and fix were reviewed by me.

Lenguaje dominante
C
Estrellas
919
Forks
604
Merge medio
9 d 5 h
PR fusionados (30 d)
26

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CCExtractor/ccextractor

Todos los issues de CCExtractor/ccextractor

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.