GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data section
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
The overflow is in parse_ad_cdp() in src/lib_ccx/ccx_gxf.c, in the 0x72 cc data section, where the loop copies cc_count * 3 bytes without checking the bytes remaining in cdp. Read ccdp_find_data() in src/lib_ccx/mp4.c for the bounds check to mirror. Done means the packet is rejected when cc_count * 3 exceeds the remaining length, and the ASan reproduction file no longer crashes while well-formed CDPs still parse.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C
- Stars
- 919
- Forks
- 604
- Avg merge
- 9d 5h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CCExtractor/ccextractor
-
[BUG] + file-sequence expansion picks the digit in the extension (clip001.mp4+ only processes clip001.mp4)Possibly taken @imfarhan0105-bits claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2478 · 2 comments ·
Maintainers usually reply within 1 day
-
[BUG] encoders: WebVTT encoder generates invalid ## delimiter and malformed @import violating W3C specificationPossibly taken @yasar710 claimed this 7 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
CCExtractor/ccextractor#2465 · 2 comments ·
Maintainers usually reply within 1 day
-
GXF: heap buffer overflow in parse_mpeg_packet() — oversized mpeg_pic_size overflows the demuxer bufferPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
CCExtractor/ccextractor#2500 ·
Maintainers usually reply within 1 day
-
[BUG] DVB: map-table cases in dvbsub_parse_pixel_data_block read past the object field dataPossibly taken @pranayr710 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
CCExtractor/ccextractor#2482 ·
Maintainers usually reply within 1 day
-
[BUG] read_exp_golomb_unsigned panics/aborts on 64 or more leading zero bits (malformed SPS)Possibly taken @Souravrajvi0 claimed this 5 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
CCExtractor/ccextractor#2470 · 2 comments ·
Maintainers usually reply within 1 day
All issues in CCExtractor/ccextractor
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: services kind: bug preview-effort: small priority: low
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Static Analysis failurePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100