GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data section
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 62/100
調査の方向性
オーバーフローは src/lib_ccx/ccx_gxf.c の parse_ad_cdp() 内、0x72 の cc データセクションにあり、ループが cdp 内の残りバイト数を確認せずに cc_count * 3 バイトをコピーしています。踏襲すべき境界チェックについては src/lib_ccx/mp4.c の ccdp_find_data() を読んでください。完了とは、cc_count * 3 が残りの長さを超えた場合にパケットが拒否され、ASan の再現ファイルがクラッシュしなくなり、かつ整形された CDP は引き続きパースされることです。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C
- スター
- 919
- フォーク
- 604
- 平均マージ
- 9日 5時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CCExtractor/ccextractor のほかの issue
-
[BUG] + file-sequence expansion picks the digit in the extension (clip001.mp4+ only processes clip001.mp4)対応中かも @imfarhan0105-bits が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
CCExtractor/ccextractor#2478 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] encoders: WebVTT encoder generates invalid ## delimiter and malformed @import violating W3C specification対応中かも @yasar710 が 7 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
CCExtractor/ccextractor#2465 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
GXF: heap buffer overflow in parse_mpeg_packet() — oversized mpeg_pic_size overflows the demuxer buffer対応中かも @pranayr710 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
CCExtractor/ccextractor#2500 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] DVB: map-table cases in dvbsub_parse_pixel_data_block read past the object field data対応中かも @pranayr710 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 30/100
CCExtractor/ccextractor#2482 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] read_exp_golomb_unsigned panics/aborts on 64 or more leading zero bits (malformed SPS)対応中かも @Souravrajvi0 が 5 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
CCExtractor/ccextractor#2470 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
CCExtractor/ccextractor の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: services kind: bug preview-effort: small priority: low
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Static Analysis failure対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100