GXF: heap buffer overflow in parse_mpeg_packet() — oversized mpeg_pic_size overflows the demuxer buffer

オープン
#2,500 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@pranayr710 がすでに取り組んでいます。

2026年11月24日 から。

  • #2501 @pranayr710 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c
領域
security

調査の方向性

Start in src/lib_ccx/ccx_gxf.c: read parse_media() where mpeg_pic_size is decoded, then parse_mpeg_packet() where that length reaches buffered_read(). Compare it with the ancillary branch's existing packet_size guard and with alloc_demuxer_data()/BUFSIZE in ccx_demuxer.c. Done means an oversized MPEG2 packet is skipped safely and the ASan reproduction no longer reports a heap-buffer-overflow.

索引モデルが issue の本文から書いたものです。

説明

Summary

parse_mpeg_packet() in src/lib_ccx/ccx_gxf.c reads mpeg_pic_size bytes from the file into the fixed-size demuxer buffer without ever checking that they fit. A GXF media packet that declares an oversized mpeg_pic_size overflows data->buffer (heap-buffer-overflow, write).

Root cause
static int parse_mpeg_packet(struct ccx_demuxer *demux, int len, struct demuxer_data *data)
{
    ...
    result = buffered_read(demux, data->buffer + data->len, len);  /* <-- */
    data->len += len;
    ...
}

len is mpeg_pic_size, taken straight from the media packet header in parse_media():

mpeg_pic_size = buffered_get_be32(demux);
mpeg_frame_desc_flag = mpeg_pic_size >> 24;
mpeg_pic_size &= 0xFFFFFF;          /* up to 16 MB, attacker controlled */
...
parse_mpeg_packet(demux, mpeg_pic_size, data);

data->buffer is a fixed malloc(BUFSIZE) (≈2 MB, alloc_demuxer_data() in ccx_demuxer.c). Nothing bounds mpeg_pic_size against it — the ancillary branch right above at least checks len < ad_track->packet_size, but the MPEG2 branch has no equivalent guard — so buffered_read writes up to ~16 MB into the 2 MB buffer.

Call path
ccx_gxf_get_more_data -> read_packet -> parse_media (TRACK_TYPE_MPEG2_525)
  -> parse_mpeg_packet
AddressSanitizer output
==8==ERROR: AddressSanitizer: heap-buffer-overflow ...
    #1 ... in buffered_read_opt ../src/lib_ccx/file_functions.c:376
    #2 ... in buffered_read ../src/lib_ccx/file_buffer.h:72
    #3 ... in parse_mpeg_packet ../src/lib_ccx/ccx_gxf.c:930
SUMMARY: AddressSanitizer: heap-buffer-overflow ... in __interceptor_read
Reproduction

A ~2 MB GXF file: a MAP packet that registers an MPEG2_525 video track (and no ancillary track), then a MEDIA packet whose mpeg_pic_size is set just over BUFSIZE with that many payload bytes following. Generator is attached to the PR.

Affected code

src/lib_ccx/ccx_gxf.c, current master (GXF demuxer is live C, not shadowed by the Rust port). Distinct from #2498 (which is the CDP cc_count read in the same file).

Fix

Skip the packet when data->len + len would exceed BUFSIZE, instead of reading it in. PR follows.


Found while auditing length handling in the GXF demuxer. Analysis and the ASan reproduction were done with AI assistance; the report and fix were reviewed by me.

主要言語
C
スター
919
フォーク
604
平均マージ
9日 5時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CCExtractor/ccextractor のほかの issue

CCExtractor/ccextractor の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。