Skip to content
Memory corruption Advisory Advanced CVE-2024-47606

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.

antonio-morales Follow

Originally disclosed on GitHub Security Lab

An integer underflow has been detected in the function qtdemuxparsetheoraextension within qtdemux.c.

antonio-morales, on GitHub Security Lab

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

  1. Craft a media file that triggers the Theora extension parsing with a size value that causes an underflow.
  2. The underflowed size is passed to gst_buffer_new_and_alloc, which attempts to allocate a huge buffer.
  3. An integer overflow in _sysmem_new_block causes only a small buffer (0x89 bytes) to be allocated.
  4. gst_buffer_fill copies data from the input file into the small buffer, overflowing it and overwriting the GstMapInfo structure.
  5. 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.

More by antonio-morales

View all

45 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.