GHSL-2024-166: Integer underflow in qtdemux_parse_theora_extension leading to function pointer overwrite in GStreamer - CVE-2024-47606
An integer underflow in GStreamer's qtdemux_parse_theora_extension causes a small buffer to be allocated, which is then overflowed by a memcpy, overwriting a function pointer. An attacker could exploit this to hijack execution flow and potentially achieve arbitrary code execution.
Originally disclosed on GitHub Security Lab
An integer underflow has been detected in the function qtdemuxparsetheoraextension within qtdemux.c.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an integer underflow in the size calculation, followed by an integer overflow in the allocation size calculation, leads to a heap buffer overflow.
Impact
This vulnerability could allow an attacker to hijack the execution flow, potentially leading to code execution.
What the attacker needed
Victim opens a malicious media file
The fix
The issue was fixed and disclosed by GStreamer.
How it was found
- Craft a media file that triggers the Theora extension parsing with a size value that causes an underflow.
- The underflowed size is passed to gst_buffer_new_and_alloc, which attempts to allocate a huge buffer.
- An integer overflow in _sysmem_new_block causes only a small buffer (0x89 bytes) to be allocated.
- gst_buffer_fill copies data from the input file into the small buffer, overflowing it and overwriting the GstMapInfo structure.
- gst_memory_unmap calls a function pointer from the corrupted structure, leading to potential code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A media file contains a size value that is smaller than expected, causing a calculation to wrap around to a huge number. The program tries to allocate memory for that huge number but a second calculation overflows, so only a tiny buffer is created. When data is copied into that tiny buffer, it spills over and corrupts a function pointer, which the program later calls, potentially letting an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.