mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-16 05:25:09 +00:00
Out-of-bounds read in H.264 SEI parsing on malformed input #882
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @THE-Amrit-mahto-05 on GitHub (Jan 2, 2026).
Description
While parsing H.264 SEI (Supplemental Enhancement Information) NAL units, CCExtractor can perform an out-of-bounds read when handling FF-extended payload_type and payload_size fields.
The issue occurs in sei_message() when the SEI message is truncated or malformed and contains a sequence of 0xFF bytes without a terminating byte.
Affected code
File: src/lib_ccx/avc_functions.c
Function:
Problematic logic:
and similarly for payload_size.
Root cause
The parsing loops dereference *seibuf without verifying that seibuf < seiend.
If the SEI NAL unit is truncated or padded with 0xFF bytes, the parser reads past the end of the SEI buffer until a non-0xFF byte is encountered, leading to undefined behavior.
Impact
Out-of-bounds read
Deterministic crash (segmentation fault) on malformed input
Undefined behavior during H.264 caption extraction
This can be triggered by small, malformed SEI NAL units and affects AVC/H.264 inputs.
Steps to reproduce
Create a minimal H.264 stream containing an SEI NAL unit with FF-extension bytes and no terminating byte, for example:
00 00 00 01 06 FF FF FF FF
Run CCExtractor on the file.
Observe a crash or undefined behavior.
Suggested fix
Add bounds checks (seibuf < seiend) inside the FF-extension parsing loops and abort parsing if the SEI message is truncated.