Crafting Targeted MP4 Fuzzers
Background
GStreamer is a widely used open source multimedia framework, supporting hundreds of media formats across its plugin sets. It consists of several command-line tools and a C library (with bindings for many other languages) that allow power users and developers to create arbitrarily complex encoding, decoding, and streaming pipelines.
From an adversarial standpoint, GStreamer's expansive and decades-old media processing code, written in a memory-unsafe language, is a rich attack surface. Any system that sends untrusted data into a GStreamer pipeline is therefore a promising target for attackers.
Prominent examples of such systems are the GNOME desktop environment, the WebKitGTK browser engine, the webOS smart TV operating system, and Comcast's RDK platform for set-top box development, all of which use GStreamer to process media from potentially malicious remote sources.
Since MP4 is the most common media container format on the internet, it was logical to scope my efforts to GStreamer's isomp4 plugin, included by default in the Good plugin set.
Challenges with conventional fuzzing
When faced with the task of fuzzing a binary format like MP4, most researchers reach for a coverage-guided mutational fuzzer such as AFL++ or libFuzzer. This is a good instinct and is usually the right answer. However, the default mutation strategies used by these fuzzers tend not to be effective at achieving deep coverage for MP4 parsers, as we will see below.
An MP4 file can be represented as an n-ary tree consisting of nodes (referred to as atoms or boxes in the specification) that carry different kinds of data and metadata. Some atoms are parents to child atoms, while others are leaves that merely contain their own payloads.
To achieve this structure in a binary file, atoms are laid out in a depth-first sequence, each with a 4-byte size field followed by a 4-byte atom label. The size field accounts for the atom's header, data, and descendants.
When a fuzzer mutates the file by inserting or deleting data within an atom, the tree may become invalid unless the modified atom's size field, as well as the size fields of each one of its ancestors, are corrected. Resultingly, a fuzzer that performs naive insertions and deletions (even on a coverage-guided basis) quickly starts failing on early validation code that checks the file's structural soundness.
For example, if a chunk of data is removed from the mdia atom, but the top-level moov atom still claims the original total size, the MP4 parser can reject the entire file because it is obviously invalid. After a while, the fuzzer can reach a plateau where it rarely makes it past those early routines, and deeper, more interesting code paths remain unexercised.
This problem is exacerbated the more deeply nested the target atom is; the probability that a random, length-changing mutation will ever be seen by the relevant parsing code drops exponentially with the atom's depth.
One way to counter this inefficiency is with structure-aware fuzzing, in which the fuzzer understands the format it is working with and uses a custom mutator to ensure that input files are at least loosely structurally valid before feeding them to the system under test.
Developing a fuzzer that models the entire MP4 format is technically possible but complex to implement and would likely be much slower than a fuzzer targeting only a narrow, bug-prone subset of the specification. Such a fuzzer would also need to decide which of the many format invariants to enforce and which to break. With too much structural validity, the fuzzer may ironically miss some bugs that rely on malformed inputs. With too little, it may run into the original problem again.
Establishing a baseline
Before attempting to develop a structure-aware fuzzer, I first wanted to answer two questions: how much of isomp4 is already covered by conventional mutational fuzzers, and is there any low-hanging fruit left?
Since GStreamer is continuously fuzzed by the OSS-Fuzz service, I headed to OSS-Fuzz's code coverage report to answer the first question. To my surprise, there was (and still is) zero pre-existing MP4 coverage because GStreamer's fuzz targets were compiled without the Good plugin set (which includes isomp4). As a result, I needed to build one of the fuzzers locally and manually enable those plugins in order to establish a baseline.
I decided to use the general-purpose gst-discoverer fuzzer, which calls the GStreamer API to scan ("discover") a media URI and extract as much metadata as possible from it with the appropriate plugin. The core logic for the harness is shown in the snippet below (comments my own). libFuzzer passes a single mutated input, represented by data and size, to the LLVMFuzzerTestOneInput function. Each mutation is coverage-guided but format-agnostic; neither libFuzzer nor the harness has any built-in awareness of the MP4 structure.
LLVMFuzzerTestOneInput then sends the input unmodified to the GStreamer API's gst_discoverer_discover_uri function for metadata discovery.
After building the fuzzer with -Dgood=enabled to enable the Good plugin set, I ran it inside a virtual machine on my own hardware (Ryzen 9 3950X, 32GB RAM) for roughly 16-24 CPU-weeks. The input corpus was seeded with both complete MP4 files I found in various online corpora and minimal files generated by GitHub Security Lab's corpus generator. Other than exercising isomp4, there were no functional differences between this fuzzer and the one continuously running on OSS-Fuzz.
Despite the fuzzer's lack of structure awareness, this round succeeded in uncovering the five memory safety vulnerabilities listed below. The first two potentially allow attackers to disclose heap contents via crafted MP4 files, especially against applications that use the GStreamer API in non-standard ways. The remaining three enable denial of service against GStreamer or any application that uses its API to parse TMPlayer or SubRip subtitle files.
- Heap out-of-bounds read in
qtdemux_parse_tree(CVE-2025-47183) - Heap out-of-bounds read in
qtdemux_parse_trak(CVE-2025-47219) - Null pointer dereference in
tmplayer_parse_line(CVE-2025-47808) - Null pointer dereference in
subrip_unescape_formatting(CVE-2025-47807) - Stack buffer overflow in
parse_subrip_time(CVE-2025-47806)
Note that the fuzzer was never seeded with subtitle files; it discovered the TMPlayer and SubRip formats entirely on its own. This is a phenomenon intrinsic to coverage-guided fuzzers, discussed in more detail in the next section.
Pipeline-based fuzzing
The first fuzzer discovered vulnerabilities in two file types it was never seeded with because libFuzzer made random mutations toward the TMPlayer and SubRip formats over time, encouraged by coverage feedback telling it that those were new code paths to explore. Such drift is common with structure-unaware, coverage-guided fuzzing of any target that supports multiple formats, but whether it is desirable depends on the researcher's goals.
For this project, I was more interested in depth of MP4 coverage than breadth of formats, so finding bugs in other file types was an anti-goal. One way to prevent format drift would be to disable support for all plugins except isomp4 at compile time. However, to keep the build system compatible with other fuzz targets without maintaining different options for each one, I instead took advantage of GStreamer's pipeline feature.
Pipelines allow users to specify the exact sequence of elements that should be chained for operations such as demuxing, decoding, and playback. By defining a pipeline with qtdemux as the only demuxer, one could craft a fuzz target whose mutations converge on the MP4 format at runtime. This works because the pipeline fails early during demuxing on non-MP4 inputs, so libFuzzer sees no new code paths and does not consider those inputs worth mutating further.
To implement this, I wrote an LLVMFuzzerTestOneInput function that passed test cases to a pipeline defined as appsrc name=src ! qtdemux ! fakesink, as shown below. The fakesink element is a dummy sink that discards its input and is necessary to complete the pipeline.
This pipeline-based fuzzer was faster than the stock one and found one bug the latter had missed: a heap out-of-bounds read in the qtdemux_parse_uuid function via an MP4 file with crafted PlayReady DRM metadata (CVE-2026-46471). An attacker could exploit this vulnerability to bypass address space layout randomization (ASLR) or leak the contents of files previously loaded by a GStreamer-backed process.
Structure-aware fuzzing
After investigating what was possible with conventional fuzzing, I started to conceptualize a structure-aware MP4 fuzzer. To avoid the complexities involved in modeling the entire MP4 format, I homed in on a small but valuable subset of the specification: the sample description (stsd) atom.
This deeply nested atom is rich with variable-size sample decoding metadata contained in a number of sub-atoms, which are technically entries of one field called the sample description table. Within GStreamer, stsd is handled by the qtdemux_parse_trak function, which loops over the sample description table's entries and parses each one using a mix of inline code and helper functions. The code tends to rely on manual pointer arithmetic and ad hoc bounds checking, making it a likely source of vulnerabilities.
Additionally, coverage reports I generated after running the earlier fuzzing campaigns revealed that large, interesting regions of this code were never being hit. For instance, the section below, which parses a chunk of the video sample description, remained without coverage after extended runs of the stock fuzzer. A fuzzer that understands how stsd fits into the larger MP4 file and takes care to preserve the structure surrounding it could therefore be fruitful for finding bugs in this code.
As a proof of concept, I developed a partially structure-aware fuzzer with the following design: instead of mutating the entire MP4 file and passing it to GStreamer, as the stock fuzzer did, it would mutate just stsd. It would then randomly splice the mutated data into one of two static template MP4 files (either a video or audio track) containing stsd's entire ancestor tree and update the ancestors' size fields appropriately. This way, the overall structure of each MP4 file passed to qtdemux is guaranteed to be valid, while only the target atom is fuzzed. My hypothesis was that this would increase coverage for code sections like the one above.
The basic implementation of this fuzzer is shown below. After receiving and minimally validating an input (a mutated stsd atom), the LLVMFuzzerTestOneInput function calls the fix_outer_structure_and_fuzz helper to adjust the ancestor tree based on the difference between the mutated atom's size and its original size in the template.
fix_outer_structure_and_fuzz passes the updated ancestor tree, mutated atom, and trailing template data to the fuzz_decode_mp4 helper, which wraps these pieces in a GstBuffer object to form a full MP4 container. It then pushes the buffer to a qtdemux pipeline defined as appsrc name=src ! qtdemux ! decodebin ! fakesink sync=false.
While the basic concept works as is, it is somewhat counterproductive to always mutate everything inside stsd. Because the goal is structure awareness, fields like the atom type (label), size, and entry count should stay correct at least some percentage of the time, or we would re-encounter the problem solved by step three in the diagram above, just at the stsd level. At the other extreme, keeping the header valid 100% of the time could make us miss bugs stemming from disagreements between the size or entry count field and the contents of the payload (the sample description table).
We can compromise by adding a libFuzzer custom mutator to fix the atom's size and entry count fields 50% of the time (arbitrary; there might be a more optimal value):
Instead of whole MP4 files, this fuzzer is seeded with a diverse sampling of stsd atoms, which I extracted from earlier runs' corpora. All crash files and other libFuzzer artifacts are also stsd atoms and do not reproduce directly under GStreamer; they must be either spliced back into the right template first or passed to the fuzzer binary (which does the splicing automatically) as positional arguments.
This fuzzer ultimately yielded three new bugs: two division-by-zero vulnerabilities allowing denial of service with crafted audio tracks (CVE-2026-46469 and CVE-2026-46470) and one global buffer overread without clear exploitability (CVE-2026-46472). As hypothesized, the coverage reports generated after a long campaign with this harness showed a substantial increase in qtdemux_parse_trak coverage, particularly in the section responsible for handling stsd.
Disclosure and remediation
As I verified and root-caused the crashes that accumulated, I reported them to the GStreamer developers per the project's disclosure policy.
Comments
No comments yet. Start the discussion.