GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data section
维护者通常 1 天内回复
评估
调研方向
溢出位于 src/lib_ccx/ccx_gxf.c 中的 parse_ad_cdp(),在 0x72 的 cc 数据段中,循环复制 cc_count * 3 个字节时没有检查 cdp 中剩余的字节数。阅读 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 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100