A 0-click exploit chain for the Pixel 9 Part 1: Decoding Dolby
The Dolby Unified Decoder used by Google Messages to transcribe audio attachments automatically contains an integer overflow in its EMDF payload allocation, allowing a crafted DD+ audio file to overrun a heap buffer with attacker-controlled bytes. Combined with a length mismatch that lets EMDF data be read past the initialised skip buffer, an attacker could achieve arbitrary code execution in the mediacodec process with no user interaction.
Published on projectzero.google
Over the past few years, several AI-powered features have been added to mobile phones that allow users to better search and understand their messages. One effect of this change is increased 0-click attack surface, as efficient analysis often requires message media to be decoded before the message is opened by the user.
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.
Context
Google Messages automatically decodes incoming SMS and RCS audio attachments so it can transcribe them, with no user interaction. That places audio decoders in the 0-click attack surface of most Android phones. This write-up is the first of three posts describing a Project Zero 0-click exploit chain against the Pixel 9. Part 1 covers arbitrary code execution in the mediacodec context via CVE-2025-54957 in the Dolby Unified Decoder; Part 2 covers CVE-2025-36934, a driver reachable from the decoder sandbox that escalates from mediacodec to kernel; Part 3 covers lessons and recommendations. The vulnerabilities were fixed as of January 5, 2026.
The Dolby Unified Decoder (UDC) supports Dolby Digital (DD, AC-3) and Dolby Digital Plus (DD+, EAC-3). A public specification exists for both formats. The UDC ships to most OEMs as a binary blob with limited symbols, statically linked into a shared library. On the Pixel 9 it lives in /vendor/lib64/libcodec2_soft_ddpdec.so.
Earlier work in this area produced CVE-2025-49415 in the Monkey's Audio codec on Samsung devices. Based on that research the team reviewed the UDC, and Natalie Silvanovich and Ivan Fratric reported CVE-2025-54957. In parallel Seth Jenkins investigated a driver accessible from the decoder sandbox on a Pixel 9 and reported CVE-2025-36934.
Setup
The target is a Google Pixel 9 running the UDC as integrated into libcodec2_soft_ddpdec.so. The exploit is built as three MP4 files, which can be added as attachments to a single SMS or RCS message and are decoded in sequence. The researcher inspected the dynamic buffer in a debugger and built the exploit as a set of syncframes combined into MP4 files. The write-up does not list specific tool versions.
Finding it
DD+ audio is a bitstream of independently decodable syncframes, each holding a series of audio samples. A syncframe can contain up to 6 audio blocks, and each audio block can carry a skip field:
| Syntax | Number of bits |
|---|---|
skiple |
1 |
if(skiple) |
|
skipl |
9 |
skipfld |
9 * 8 |
} |
So the decoder copies up to 0x1FF (skipl) bytes per audio block into a buffer called the skip buffer. The skip buffer holds data in Extensible Metadata Delivery Format (EMDF). The UDC searches the skip buffer for a syncword and then processes what follows as an EMDF container:
| Syntax | Number of bits |
|---|---|
emdf_sync(){ |
|
syncword |
16 |
emdf_container_length |
16 |
} |
The EMDF syncword is 'X8'. The container itself is defined as:
| Syntax | Number of bits |
|---|---|
emdf_container() { |
|
emdf_version |
2 |
if (emdf_version == 3) { |
|
emdf_version += variable_bits(2) |
|
} |
|
key_id |
3 |
if (key_id == 7) { |
|
key_id += variable_bits(3) |
|
} |
|
while (emdf_payload_id != 0x0) { |
5 |
if (emdf_payload_id == 0x1F) { |
|
emdf_payload_id += variable_bits(5) |
|
} |
|
} |
|
emdf_payload_config() |
|
emdf_payload_size |
variable_bits(8) |
for (i = 0; i < payload_size; i++) { |
|
emdf_payload_byte |
8 |
} |
|
emdf_protection() |
|
} |
And variable_bits is:
| Syntax | Number of bits |
|---|---|
variable_bits (n_bits) { |
|
value = 0; |
|
do { |
|
value += read |
n_bits |
read_more |
1 |
if (read_more) { |
|
value <<= n_bits; |
|
value += (1<<n_bits); |
|
} |
|
} |
|
while (read_more); |
|
return value |
|
} |
The specification states no limit on emdf_payload_size, and variable_bits can return essentially any numeric value. That is the root of the bug Ivan Fratric found in the Android UDC binary. In pseudo-code, the EMDF payload is read into a custom 'evo' heap as follows:
result = read_variable_bits(this, 8, &payload_length);
if ( !result )
{
if ( evo_heap )
{
buffer = ddp_udc_int_evo_malloc(evo_heap, payload_length, param.extra_len);
outstruct.buf = buffer;
if ( !buffer )
return 2;
if ( payload_length )
{
index = 0;
while ( !ddp_udc_int_evo_brw_read(this, 8, &byte_read) )
{
outstruct.buf[index++] = byte_read;
if ( index >= payload_length )
goto ERROR;
}
return 10;
}
}
Memory is allocated, then payload bytes are copied into it. The allocator is:
void ddp_udc_int_evo_malloc(heap *h, size_t alloc_size, size_t extra)
{
size_t total_size;
unsigned __int8 *mem;
total_size = alloc_size + extra;
if ( alloc_size + extra < alloc_size )
return 0;
if ( total_size % 8 )
total_size += (8 - total_size) % total_size;
if ( total_size > heap->remaining )
return 0;
mem = heap->curr_mem;
heap->remaining -= total_size;
heap->curr_mem += total_size;
return mem;
}
The evo heap is a single slab with one tracking pointer, incremented on allocation. Nothing can be freed. It is used only for EMDF payloads of a single syncframe, then cleared and reused for the next frame, with no persistence between syncframes. The allocator performs several length checks, but the alignment step lacks an integer overflow check:
if ( total_size % 8 )
total_size += (8 - total_size) % total_size;
If the total allocation size on a 64-bit platform is between 0xFFFFFFFFFFFFFFF9 and 0xFFFFFFFFFFFFFFFF, total_size wraps to a small allocation, while the write loop still uses the original payload_length as its bound.
Integer overflow bugs usually mean very large writes, but here each byte is read through ddp_udc_int_evo_brw_read, which checks read bounds against emdf_container_length, also read from the skip buffer. When that check fails the loop exits, so the overflow size and the bytes written out of bounds are controllable, up to the size of skipl (0x1FF * 6 audio blocks). The researcher calls this the 'buffer overrun capability'.
There is also a leak. EMDF content is written to the skip buffer with length skipl, but the container has its own emdf_container_length. What happens when the container length is larger than skipl?
if ( skipflde && ... )
{
int skip_copy_len = 0;
for ( int block_num = 0; block_num < total_blocks; ++block_num )
{
if ( skiple )
{
...
for ( skip_copy_len; skip_copy_len < skipl; skip_copy_len++ )
{
b = read_byte_from_syncframe();
skip_buffer[skip_copy_len] = b;
}
}
}
int i = 0;
for (i = 0; i < skip_copy_len; i+=2 )
{
int16_t word = skip_buffer[i] | skip_buffer[i+1]);
if ( word == "X8" )
{
has_syncword = 1;
break;
}
}
if ( has_syncword )
{
…
emdf_container_length = skip_buffer[i + 1] | ( skip_buffer[i] << 8);
bit_reader.size = emdf_container_length;
bit_reader.data = skip_buffer[i + 2];
}
}
The skip buffer is written according to skipl, but the bit reader used to process the container has its length set to emdf_container_length, so EMDF data can be read past the initialised skip buffer. This is the 'leak capability'. It was not reported as a separate vulnerability because it has no security impact on its own: the skip buffer starts zeroed and afterwards only receives syncframe data, so an attacker could only leak what they already know. It becomes useful only combined with the buffer overrun.
Exploitation
Step 1: understand the decoder memory layout
The UDC makes four system heap allocations when decoding DD+ audio, all at decoder creation before any syncframe is processed, and frees and reallocates them between media files. Two matter here:
- The 'static buffer', 692855 bytes on Android, holds a large struct supporting all decoder functionality. The evo heap is part of it.
- The 'dynamic buffer', 85827 bytes, is scratch space and holds the skip buffer.
The other two allocations are for input parameters and output data and are not relevant. The names come from Android's integration of the UDC; both buffers are dynamically allocated.
The evo heap sits at offset 0x61d28 in the static buffer. Immediately after it is the pointer used to write skip data when processing EMDF, called the 'skip pointer'. It points 0x1000 below the skip buffer, and 0x1000 is added to it to compute where skipfld is written each syncframe. So the bug can overwrite a pointer that is later written with attacker-controlled content, the skip data of the next syncframe.
It is not as simple as overwriting the pointer directly: the evo heap is 0x1f08 bytes long and skipl maxes out at 3066 (0xbfa = 0x1ff * 6 audio blocks), so the value written into the skip pointer by a single overflowing payload is not immediately controllable. The original proof-of-concept attached to CVE-2025-54957 demonstrates this: the overrun happens, but the skip pointer is more than 3066 bytes from the overwritten evo heap allocation, so data is copied from outside the skip buffer. That memory is always zero, the skip pointer becomes 0, and a null pointer crash follows when the next syncframe's skip data is written.
The fix is to trigger the overrun when the evo heap is partially filled. An EMDF container can hold multiple payloads, and each payload allocates on the evo heap. In ddp_udc_int_evo_parse_bitstream, the smallest possible payload consumes 19 bits of skip buffer, while every payload processed allocates 96 bytes on the evo heap. Roughly 99 payloads fill the heap, which takes 235 bytes of skip data, well within the available space. This makes it possible to overwrite the skip pointer with a controllable absolute value and then write arbitrary data to it.
Step 2: WRITE DYNAMIC
An absolute pointer is unlikely to be known in a 0-click context because of ASLR. A partial overwrite is more practical: 0x7AAAAA00A0 could become 0x7AAAAA1234. Since the skip pointer originally points into the dynamic buffer, most of the dynamic buffer can be overwritten. The dynamic buffer only holds temporary numeric data, with no pointers or useful structures, but there is one useful property: normally only 3066 bytes of skip data can be written, and this allows more.
Consider this series of syncframes:
- Sets skip pointer to 0x7XXXXX4000
- Writes 3066 bytes of skip data to skip pointer
- Sets skip pointer to 0x7XXXXX3800
- Writes 0x800+ bytes of skip data to skip pointer
The available data in the skip buffer is now 3066 + 0x800, and chaining more syncframes can write up to 0xFFFF bytes into the dynamic buffer. This is called WRITE DYNAMIC.
One subtlety: setting the skip pointer overwrites data in the skip buffer. Syncframe 2 writes 3066 bytes, syncframe 3 overwrites, say, 200 of them, so syncframe 4 must write 0x800+200 bytes to repair the overwritten data. Writes must overlap. With enough syncframes almost the whole dynamic buffer can be filled with attacker data. It is also possible to process written data without modifying it: set the skip pointer to the start of the data in one syncframe, then process a second syncframe with skipl of 2, which writes only the syncword ('X8'), and the skip data is processed according to the already written emdf_container_length.
WRITE DYNAMIC alone is not enough for exploitation.
Step 3: look for targets in the static buffer
The static buffer has only two function pointers, at offsets 0x8a410 and 0x8a438, called frequently by DLB_CLqmf_analysisL. This appears to be the only dynamically allocated memory used by the UDC containing function pointers. Those offsets are more than 0x20000 bytes past the end of the evo heap at 0x63c30, far too large to reach by overflowing the heap, even filling the whole dynamic buffer (0xFFFF writable bytes) with EMDF container data.
Step 4: extend the evo heap
Near the end of the evo heap is heap_len, which sets the allocation limit of the evo heap during each syncframe. Overwriting it would let the evo heap allocate outside its original bounds, enabling relative writes within the static buffer. With a very large heap length, allocating 0x286e8 bytes from the evo heap start at 0x61d28 would reach 0x61d28 + 0x286e8 = 0x8a410, the function pointer. Payloads use skip buffer memory at a ratio of 19 bits to 90 bytes, so the function pointer could be reached with 0x286e8 / 90 * 19 / 8 = ~0xa000 bytes of skip data, under the 0xFFFF available.
Overwriting heap_len also overwrites the skip pointer, and an invalid skip pointer crashes before the new heap_len is used. Knowing an absolute writable pointer is impractical on a Pixel without an information leak. A valid pointer in the dynamic buffer would help, since the leak capability could embed it in skip data, but the dynamic buffer holds only numeric data.
Except that the dynamic buffer does contain pointers: not in the allocated portion, but in the contiguous metadata that Android's scudo allocator places with the allocation. In a debugger the pointer always has the form 0x000000XXXXXXX0A0, with the 0xa0 offset leaving room for the heap header. The header layout is shown in the post. Memory between offset 0x00 and 0x50 is unused by scudo because this is a secondary (large) allocation, but a guard page precedes the header, and 0x50 bytes is not enough for the EMDF container needed to overwrite both the skip pointer and the heap length. The researcher found two properties to work around this:
- If a secondary allocation is freed and a chunk up to 0x2000 bytes smaller is then allocated, the freed chunk is reused and the heap header shifts upwards. For example, a 0x17000 chunk at 0x7f00000000 that is freed and then satisfied by a 0x15000 allocation leaves the header at 0x7f00002000.
- When a secondary chunk is freed, scudo determines its size entirely from the 'curr chunk len' field in the header.
The dynamic and static buffers are large allocations with unusual sizes, so scudo always places them at the same location in a given process, allocating on decoder init and freeing on uninit, because once created they are the only suitable existing chunks for a request of that size. The UDC also runs in a separate process from other codecs on Android.
So the skip pointer can be aimed at the 'curr chunk len' field of the dynamic buffer's header and overwritten, changing the chunk length from 0x15000 to 0x17000. When the decoder is reset (a new file is played), the buffer is reallocated with an extra 0x2000 bytes of writable space before the header. This requires decoding multiple files, which is fine for transcription: multiple audio attachments to one message are decoded in sequence.
There is an ASLR problem. The dynamic buffer is at 0x000000XXXXXXY0a0, with X and Y randomised. The target value is 0x000000XXXXXXY065, but the skip buffer is 0x1000 from the address the skip pointer references, so the skip pointer must be 0x000000XXXXXXZ065 where Z is one less than Y. The exploit must overwrite nibble Y and therefore know it. An experiment on a Pixel showed the value is fairly evenly randomised, so the only option is to guess: the exploit works 1 in 16 times. An attacker can resend until it works; a wrong guess crashes decoding and the process respawns after roughly three seconds, so success comes on average in 24 seconds.
The exploit assumes the nibble is 3. With that and the header shift, an EMDF container can be inserted before the heap header and the leak capability used to copy it over the skip pointer, then continue the copy to set the heap length. The heap length ends up overwritten by audio data from early in the dynamic buffer, specifically bit allocation pointers, which for the syncframe used is 0x77007700770077.
Step 5: control the program counter
With roughly 2070 EMDF payloads written into the dynamic buffer, processing them allocates ~0x28000 bytes of evo heap, and the final payload overwrites the function pointer at 0x8a410. This did not work, because other fields follow the heap length in the static buffer.
To see why, look at how evo memory is allocated when EMDF payloads are processed, in highly simplified pseudocode:
int num_payloads = 0;
while(true){
int error = evo_parse_payload_id(&reader, &payload_id);
if(payload_id == 0 || error)
break;
num_payloads++;
error = evo_parse_payload(reader, payload_id, 0, 0, &payload, 0); //allocates no memory
if(error)
break;
}
void** payload_array = evo_malloc(evo_heap, 8 * num_payloads, 8 * array_extra);
for (int i = 0; i < num_payload; i++){
payload_array[i] = evo_alloc(88, 0);
}
reader.seek(0);
for (int i = 0; i < num_payload; i++){
int error = evo_parse_payload_id(&reader, &payload_id);
if(payload_id == 0 || error)
break;
error = evo_parse_payload(reader, payload_id, evo_heap, 0, payload_array[i], 0);
if(error)
break;
}
Inside the second evo_parse_payload call, a single allocation (the one that can overflow) happens:
void* payload_mem = evo_alloc(payload_size, payload_extra);
The code counts payloads, allocates an array of pointers, allocates an 88-byte struct per payload and stores its pointer in the array, then reads each payload into its struct, optionally allocating payload memory. array_extra and payload_extra are integrator-configurable parameters that make specific evo_alloc calls allocate extra memory.
With the heap length overwritten to a huge value, the decoder allocates outside the evo heap. The first allocation is payload_array, which with 2070 payloads is 0x40B0 bytes. It overlaps payload_extra and many other static buffer fields, setting them to pointer values. Fields interpreted as integers, like payload_extra, become very large numbers. Then evo_parse_payload attempts evo_alloc(payload_size, payload_extra). The size is payload_size + payload_extra (with an integer overflow check) before the buggy alignment padding. Pointers are tagged on Android, so this is something like:
total_size = payload_size + 0xB400007XXXXXXXXX;
The heap length is 0x77007700770077, always smaller than total_size, so the allocation fails. Worse, the overwritten payload_extra persists across syncframes, so no payload_mem allocation ever succeeds again, and the bug can never be triggered again to correct the static buffer.
It may not be necessary to trigger the bug again: the skip pointer is among the fields overwritten by the huge payload_array allocation, pointing into the static buffer above the evo heap. The researcher skips some details because this strategy was not used in the final exploit, but writing data to the altered skip pointer overwrote the function pointer, demonstrating that the vulnerability can set the program counter.
Step 6: non-contiguous overwrites
Setting the PC showed excellent exploitability, but it prevented the bug from being triggered again, allowing only one overwrite, which makes shellcode execution hard. The next goal was multiple non-contiguous writes to the static buffer.
The unavoidable corruption of payload_extra prevented future overwrites, but that same ability can be turned around. Evo heap allocations are laid out so that, with two payloads in a container, the second payload's data is allocated at num_payloads × 96 + payload_1_size + payload_extra. That lets payload_extra bytes be allocated in the static buffer without being overwritten by the payload. Since payload length and contents are attacker-controlled, any data at any relative location in the static buffer could be written if payload_extra could be set to controlled data. payload_1_size also comes from syncframe data. All required writes are close together, so payload_extra only needs writing once, making heap_base + num_payloads × 96 + payload_1_size + payload_extra equal to the X0 parameter of DLB_CLqmf_analysisL. Changing payload_1_size then shifts individual writes by that many bytes; for example, payload_1_size of 14 × 8 overwrites the function pointer discussed above.
Step 7: overwriting payload_extra
The method used for the heap length is not enough for payload_extra, and the corruption that gave PC control did not provide adequate control of the values. The heap length was overwritten by audio data written soon after the static buffer's scudo heap header, and payload_extra was overwritten by a pointer. Random garbage was enough for the heap length, but a specific value is needed for multiple overwrites.
WRITE DYNAMIC cannot write the data after the heap header to the needed value, because that address is written by the decoder while decoding bit allocation pointers (baps), between when attacker data is written and when the next syncframe processes it. Even if the right values are written with WRITE DYNAMIC, they are overwritten before they can set payload_extra and nearby fields. Including erroneous data to stop baps from being written also stopped EMDF data from being processed. Altering an audio block to write controlled data there did not work either: baps are limited to low 16-bit integers.
The next idea was to get scudo to write an 'inactive' header, containing pointer values but not currently in use. Experimenting with scudo showed that if a secondary chunk is the first of its size ever allocated by a process (as the dynamic buffer is), its previous pointer points to itself, and if that previous pointer is partially overwritten (for example, so the last two bytes are 0x5000 instead of 0x3000), the next allocation returns the 0x5000 address but the scudo header at 0x3000 is not cleared. This only works because the dynamic buffer is the only buffer anywhere near its size allocated by the process; otherwise the buffer could be allocated again, causing memory corruption and a crash before the exploit finishes.
Because the decoder must be reset to reallocate the dynamic buffer, a third media file was added. Three attachments fit easily in one SMS or RCS message. The files are:
- first.mp4 -- Using WRITE DYNAMIC, writes
dynamic_base + 0x3061to 0x48, causing the dynamic buffer to be reallocated atdynamic_base + 0x4800when second.mp4 is loaded - second.mp4 -- Using WRITE DYNAMIC, writes
dynamic_base + 0x4861to 0x50, causing the dynamic buffer to be reallocated atdynamic_base + 0x5000when third.mp4 is loaded - third.mp4 -- contains the rest of the exploit
dynamic_base is the dynamic buffer location with the lower two bytes cleared, i.e. dynamic_buffer && 0xFFFFFFFFFFFF0000. When the ASLR state is right, the dynamic buffer is at dynamic_base + 0x3000.
There is now an inactive scudo heap header at dynamic_base + 0x4800 that baps do not overwrite, usable to build an EMDF container that overwrites payload_extra. One problem remains: filling a buffer with WRITE DYNAMIC requires overlapping writes downwards, because the next EMDF container, needed to move the skip pointer, overwrites data at the start of the write. That is fine for a long page of data, but not here. Specific data had to go at exactly offset 0xc8 without corrupting the 'prev chunk ptr', which was needed to overwrite the skip pointer during the copy. There are 0x60 bytes between them, not enough for a payload that moves the skip pointer.
A new primitive comes from how the decoder handles the EMDF syncword. Once skip data is copied into the skip buffer, the buffer is searched for 'X8' and parsing starts after it. Data placed before the syncword is written to the skip pointer, and the container that moves the skip pointer goes after it, so both happen in one syncframe and the data is not corrupted by a later skip pointer write. This is WRITE DYNAMIC FAST. It has two downsides: less data can be written per syncframe, and it is harder to debug, because in WRITE DYNAMIC the written address is always at the same offset, making many syncframes easy to inspect visually, which is not true here. The exploit uses WRITE DYNAMIC wherever possible and WRITE DYNAMIC FAST only where necessary.
With this, a syncframe overwrites the skip pointer with a valid pointer into the dynamic buffer, then overwrites the heap length and payload_extra. This gives WRITE STATIC: a write to any offset in the static buffer larger than 0x63c30 relative to its base.
Step 8: calling controllable functions
The function pointers in the static buffer are called in DLB_CLqmf_analysisL:
void* DLB_CLqmf_analysisL(void **static_buffer, __int64 *output_index, __int64 in_param)
{
//static_buffer is static buffer at offset 0x8a3c8
…
int loop_times = *(int*)static_buffer + 5);
int index = *(_DWORD *)static_buffer;
do
{
index_val = *output_index++;
param_X0 = static_buffer[12];
param_val = param_X0 + 8 * index;
(static_buffer[14])(
param_X0,
static_buffer[5],
static_buffer[1],
static_buffer[7],
in_param);
result = dlb_forwardModulationComplex(
param_X0,
index_val,
param_val,
*static_buffer,
static_buffer[13],
static_buffer[8],
static_buffer[9]);
index = *(unsigned int *)static_buffer;
--loop_times;
…
}
while ( loop_times );
return result;
}
And dlb_forwardModulationComplex contains:
if ( a7 )
{
result = (__int64 (__fastcall *)(__int64, __int64, _QWORD))(*a7)(a3, a1, a4);
}
This reads a function pointer and parameters from memory writable with WRITE STATIC and calls the pointer with those parameters. There is also an indirect call through dlb_forwardModulationComplex when a pointer to a function pointer is available, and the call repeats a controllable number of times based on a value read from the static buffer. Combining DLB_CLqmf_analysisL with WRITE STATIC allows partial overwrites of function pointers to run ROP with controllable parameters.
Step 9: from ROP to instruction execution
Jann Horn repeatedly asked how the exploit would get from ROP to code execution in the mediacodec context, given Android's security features. The usual strategies are writing a shared library and calling dlopen, or writing shellcode and calling mprotect with ROP. SELinux blocked both: the mediacodec context has no allow rule to open and write the same file, so dlopen is out, and it lacks execmem permissions, so making memory executable is out. libcodec2_soft_ddpdec.so also makes limited libc calls, so few functions are available for ROP; it imports fopen and fread, but not fwrite or fseek.
Jann Horn suggested writing to /proc/self/mem, a ProcFS file that allows any memory in a process to be overwritten for debugging (software breakpoints), which could overwrite a function and then execute it. After investigating the mediacodec permissions, the strategy was:
- Map shellcode into memory using WRITE DYNAMIC
- Call
fopenon/proc/self/memmany times, so a file descriptor number associated with/proc/self/memcan be easily guessed - Call
pwriteto write the shellcode to a function that can later be executed. (Note thatpwriteis not imported bylibcodec2_soft_ddpdec.so, but nothing else that can write to a file handle is either).
Turning this into ROP calls via WRITE STATIC was harder than expected. Partially overwriting the function pointers in DLB_CLqmf_analysisL gives less than expected: the function makes two overwritable calls, a direct call to analysisPolyphaseFiltering_P4 at 0x26BDEC (not symbolized in the Android library) and an indirect call to DLB_r8_fft_64 via a pointer at offset 0x2A7B60. The upper nibble of the second byte of their load address is randomised by ASLR on Android, and testing showed fairly uniform behaviour. The options were ROP gadgets that only overwrite the first byte of the function pointers, or extra unreliability. The available gadgets were not promising, so the exploit guesses this nibble, adding another 1/16 probability for a total of 1 in 256. With a three-second respawn, that is around six minutes on average, which is not prohibitive.
Guessing the nibble expands the gadget span to 0xFFFF bytes, shiftable somewhat depending on the guess. That is still only about 5% of the 1.3 MB of code in libcodec2_soft_ddpdec.so. For the indirect call, 0xFFFF spans almost the entire export table and the global offset table (GOT), but the library exports only about 40 libc functions.
It was not hopeless. memcpy can be called within these limits, and with unmodified parameters dst is in the dynamic buffer and src in the static buffer. There was also a promising gadget in range:
0x000000000026ae38 :
ldr w8, [x1]
add w8, w8, #0x157
str w8, [x1]
ret
Called the 'increment gadget', it led to this plan:
- Change the indirect call to the
fopenpointer in the GOT, and call it several times on/proc/self/mem - Change the indirect call to
memcpy, and copy thefopenGOT entry to the dynamic buffer - Set the
dstparameter ofmemcpyto the location of the GOT pointer in the dynamic buffer and call it again, causing a pointer to thefopenfunction in libc to be copied to the dynamic buffer - Use DYNAMIC WRITE to overwrite the last byte of the function pointer, so the distance between the pointer and
pwriteis a multiple of 0x157 - Call the increment gadget over and over to increment the function pointer in the dynamic buffer by 0x157 until its value is
pwrite - Call
pwrite - Profit?
The maths works in the version examined: fopen is at 0x92E90 and pwrite at 0xDD6C0. A one-byte overwrite changes the fopen pointer to 0x92E4A, then:
0x157 × 890 + 0x92E4A = 0xDD6C0
The researcher believes this generalises to libc builds with different offsets. Each libc version has at least four call locations that end up calling pwrite: pwrite, pwrite's PLT, pwrite64 and pwrite64's PLT. If those fail, combinations of seek and write or fseek and fwrite exist. Worst case, the exploit can change which GOT entry is read so the maths starts from a different function pointer. There are very many possibilities and more than one is likely to work on every libc compilation.
Step 10: the third file, syncframe by syncframe
The third file is complicated, with unexpected problems. The syncframes can be followed in the attached exploit. Files beginning with numbers, such as 10_write_x0, contain the actual syncframe data; files like make_10_write_x0.py contain Python that generates the frame, often created with Gemini. Files with no corresponding Python were handforged or copied from previous syncframes. Files with the _special suffix were generated with the Python then altered by hand. combine_frames.py combines the syncframes into a single MP4 with correct checksums.
longmem
The third MP4 starts with the 36 syncframes in the longmem directory, containing the shellcode. It is copied to the dynamic buffer at descending addresses using DYNAMIC WRITE. Later steps break DYNAMIC WRITE, so it is easiest to place it now.
1_adjust_write_heap
Sets the skip pointer to dynamic_base + 0xF000.
2_adjust_write_heap_special
Uses DYNAMIC WRITE FAST to write 'wb' and "/proc/self/mem" to that address, so they are available as parameters for a future fopen call, then moves the skip pointer to dynamic_base + 0xD000 so they are not immediately corrupted.
3_adjust_write_heap
Sets the skip pointer to dynamic_base + 0x48c8, which will correspond to the evo heap length and payload_extra once the memory is copied. In hindsight this could have been done in the previous frame.
4_adjust_write_heap_special
Uses DYNAMIC WRITE FAST to write 0xFFFFFFFFFFFFFFFF at the offset corresponding to the evo heap length and 0x28530 at the offset corresponding to payload_extra, then sets the skip pointer to dynamic_base + 0x473a.
5_do_heap_write
Writes the start of an EMDF container to the address set in the previous frame, so that the data from 3_adjust_write_heap, 4_adjust_write_heap_special and this frame form a valid EMDF container. Parsing it triggers the bug and sets the heap length to 0xFFFFFFFFFFFFFFFF and payload_extra to 0x28530. This enables WRITE STATIC but disables WRITE DYNAMIC and DYNAMIC WRITE FAST, because evo heap allocations no longer take the same amount of space.
6_write_pc
WRITE STATIC can write the memory that becomes the X0 parameter to DLB_CLqmf_analysisL. The direct call's function pointer and its parameters (ARM64 registers X0 to X3) can be overwritten, and the indirect call's parameters are calculated from values in the same structure. Each 64-bit slot is an 'entry' that must be overwritten individually for non-contiguous partial overwrites, and WRITE STATIC alters one entry per syncframe. DLB_CLqmf_analysisL also executes once per syncframe, which can crash or misbehave if parameters are being set when the call happens. This frame sets direct_call_fptr at entry 14 to a gadget containing only ret, by partially overwriting the existing pointer, so the direct call does nothing unexpected.
7_garbage
Any frame with a valid EMDF header crashed after the previous frame due to an out-of-bounds memset. Based on its parameters the call is intended to zero the evo heap, but the heap length is now larger than the static buffer, so it writes out of bounds. Minimal analysis showed it requires processing two syncframes with EMDF containers in a row, so a frame with random invalid data resets this. This 'garbage' frame is required after every valid syncframe to avoid crashes. It is omitted from the rest of the description, but every later frame is even-numbered because the odd-numbered ones are garbage.
8_write_str_str
As with frame 6, the indirect function pointer at entry 9 must be overwritten to avoid crashes while parameters are set, but ROP cannot be used because the entry must point to a pointer to a function. This frame partially overwrites entry 9 to the GOT entry for strstr. X0 and X1 of the indirect call are always pointers at this stage and strstr modifies no memory, so repeated calls are harmless.
10_write_x0
Prepares X0 for the indirect call to fopen. X0 is the pointer at entry 12 (direct_call_X0) plus an offset from entry 0 (index):
indirect_call_x0 = direct_call_X0 + 8 * index;
"/proc/self/mem" was loaded into the dynamic buffer in frame 1, and this frame sets index to 1, so X0 references that string, 8 bytes from 'wb'.
12_write_x1
Partially overwrites entry 10, currently a pointer into the dynamic buffer, to dynamic_base + 0xF000, pointing at 'wb'.
14_write_fopen
Partially overwrites entry 9 so the indirect pointer references fopen. fopen is called four times, the default loop_count.
16_garbage to 23_garbage
Several garbage frames run fopen repeatedly to spray the file handle so it can be guessed. The UDC process opens very few files, so handles are predictable over a range.
24_write_str_str
Returns entry 9 to strstr, so fopen stops being called.
26_write_x2
Sets direct_call_X2 (entry 1) to 0xb8 for a memcpy call.
28_write_x0
Partially overwrites the dynamic buffer pointer in direct_call_X0 (entry 12) to dynamic_base + 0xEC00 for memcpy.
30_loop_count
Sets loop_count in entry 2 to 1, so future calls run once per syncframe.
32_memcpy
Sets the direct function pointer (entry 14) to a memcpy gadget at 0x26cc2c, which is called, copying the static buffer to the dynamic buffer, including the indirect pointer to strstr set at entry 9. The copy repeats every syncframe until entry 14 is overwritten again.
34_write_x0
The previous direct_call_X0 was a dummy value to keep the copy away from the skip buffer while the large EMDF container was processed. This frame sets it to the real destination, dynamic_base + 0x5F83.
36_zero_page and 38_copy_x1_special
These copy the newly written strstr GOT entry pointer to direct_call_X1 using the leak capability, so it can be the src for the next memcpy. 36_zero_page writes zeros followed by the end of an EMDF container to the skip pointer; the memcpy copies the GOT pointer into the middle of the container. 38_copy_x1_special writes the head of the container to the skip pointer, and parsing it sets direct_call_X1 (entry 5) to the GOT pointer.
40_write_x0 and 42_write_x0
Frame 40 sets direct_call_X0 (entry 12) to dynamic_base + 0xEF00; memcpy copies a direct pointer to strstr there. Frame 42 sets it to dynamic_base + 0x6043 so the copied memory is not corrupted and the next memcpy is set up.
44_write_x2, 46_write_scf, 48_zero_page and 50_write_x3_special
The idea was to set direct_call_X3 to strstr as the offset parameter of the eventual pwrite call, since the pointer was available in the dynamic buffer and all other direct calls needed fewer than four parameters. This turned out to be a bad idea. offset is where pwrite writes, which for /proc/self/mem is the address of the function to be overwritten with shellcode. strstr seemed perfect, but the finished exploit failed because getpid, munlock and several other frequently called functions sit immediately after it in libc and usually got called first, jumping into the middle of the shellcode. It was easier to copy a different function pointer with memcpy, and after testing __stack_chk_fail was chosen: it is not called during normal operation and the functions after it in libc are not used by the UDC. These frames use the same trick as for the strstr GOT copy to copy a pointer to __stack_chk_fail into direct_call_X3. This takes one round of the leak capability rather than two, because the pointer to the strstr GOT entry in direct_call_X1 could be partially overwritten to point to the __stack_chk_fail GOT entry, avoiding a second static buffer copy.
52_set_pc_back
Sets the direct call back to the ret gadget so memcpy stops being called.
54_write_skip, 56_write_x1_end_special and 58_write_x1_start_special
At the start the researcher believed shellcode execution would be possible without WRITE DYNAMIC once WRITE STATIC was unlocked. That was wrong: the plan missed that direct_call_X1 was set to the GOT at this point but needed to point to the dynamic buffer. Pointers into the dynamic buffer were already there from copying the static buffer, and the same trick could copy one to direct_call_X1, but the skip pointer would need to be moved and written to their address. The easiest path was to regain WRITE DYNAMIC.
This is a maths problem. The original WRITE DYNAMIC allocates many EMDF payloads to exhaust the heap, then triggers the buffer overwrite to alter the skip pointer; with payload_extra overwritten this fails because the integer overflow check fails when it is added to the payload size. But the vulnerability does not need to be triggered once the heap length is overwritten, because the evo heap no longer accurately checks whether heap writes are out of bounds. The new WRITE DYNAMIC allocates exactly enough payloads that the pointer array plus the payload structs line up with the skip pointer, and the first payload's data overlaps the pointer and overwrites it. These frames use a series of WRITE DYNAMIC and WRITE DYNAMIC FAST calls to set direct_call_X1 to the dynamic buffer.
60_write_skip, 62_write_single_byte and 64_move_skip
The first two frames use DYNAMIC WRITE to overwrite the final byte of the strstr pointer so it is a multiple of 0x157 away from pwrite. The last moves the skip pointer elsewhere so the byte is not written twice.
66_write_index
The increment gadget will run many times and also increment index at entry 0 in DLB_CLqmf_analysisL. This frame sets it to zero so later increments do not cause out-of-bounds reads.
68_loop_count
Sets loop_count in entry 2 to 0x7B so the increment gadget runs the right number of times. DLB_CLqmf_analysisL runs twice, so the gadget runs 0xF6 times.
70_write_x1
direct_call_X1 points somewhere in the dynamic buffer; this frame makes it point exactly at the modified strstr pointer.
72_inc_157
Sets the direct function pointer to the increment gadget, called 0xf6 times, so the pointer in the dynamic buffer becomes pwrite.
74_set_pc_back
Sets the direct call pointer back to the ret gadget so incrementing stops.
76_set_malloc
The indirect pointer is still strstr, which is a problem while preparing pwrite parameters, because pwrite's first parameter is a file handle (an integer) and would crash as strstr's first parameter. This frame sets the indirect pointer to malloc, whose GOT entry is in range and which succeeds with a single integer parameter.
78_write_x0
Writes direct_call_X0 with 40, the estimated handle for /proc/self/mem.
80_write_x1
Partially overwrites direct_call_X1 to point at the shellcode in the dynamic buffer.
82_write_x2
Writes direct_call_X2 with the integer length of the shellcode.
84_write_end_special and 86_write_start_special
Copy the pointer to pwrite into direct_call_fptr (entry 14) using the same method as other pointer copies from the dynamic buffer. pwrite is called immediately, overwriting __stack_chk_fail with the shellcode.
88_write_scf
Partially overwrites the indirect call register so it points to the GOT entry for _stack_chk_fail. __stack_chk_fail executes immediately, running the shellcode.
Root cause
The specification places no limit on emdf_payload_size, and variable_bits can return essentially any value. The allocator ddp_udc_int_evo_malloc checks alloc_size + extra for overflow but then adds alignment padding with total_size += (8 - total_size) % total_size; without an overflow check. A total size between 0xFFFFFFFFFFFFFFF9 and 0xFFFFFFFFFFFFFFFF wraps to a small allocation while the write loop still uses the original payload_length. The read bounds check in ddp_udc_int_evo_brw_read against emdf_container_length limits the overflow to the size of skipl (0x1FF * 6 audio blocks) and makes the written bytes controllable.
The leak comes from the same design: the skip buffer is filled according to skipl, but the bit reader's length is set to emdf_container_length, so EMDF data can be read past the initialised skip buffer. On its own it leaks only zeros or media content the attacker supplied.
Existing defences did not stop the chain. ASLR is defeated by guessing the dynamic buffer nibble (1 in 16) and the function pointer nibble (1 in 16), for 1 in 256 overall. SELinux blocks writing and opening the same file and blocks execmem, so dlopen and mprotect are unavailable; the chain uses /proc/self/mem and pwrite instead. The limited libc imports of libcodec2_soft_ddpdec.so constrain ROP, which is worked around with the increment gadget and GOT entries.
Impact
CVE-2025-54957 is likely in the 0-click attack surface of most Android devices in use today, because Google Messages automatically decodes incoming SMS and RCS audio attachments. On the Pixel 9 the exploit achieves arbitrary code execution in the mediacodec context. Part 2 of the series escalates from mediacodec to kernel via CVE-2025-36934. The exploit works roughly 1 in 255 times due to ASLR guessing, with a second, smaller source of unreliability. A second source of unreliability is binder occasionally performing a secondary allocation while the exploit runs, causing header checks to fail and a crash; this happened a lot with the debugger attached but less than 10% of the time in normal operation. A wrong guess crashes decoding and the process respawns after roughly three seconds, so repeated delivery is practical.
Fix
The vulnerabilities discussed in the posts were fixed as of January 5, 2026.
Variants to test
Hunting notes
Signals during recon include decoders that run automatically on message receipt (transcription, previews, thumbnails), libraries that import only a small subset of libc, and allocators with a single tracking pointer and no free. The researcher built a 0-click exploit chain targeting the Pixel 9, demonstrating PC control and then shellcode execution in the mediacodec context. The report notes that vendors and the security community questioned whether such vulnerabilities are exploitable and whether 0-click exploits are feasible for all but the most well-resourced attackers.
What happened, in plain words
Google Messages is the default texting app on many Android phones. When someone sends you a voice note or any audio file by SMS or RCS (the newer, richer version of SMS), the app tries to transcribe it automatically. That means the audio is decoded the moment it arrives, before you tap anything. A decoder is a piece of software that turns a compressed file into sound data the phone can use. Because decoding happens with no tap from you, a bug in a decoder can be triggered by simply sending a message. Security people call this a "0-click" attack: zero clicks from the victim.
This article is about one such bug, CVE-2025-54957, in the Dolby Unified Decoder (UDC), a library that understands the Dolby Digital and Dolby Digital Plus audio formats. The Project Zero team built an exploit that uses the bug to run code inside the part of Android that handles media, called mediacodec. The Project Zero team at Google wrote a 0-click exploit chain targeting the Pixel 9, and this is the first of three posts about it. Part 2 covers a second bug used to climb from the media process up to the phone's kernel (the core of the operating system). Part 3 covers lessons and advice. The vulnerabilities discussed in the posts were fixed as of January 5, 2026.
The team had already found a similar bug in another audio codec, Monkey's Audio, on Samsung phones (CVE-2025-49415). That led them to review the Dolby decoder, where Natalie Silvanovich and Ivan Fratric found CVE-2025-54957. In parallel, Seth Jenkins looked at a driver reachable from the decoder's sandbox on a Pixel 9 and found CVE-2025-36934.
A few ideas you need before the details make sense:
- Memory and addresses. A running program keeps its data in memory, and every byte has a numeric address, like a house number on a very long street. Pointers are variables that store such an address, so the program can find something again later.
- Buffers. A buffer is just a reserved block of memory used to hold data temporarily, for example the bytes of an audio file while they are being processed.
- Heap. The heap is the area of memory a program uses for data whose size is only known while it runs. An allocator hands out pieces of it on request.
- Integer overflow. Computers store numbers in fixed-size boxes. If you add to a number and the result is too big for the box, it wraps around to a small value, like a car odometer rolling from 999999 to 000000. Code that trusts the wrapped value can be tricked into reserving far less memory than it later writes into.
- ASLR. Address Space Layout Randomisation. The operating system loads programs and their data at randomised addresses each time, so an attacker cannot hard-code an address. It is like shuffling the deck before every game.
- Sandbox and SELinux. Android runs risky components in a restricted box (a sandbox) so that a bug there does not give full control of the phone. SELinux is the rule system that decides what each process may touch: which files it may open, which memory it may make executable, and so on.
- ROP. Return-Oriented Programming. When an attacker can only redirect execution to existing code, not inject new code, they chain together small snippets of existing instructions ("gadgets") that each end in a return, to make the program do something useful.
- Shellcode. A small piece of machine code an attacker wants to run, usually to start a shell or download more code.
The Dolby Unified Decoder
The Dolby Unified Decoder supports Dolby Digital (DD, also called AC-3) and Dolby Digital Plus (DD+, also called EAC-3). Both formats have a public specification, a document that describes exactly how the bytes of a file are laid out. The decoder is shipped to most phone makers as a compiled binary "blob" with few readable names inside, and it is linked into a shared library. On the Pixel 9 it lives at /vendor/lib64/libcodec2_soft_ddpdec.so.
The bug
DD+ audio is a stream of "syncframes". Each syncframe is a self-contained chunk that can be decoded on its own and represents a short run of audio samples. The decoder reads them one after another.
Inside a syncframe there are audio blocks, and a syncframe can hold up to 6 of them. Each audio block can carry a "skip" field, described in the specification like this:
| Syntax | Number of bits |
|---|---|
skiple |
1 |
if(skiple) |
|
skipl |
9 |
skipfld |
9 * 8 |
} |
In plain words: a one-bit flag skiple says whether a skip field is present. If it is, skipl is a 9-bit number giving a length, and skipfld is that many bytes of data. So the decoder copies up to 0x1FF bytes per audio block into a buffer the researcher calls the "skip buffer".
The skip buffer holds data in a format called Extensible Metadata Delivery Format (EMDF). It is "synchronised": the decoder scans the buffer for a special marker (a syncword) and then treats what follows as an EMDF container. The specification describes the marker like this:
| Syntax | Number of bits |
|---|---|
emdf_sync(){ |
|
syncword |
16 |
emdf_container_length |
16 |
} |
The syncword is the two characters 'X8'. After it comes a 16-bit number saying how long the container is. The container itself is defined as:
| Syntax | Number of bits |
|---|---|
emdf_container() { |
|
emdf_version |
2 |
if (emdf_version == 3) { |
|
emdf_version += variable_bits(2) |
|
} |
|
key_id |
3 |
if (key_id == 7) { |
|
key_id += variable_bits(3) |
|
} |
|
while (emdf_payload_id != 0x0) { |
5 |
if (emdf_payload_id == 0x1F) { |
|
emdf_payload_id += variable_bits(5) |
|
} |
|
} |
|
emdf_payload_config() |
|
emdf_payload_size |
variable_bits(8) |
for (i = 0; i < payload_size; i++) { |
|
emdf_payload_byte |
8 |
} |
|
emdf_protection() |
|
} |
A container holds one or more "payloads", each with an identifier, a size and a run of bytes. The size is read with a helper called variable_bits, defined as:
| Syntax | Number of bits |
|---|---|
variable_bits (n_bits) { |
|
value = 0; |
|
do { |
|
value += read |
n_bits |
read_more |
1 |
if (read_more) { |
|
value <<= n_bits; |
|
value += (1<<n_bits); |
|
} |
|
} |
|
while (read_more); |
|
return value |
|
} |
This reads a chunk of bits, then a flag saying "more follows". If more follows, it shifts what it has and adds another chunk, repeating as long as the flag is set. The result can be essentially any number, however large.
The specification puts no upper limit on emdf_payload_size, and variable_bits can return a huge value. That is the root of the bug Ivan Fratric found in the Android binary. In simplified form, the decoder reads the payload size and then reserves memory for it like this:
result = read_variable_bits(this, 8, &payload_length);
if ( !result )
{
if ( evo_heap )
{
buffer = ddp_udc_int_evo_malloc(evo_heap, payload_length, param.extra_len);
outstruct.buf = buffer;
if ( !buffer )
return 2;
if ( payload_length )
{
index = 0;
while ( !ddp_udc_int_evo_brw_read(this, 8, &byte_read) )
{
outstruct.buf[index++] = byte_read;
if ( index >= payload_length )
goto ERROR;
}
return 10;
}
}
Line by line:
read_variable_bits(this, 8, &payload_length)reads the payload size from the file intopayload_length.- If that succeeded and an "evo heap" exists,
ddp_udc_int_evo_mallocreservespayload_lengthbytes (plus some extra) and returns the address inbuffer. - If no memory came back, it returns an error code 2.
- Otherwise it loops:
ddp_udc_int_evo_brw_readreads one byte from the file, and the byte is stored atoutstruct.buf[index++], thenindexis increased. - If
indexreachespayload_length, the loop stops with an error code.
So memory is reserved first, then bytes are copied in. The reservation function is:
void ddp_udc_int_evo_malloc(heap *h, size_t alloc_size, size_t extra)
{
size_t total_size;
unsigned __int8 *mem;
total_size = alloc_size + extra;
if ( alloc_size + extra < alloc_size )
return 0;
if ( total_size % 8 )
total_size += (8 - total_size) % total_size;
if ( total_size > heap->remaining )
return 0;
mem = heap->curr_mem;
heap->remaining -= total_size;
heap->curr_mem += total_size;
return mem;
}
Line by line:
total_size = alloc_size + extra;adds the requested size and the extra amount.if ( alloc_size + extra < alloc_size ) return 0;is an overflow check: if adding made the number smaller, something wrapped, so refuse.if ( total_size % 8 ) total_size += (8 - total_size) % total_size;rounds the size up to a multiple of 8, so allocations stay aligned.if ( total_size > heap->remaining ) return 0;refuses if the heap does not have enough room left.- The last three lines hand out the current position, subtract the size from what remains, and move the position forward.
The "evo heap" is a single slab of memory with one moving pointer. Nothing can be freed. It is used only for the payloads of one syncframe, then wiped and reused for the next, so nothing carries over between frames.
The allocator does several length checks, but the rounding step has no overflow check:
if ( total_size % 8 )
total_size += (8 - total_size) % total_size;
If the total size on a 64-bit machine is between 0xFFFFFFFFFFFFFFF9 and 0xFFFFFFFFFFFFFFFF, the rounding wraps around and produces a tiny number. The reservation is then tiny, but the copy loop still uses the original payload_length as its limit. That is a classic integer overflow leading to a buffer overflow: reserve a small box, then write far more into it.
Normally such bugs mean enormous, uncontrollable writes. Here each byte is read through ddp_udc_int_evo_brw_read, which checks how much data is actually available against emdf_container_length, another number taken from the file. When that check fails, the loop stops. So the attacker controls both how far past the buffer the write goes and which bytes are written, up to the size of skipl (0x1FF times 6 audio blocks). The researcher calls this the "buffer overrun capability".
There is also a leak. The skip buffer is filled according to skipl, but the container has its own emdf_container_length. What if the container claims to be longer than what was copied in?
if ( skipflde && ... )
{
int skip_copy_len = 0;
for ( int block_num = 0; block_num < total_blocks; ++block_num )
{
if ( skiple )
{
...
for ( skip_copy_len; skip_copy_len < skipl; skip_copy_len++ )
{
b = read_byte_from_syncframe();
skip_buffer[skip_copy_len] = b;
}
}
}
int i = 0;
for (i = 0; i < skip_copy_len; i+=2 )
{
int16_t word = skip_buffer[i] | skip_buffer[i+1]);
if ( word == "X8" )
{
has_syncword = 1;
break;
}
}
if ( has_syncword )
{
…
emdf_container_length = skip_buffer[i + 1] | ( skip_buffer[i] << 8);
bit_reader.size = emdf_container_length;
bit_reader.data = skip_buffer[i + 2];
}
}
Line by line:
- For each audio block, if the skip flag is set, bytes are read from the file and stored in
skip_buffer, up toskiplbytes. - Then the buffer is scanned two bytes at a time looking for the marker 'X8'.
- If the marker is found, the container length is read from the two bytes after it, and the reader that will parse the container is given that length and a starting position.
The buffer was filled according to skipl, but the reader is told to read emdf_container_length bytes. If the second number is bigger, the reader reads past the part of the buffer that was filled. The researcher calls this the "leak capability". It was not reported as a separate bug because on its own it has no security impact: the skip buffer starts as all zeros and afterwards only ever receives data from the file being decoded, so an attacker could only leak things they already sent. It becomes useful only when combined with the overrun.
Decoder memory layout
To exploit the bug, you need to know what sits next to it in memory. The decoder makes four allocations from the system heap when it is created, before any audio is processed, and frees and reallocates them between files. Two matter:
- The "static buffer", 692855 bytes on Android, holds a big structure with all the decoder's state. The evo heap is part of it.
- The "dynamic buffer", 85827 bytes, is scratch space and contains the skip buffer.
The other two hold input parameters and output data and are not relevant. The names come from how Android integrates the decoder; both are in fact allocated at runtime.
The evo heap sits at offset 0x61d28 inside the static buffer. Right after it is the pointer used to write skip data when processing EMDF, called the "skip pointer". It points 0x1000 below the skip buffer, and 0x1000 is added to it to work out where skipfld is written each syncframe. So the bug can overwrite a pointer that is later used to write attacker-controlled data, namely the skip data of the next syncframe.
It is not as simple as overwriting that pointer directly. The evo heap is 0x1f08 bytes long, and skipl maxes out at 3066 (0xbfa, which is 0x1ff times 6 audio blocks), so a single overflowing payload cannot reach the pointer with a value the attacker chooses. The original proof-of-concept attached to CVE-2025-54957 shows this: the overrun happens, but the skip pointer is more than 3066 bytes away from the overwritten allocation, so the bytes copied into it come from outside the skip buffer. That memory is always zero, so the skip pointer becomes 0, and the next syncframe's write to it crashes the process.
The fix is to trigger the overrun when the evo heap is already partly full. A container can hold many payloads, and each one allocates on the evo heap. In ddp_udc_int_evo_parse_bitstream, the smallest possible payload uses 19 bits of skip data, while each payload allocates 96 bytes on the evo heap. About 99 payloads fill the heap, which takes only 235 bytes of skip data, well within what is available. That makes it possible to overwrite the skip pointer with a value the attacker controls, and then write arbitrary data wherever it points.
Write what where?
Knowing an absolute address is unlikely in a 0-click attack because of ASLR. A partial overwrite is more practical: 0x7AAAAA00A0 could become 0x7AAAAA1234, keeping the randomised high bits and changing only the low ones. Since the skip pointer normally points into the dynamic buffer, most of that buffer can be overwritten. The dynamic buffer only holds temporary numbers, with no pointers or useful structures, but it has one useful property: normally only 3066 bytes of skip data can be written, and this trick allows more.
Picture this sequence of syncframes:
- Sets skip pointer to 0x7XXXXX4000
- Writes 3066 bytes of skip data to skip pointer
- Sets skip pointer to 0x7XXXXX3800
- Writes 0x800+ bytes of skip data to skip pointer
The available data in the skip buffer is now 3066 + 0x800, and by chaining more syncframes up to 0xFFFF bytes can be written into the dynamic buffer. The researcher calls this WRITE DYNAMIC.
One subtlety: setting the skip pointer overwrites data in the skip buffer. Syncframe 2 writes 3066 bytes, syncframe 3 overwrites, say, 200 of them, so syncframe 4 must write 0x800+200 bytes to repair the damage. The writes must overlap. With enough syncframes almost the whole dynamic buffer can be filled with attacker data. It is also possible to process written data without changing it: point the skip pointer at the start of the data in one syncframe, then process a second syncframe with skipl of 2, which writes only the marker 'X8', and the data is then parsed according to the emdf_container_length already written.
WRITE DYNAMIC alone is not enough to take over the phone.
Looking for targets in the static buffer
The static buffer contains only two function pointers, at offsets 0x8a410 and 0x8a438, and they are called often by a function named DLB_CLqmf_analysisL. A function pointer is a variable holding the address of code to run; overwriting one is a classic way to hijack a program. This appears to be the only dynamically allocated memory used by the decoder that holds function pointers. Those offsets are more than 0x20000 bytes past the end of the evo heap at 0x63c30, far too far to reach by overflowing the heap, even by filling the whole dynamic buffer (0xFFFF writable bytes) with container data.
Extending the evo heap
Near the end of the evo heap is a field called heap_len, which sets how much the evo heap may allocate during each syncframe. Overwriting it would let the heap hand out memory outside its normal bounds, which would allow writes at chosen distances inside the static buffer. With a very large heap length, allocating 0x286e8 bytes starting from 0x61d28 would reach 0x61d28 + 0x286e8 = 0x8a410, the function pointer. Payloads use skip data at a ratio of 19 bits to 90 bytes, so the pointer could be reached with about 0x286e8 / 90 * 19 / 8 = ~0xa000 bytes of skip data, under the 0xFFFF available.
Overwriting heap_len also overwrites the skip pointer, and an invalid skip pointer crashes the process before the new heap_len is used. Knowing an absolute writable address is impractical on a Pixel without an information leak. A valid pointer sitting in the dynamic buffer would help, because the leak capability could copy it into skip data, but the dynamic buffer holds only numbers.
Except that the dynamic buffer does contain pointers: not in the part the decoder uses, but in the bookkeeping data that Android's memory allocator, scudo, stores alongside the allocation. In a debugger the pointer always has the form 0x000000XXXXXXX0A0, where the 0xa0 offset leaves room for the allocator's header. The header layout is shown in the post. The bytes between offset 0x00 and 0x50 are unused by scudo because this is a "secondary" (large) allocation, but a guard page sits before the header, and 0x50 bytes is not enough for the container needed to overwrite both the skip pointer and the heap length. The researcher found two properties to work around this:
- If a secondary allocation is freed and a chunk up to 0x2000 bytes smaller is then allocated, the freed chunk is reused and the header moves upwards. For example, a 0x17000 chunk at 0x7f00000000 that is freed and then satisfied by a 0x15000 allocation leaves the header at 0x7f00002000.
- When a secondary chunk is freed, scudo works out its size entirely from the "curr chunk len" field in the header.
The dynamic and static buffers are large and have unusual sizes, so scudo always places them at the same spot in a given process, allocating on decoder start and freeing on stop, because once created they are the only suitable chunks for a request of that size. The decoder also runs in its own process, separate from other codecs on Android.
So the skip pointer can be aimed at the "curr chunk len" field of the dynamic buffer's header and overwritten, changing the chunk length from 0x15000 to 0x17000. When the decoder is reset (a new file is played), the buffer is reallocated with an extra 0x2000 bytes of writable space before the header. This means the attack must decode several files, which is fine for transcription: several audio attachments to one message are decoded in order.
There is an ASLR problem. The dynamic buffer is at 0x000000XXXXXXY0a0, where X and Y are randomised. The target value is 0x000000XXXXXXY065, but the skip buffer is 0x1000 away from the address the skip pointer refers to, so the skip pointer must be 0x000000XXXXXXZ065 where Z is one less than Y. The attack must overwrite the Y digit and therefore know it. An experiment on a Pixel showed it is fairly evenly randomised, so the only option is to guess: the attack works 1 time in 16. An attacker can resend until it works; a wrong guess crashes decoding and the process restarts after roughly three seconds, so success comes on average in 24 seconds.
The exploit assumes the digit is 3. With that and the header shift, a container can be placed before the header and the leak capability used to copy it over the skip pointer, then continue the copy to set the heap length. The heap length ends up overwritten by audio data from early in the dynamic buffer, specifically bit allocation pointers, which for the syncframe used is 0x77007700770077.
Controlling the program counter
With roughly 2070 payloads written into the dynamic buffer, processing them allocates about 0x28000 bytes of evo heap, and the final payload overwrites the function pointer at 0x8a410. This did not work, because other fields follow the heap length in the static buffer.
To see why, look at how evo memory is allocated when payloads are processed, in simplified pseudocode:
int num_payloads = 0;
while(true){
int error = evo_parse_payload_id(&reader, &payload_id);
if(payload_id == 0 || error)
break;
num_payloads++;
error = evo_parse_payload(reader, payload_id, 0, 0, &payload, 0); //allocates no memory
if(error)
break;
}
void** payload_array = evo_malloc(evo_heap, 8 * num_payloads, 8 * array_extra);
for (int i = 0; i < num_payload; i++){
payload_array[i] = evo_alloc(88, 0);
}
reader.seek(0);
for (int i = 0; i < num_payload; i++){
int error = evo_parse_payload_id(&reader, &payload_id);
if(payload_id == 0 || error)
break;
error = evo_parse_payload(reader, payload_id, evo_heap, 0, payload_array[i], 0);
if(error)
break;
}
Line by line:
- The first loop counts how many payloads the container holds, without allocating anything.
evo_malloc(evo_heap, 8 * num_payloads, 8 * array_extra)reserves an array of pointers, one per payload, plusarray_extra.- The next loop reserves an 88-byte structure for each payload and stores its address in the array.
- The reader rewinds to the start, and the final loop parses each payload again, this time with the heap available, filling in the structures.
Inside the second evo_parse_payload call, one allocation happens, the same one that can overflow:
void* payload_mem = evo_alloc(payload_size, payload_extra);
array_extra and payload_extra are settings the integrator can choose, which make certain allocations reserve extra memory.
With the heap length overwritten to a huge value, the decoder allocates outside the evo heap. The first allocation is payload_array, which with 2070 payloads is 0x40B0 bytes. It lands on top of payload_extra and many other static buffer fields, setting them to pointer values. Fields read as integers, like payload_extra, become very large numbers. Then evo_parse_payload tries evo_alloc(payload_size, payload_extra). The size is payload_size + payload_extra (with an overflow check) before the buggy rounding. Pointers are tagged on Android, so this is something like:
total_size = payload_size + 0xB400007XXXXXXXXX;
The heap length is 0x77007700770077, always smaller than total_size, so the allocation fails. Worse, the overwritten payload_extra persists across syncframes, so no payload allocation ever succeeds again, and the bug can never be triggered again to repair the static buffer.
It may not be necessary to trigger the bug again: the skip pointer is among the fields overwritten by the huge payload_array allocation, and it now points into the static buffer above the evo heap. The researcher skips some details because this route was not used in the final exploit, but writing data through the altered skip pointer overwrote the function pointer, proving the bug can set the program counter.
Non-contiguous overwrites
Setting the program counter showed the bug is very exploitable, but it also stopped the bug from being triggered again, allowing only one overwrite, which makes running shellcode hard. The next goal was several separate writes to the static buffer.
The unavoidable corruption of payload_extra blocked future overwrites, but that same ability can be turned around. Evo heap allocations are laid out so that, with two payloads in a container, the second payload's data is placed at num_payloads × 96 + payload_1_size + payload_extra. That lets payload_extra bytes be reserved in the static buffer without being overwritten by the payload. Since payload length and contents are attacker-controlled, any data at any relative location in the static buffer could be written if payload_extra could be set to a chosen value. payload_1_size also comes from the file. All the writes needed are close together, so payload_extra only needs setting once, making heap_base + num_payloads × 96 + payload_1_size + payload_extra equal to the X0 parameter of DLB_CLqmf_analysisL. Changing payload_1_size then shifts individual writes by that many bytes; for example, payload_1_size of 14 × 8 overwrites the function pointer discussed above.
Overwriting payload_extra
The method used for the heap length is not enough for payload_extra, and the corruption that gave program counter control did not give enough control over the values. The heap length was overwritten by audio data written soon after the static buffer's scudo header, and payload_extra was overwritten by a pointer. Random garbage was enough for the heap length, but a specific value is needed for multiple overwrites.
WRITE DYNAMIC cannot write the bytes after the heap header to the needed value, because that address is written by the decoder while decoding bit allocation pointers (baps), between the moment attacker data is written and the moment the next syncframe processes it. Even if the right values are written with WRITE DYNAMIC, they are overwritten before they can set payload_extra and nearby fields. Including bad data to stop baps from being written also stopped EMDF data from being processed. Altering an audio block to write chosen data there did not work either: baps are limited to small 16-bit integers.
The next idea was to get scudo to leave an "inactive" header, one that holds pointer values but is not currently in use. Experimenting with scudo showed that if a secondary chunk is the first of its size ever allocated by a process (as the dynamic buffer is), its previous pointer points to itself, and if that previous pointer is partly overwritten (for example, so the last two bytes are 0x5000 instead of 0x3000), the next allocation returns the 0x5000 address but the header at 0x3000 is not cleared. This only works because the dynamic buffer is the only buffer anywhere near its size allocated by the process; otherwise the buffer could be allocated again, causing memory corruption and a crash before the attack finishes.
Because the decoder must be reset to reallocate the dynamic buffer, a third media file was added. Three attachments fit easily in one SMS or RCS message. The files are:
- first.mp4 -- Using WRITE DYNAMIC, writes
dynamic_base + 0x3061to 0x48, causing the dynamic buffer to be reallocated atdynamic_base + 0x4800when second.mp4 is loaded - second.mp4 -- Using WRITE DYNAMIC, writes
dynamic_base + 0x4861to 0x50, causing the dynamic buffer to be reallocated atdynamic_base + 0x5000when third.mp4 is loaded - third.mp4 -- contains the rest of the exploit
dynamic_base is the dynamic buffer's location with the lower two bytes cleared, i.e. dynamic_buffer && 0xFFFFFFFFFFFF0000. When the ASLR state is right, the dynamic buffer is at dynamic_base + 0x3000.
There is now an inactive scudo header at dynamic_base + 0x4800 that baps do not overwrite, which can be used to build a container that overwrites payload_extra. One problem remains: filling a buffer with WRITE DYNAMIC needs overlapping writes downwards, because the next container, needed to move the skip pointer, overwrites data at the start of the write. That is fine for a long page of data, but not here. Specific data had to go at exactly offset 0xc8 without damaging the "prev chunk ptr", which was needed to overwrite the skip pointer during the copy. There are 0x60 bytes between them, not enough for a payload that moves the skip pointer.
A new trick comes from how the decoder handles the marker. Once skip data is copied into the skip buffer, the buffer is searched for 'X8' and parsing starts after it. Data placed before the marker is written to the skip pointer, and the container that moves the skip pointer goes after it, so both happen in one syncframe and the data is not damaged by a later skip pointer write. This is WRITE DYNAMIC FAST. It has two downsides: less data can be written per syncframe, and it is harder to debug, because with WRITE DYNAMIC the written address is always at the same offset, making many syncframes easy to inspect by eye, which is not true here. The exploit uses WRITE DYNAMIC wherever possible and WRITE DYNAMIC FAST only where necessary.
With this, a syncframe overwrites the skip pointer with a valid pointer into the dynamic buffer, then overwrites the heap length and payload_extra. This gives WRITE STATIC: a write to any offset in the static buffer above 0x63c30 relative to its base.
Calling controllable functions
The function pointers in the static buffer are called in DLB_CLqmf_analysisL:
void* DLB_CLqmf_analysisL(void **static_buffer, __int64 *output_index, __int64 in_param)
{
//static_buffer is static buffer at offset 0x8a3c8
…
int loop_times = *(int*)static_buffer + 5);
int index = *(_DWORD *)static_buffer;
do
{
index_val = *output_index++;
param_X0 = static_buffer[12];
param_val = param_X0 + 8 * index;
(static_buffer[14])(
param_X0,
static_buffer[5],
static_buffer[1],
static_buffer[7],
in_param);
result = dlb_forwardModulationComplex(
param_X0,
index_val,
param_val,
*static_buffer,
static_buffer[13],
static_buffer[8],
static_buffer[9]);
index = *(unsigned int *)static_buffer;
--loop_times;
…
}
while ( loop_times );
return result;
}
Line by line:
loop_timesis read from the start of the static buffer, plus 5, andindexfrom the same place.- The loop takes the next value from
output_index, readsparam_X0from slot 12 of the static buffer, and computesparam_valfrom it andindex. - It then calls the function pointer in slot 14, passing
param_X0, slots 5, 1 and 7, andin_param. - Next it calls
dlb_forwardModulationComplexwith several values from the static buffer, including slot 9. indexis refreshed,loop_timesis decremented, and the loop repeats until it reaches zero.
And dlb_forwardModulationComplex contains:
if ( a7 )
{
result = (__int64 (__fastcall *)(__int64, __int64, _QWORD))(*a7)(a3, a1, a4);
}
If a7 is not null, it treats a7 as a pointer to a function pointer and calls that function with a3, a1 and a4. So this code reads a function pointer and its arguments from memory that WRITE STATIC can change, and calls it. There is also an indirect call through dlb_forwardModulationComplex when a pointer to a function pointer is available, and the call repeats a controllable number of times based on a value read from the static buffer. Combining DLB_CLqmf_analysisL with WRITE STATIC allows partial overwrites of function pointers to run ROP with controllable arguments.
From ROP to instruction execution
Jann Horn repeatedly asked how the attack would get from ROP to actually running code in the mediacodec context, given Android's protections. The usual approaches are to write a shared library and call dlopen, or to write shellcode and call mprotect with ROP to make it executable. SELinux blocked both: the mediacodec context has no rule allowing it to open and write the same file, so dlopen is out, and it lacks execmem permission, so making memory executable is out. libcodec2_soft_ddpdec.so also makes few libc calls, so few functions are available for ROP; it imports fopen and fread, but not fwrite or fseek.
Jann Horn suggested writing to /proc/self/mem, a special file in the ProcFS filesystem that lets a process overwrite any of its own memory, used for debugging (software breakpoints). That could overwrite a function and then run it. After checking the mediacodec permissions, the plan was:
- Map shellcode into memory using WRITE DYNAMIC
- Call
fopenon/proc/self/memmany times, so a file descriptor number associated with/proc/self/memcan be easily guessed - Call
pwriteto write the shellcode to a function that can later be executed. (Note thatpwriteis not imported bylibcodec2_soft_ddpdec.so, but nothing else that can write to a file handle is either).
Turning this into ROP calls via WRITE STATIC was harder than expected. Partially overwriting the function pointers in DLB_CLqmf_analysisL gives less than expected: the function makes two overwritable calls, a direct call to analysisPolyphaseFiltering_P4 at 0x26BDEC (not named in the Android library) and an indirect call to DLB_r8_fft_64 via a pointer at offset 0x2A7B60. The upper nibble of the second byte of their load address is randomised by ASLR on Android, and testing showed fairly uniform behaviour. The options were ROP gadgets that only overwrite the first byte of the function pointers, or extra unreliability. The available gadgets were not promising, so the exploit guesses this nibble, adding another 1 in 16 chance for a total of 1 in 256. With a three-second restart, that is around six minutes on average, which is acceptable.
Guessing the nibble expands the gadget span to 0xFFFF bytes, shiftable somewhat depending on the guess. That is still only about 5% of the 1.3 MB of code in libcodec2_soft_ddpdec.so. For the indirect call, 0xFFFF spans almost the entire export table and the global offset table (GOT), but the library exports only about 40 libc functions.
It was not hopeless. memcpy can be called within these limits, and with unmodified arguments dst is in the dynamic buffer and src in the static buffer. There was also a promising gadget in range:
0x000000000026ae38 :
ldr w8, [x1]
add w8, w8, #0x157
str w8, [x1]
ret
Line by line: ldr w8, [x1] loads a 32-bit value from the address in register x1 into register w8. add w8, w8, #0x157 adds 0x157 to it. str w8, [x1] stores it back to the same address. ret returns. In short, it adds 0x157 to a number in memory. The researcher calls it the "increment gadget".
That led to this plan:
- Change the indirect call to the
fopenpointer in the GOT, and call it several times on/proc/self/mem - Change the indirect call to
memcpy, and copy thefopenGOT entry to the dynamic buffer - Set the
dstargument ofmemcpyto the location of the GOT pointer in the dynamic buffer and call it again, causing a pointer to thefopenfunction in libc to be copied to the dynamic buffer - Use DYNAMIC WRITE to overwrite the last byte of the function pointer, so the distance between the pointer and
pwriteis a multiple of 0x157 - Call the increment gadget over and over to increment the function pointer in the dynamic buffer by 0x157 until its value is
pwrite - Call
pwrite - Profit?
The maths works in the version examined: fopen is at 0x92E90 and pwrite at 0xDD6C0. A one-byte overwrite changes the fopen pointer to 0x92E4A, then:
0x157 × 890 + 0x92E4A = 0xDD6C0
The researcher believes this generalises to libc builds with different offsets. Each libc version has at least four call locations that end up calling pwrite: pwrite, pwrite's PLT, pwrite64 and pwrite64's PLT. If those fail, combinations of seek and write or fseek and fwrite exist. Worst case, the exploit can change which GOT entry is read so the maths starts from a different function pointer. There are very many possibilities and more than one is likely to work on every libc build.
The exploit, syncframe by syncframe
The third file is complicated, with unexpected problems. The syncframes can be followed in the attached exploit. Files beginning with numbers, such as 10_write_x0, contain the actual syncframe data; files like make_10_write_x0.py contain Python that generates the frame, often created with Gemini. Files with no matching Python were hand-made or copied from earlier syncframes. Files with the _special suffix were generated with the Python then altered by hand. combine_frames.py combines the syncframes into a single MP4 with correct checksums.
longmem
The third MP4 starts with the 36 syncframes in the longmem directory, containing the shellcode. It is copied to the dynamic buffer at descending addresses using DYNAMIC WRITE. Later steps break DYNAMIC WRITE, so it is easiest to place it now.
1_adjust_write_heap
Sets the skip pointer to dynamic_base + 0xF000.
2_adjust_write_heap_special
Uses DYNAMIC WRITE FAST to write 'wb' and "/proc/self/mem" to that address, so they are ready as arguments for a future fopen call, then moves the skip pointer to dynamic_base + 0xD000 so they are not immediately damaged.
3_adjust_write_heap
Sets the skip pointer to dynamic_base + 0x48c8, an offset that will line up with the evo heap length and payload_extra once the memory is copied. In hindsight this could have been done in the previous frame.
4_adjust_write_heap_special
Uses DYNAMIC WRITE FAST to write 0xFFFFFFFFFFFFFFFF at the offset that will be the evo heap length and 0x28530 at the offset that will be payload_extra, then sets the skip pointer to dynamic_base + 0x473a.
5_do_heap_write
Writes the start of a container to the address set in the previous frame, so that the data from 3_adjust_write_heap, 4_adjust_write_heap_special and this frame together form a valid container. Parsing it triggers the bug and sets the heap length to 0xFFFFFFFFFFFFFFFF and payload_extra to 0x28530. This enables WRITE STATIC but disables WRITE DYNAMIC and DYNAMIC WRITE FAST, because evo heap allocations no longer take the same amount of space.
6_write_pc
WRITE STATIC can write the memory that becomes the X0 argument to DLB_CLqmf_analysisL. The direct call's function pointer and its arguments (ARM64 registers X0 to X3) can be overwritten, and the indirect call's arguments are calculated from values in the same structure. Each 64-bit slot is an "entry" that must be overwritten individually for separate partial overwrites, and WRITE STATIC changes one entry per syncframe. DLB_CLqmf_analysisL also runs once per syncframe, which can crash or misbehave if arguments are being set when the call happens. This frame sets direct_call_fptr at entry 14 to a gadget containing only ret, by partially overwriting the existing pointer, so the direct call does nothing unexpected.
7_garbage
Any frame with a valid header crashed after the previous frame because of an out-of-bounds memset. Judging by its arguments, the call is meant to zero the evo heap, but the heap length is now larger than the static buffer, so it writes out of bounds. A minimal analysis showed it needs two syncframes with containers in a row, so a frame with random invalid data resets this. This "garbage" frame is needed after every valid syncframe to avoid crashes. It is left out of the rest of the description, but every later frame is even-numbered because the odd-numbered ones are garbage.
8_write_str_str
As with frame 6, the indirect function pointer at entry 9 must be overwritten to avoid crashes while arguments are set, but ROP cannot be used because the entry must point to a pointer to a function. This frame partially overwrites entry 9 to the GOT entry for strstr. X0 and X1 of the indirect call are always pointers at this stage and strstr changes no memory, so repeated calls are harmless.
10_write_x0
Prepares X0 for the indirect call to fopen. X0 is the pointer at entry 12 (direct_call_X0) plus an offset from entry 0 (index):
indirect_call_x0 = direct_call_X0 + 8 * index;
"/proc/self/mem" was loaded into the dynamic buffer in frame 1, and this frame sets index to 1, so X0 points at that string, 8 bytes from 'wb'.
12_write_x1
Partially overwrites entry 10, currently a pointer into the dynamic buffer, to dynamic_base + 0xF000, pointing at 'wb'.
14_write_fopen
Partially overwrites entry 9 so the indirect pointer now references fopen. fopen is called four times, the default loop_count.
16_garbage to 23_garbage
Several garbage frames run fopen repeatedly to spray the file handle so it can be guessed. The decoder process opens very few files, so handles are predictable over a range.
24_write_str_str
Returns entry 9 to strstr, so fopen stops being called.
26_write_x2
Sets direct_call_X2 (entry 1) to 0xb8 for a memcpy call.
28_write_x0
Partially overwrites the dynamic buffer pointer in direct_call_X0 (entry 12) to dynamic_base + 0xEC00 for memcpy.
30_loop_count
Sets loop_count in entry 2 to 1, so future calls run once per syncframe.
32_memcpy
Sets the direct function pointer (entry 14) to a memcpy gadget at 0x26cc2c, which is called, copying the static buffer to the dynamic buffer, including the indirect pointer to strstr set at entry 9. The copy repeats every syncframe until entry 14 is overwritten again.
34_write_x0
The previous direct_call_X0 was a dummy value to keep the copy away from the skip buffer while the large container was processed. This frame sets it to the real destination, dynamic_base + 0x5F83.
36_zero_page and 38_copy_x1_special
These copy the newly written strstr GOT entry pointer to direct_call_X1 using the leak capability, so it can be the src for the next memcpy. 36_zero_page writes zeros followed by the end of a container to the skip pointer; the memcpy copies the GOT pointer into the middle of the container. 38_copy_x1_special writes the head of the container to the skip pointer, and parsing it sets direct_call_X1 (entry 5) to the GOT pointer.
40_write_x0 and 42_write_x0
Frame 40 sets direct_call_X0 (entry 12) to dynamic_base + 0xEF00; memcpy copies a direct pointer to strstr there. Frame 42 sets it to dynamic_base + 0x6043 so the copied memory is not damaged and the next memcpy is set up.
44_write_x2, 46_write_scf, 48_zero_page and 50_write_x3_special
The idea was to set direct_call_X3 to strstr as the offset argument of the eventual pwrite call, since the pointer was available in the dynamic buffer and all other direct calls needed fewer than four arguments. This turned out to be a bad idea. offset is where pwrite writes, which for /proc/self/mem is the address of the function to be overwritten with shellcode. strstr seemed perfect, but the finished exploit failed because getpid, munlock and several other frequently called functions sit immediately after it in libc and usually got called first, jumping into the middle of the shellcode. It was easier to copy a different function pointer with memcpy, and after testing __stack_chk_fail was chosen: it is not called during normal operation and the functions after it in libc are not used by the decoder. These frames use the same trick as for the strstr GOT copy to copy a pointer to __stack_chk_fail into direct_call_X3. This takes one round of the leak capability rather than two, because the pointer to the strstr GOT entry in direct_call_X1 could be partially overwritten to point to the __stack_chk_fail GOT entry, avoiding a second static buffer copy.
52_set_pc_back
Sets the direct call back to the ret gadget so memcpy stops being called.
54_write_skip, 56_write_x1_end_special and 58_write_x1_start_special
At the start the researcher believed shellcode execution would be possible without WRITE DYNAMIC once WRITE STATIC was unlocked. That was wrong: the plan missed that direct_call_X1 was set to the GOT at this point but needed to point to the dynamic buffer. Pointers into the dynamic buffer were already there from copying the static buffer, and the same trick could copy one to direct_call_X1, but the skip pointer would need to be moved and written to their address. The easiest path was to regain WRITE DYNAMIC.
This is a maths problem. The original WRITE DYNAMIC allocates many payloads to exhaust the heap, then triggers the overrun to alter the skip pointer; with payload_extra overwritten this fails because the overflow check fails when it is added to the payload size. But the bug does not need to be triggered once the heap length is overwritten, because the evo heap no longer accurately checks whether heap writes are out of bounds. The new WRITE DYNAMIC allocates exactly enough payloads that the pointer array plus the payload structures line up with the skip pointer, and the first payload's data overlaps the pointer and overwrites it. These frames use a series of WRITE DYNAMIC and WRITE DYNAMIC FAST calls to set direct_call_X1 to the dynamic buffer.
60_write_skip, 62_write_single_byte and 64_move_skip
The first two frames use DYNAMIC WRITE to overwrite the final byte of the strstr pointer so it is a multiple of 0x157 away from pwrite. The last moves the skip pointer elsewhere so the byte is not written twice.
66_write_index
The increment gadget will run many times and also increment index at entry 0 in DLB_CLqmf_analysisL. This frame sets it to zero so later increments do not cause out-of-bounds reads.
68_loop_count
Sets loop_count in entry 2 to 0x7B so the increment gadget runs the right number of times. DLB_CLqmf_analysisL runs twice, so the gadget runs 0xF6 times.
70_write_x1
direct_call_X1 points somewhere in the dynamic buffer; this frame makes it point exactly at the modified strstr pointer.
72_inc_157
Sets the direct function pointer to the increment gadget, called 0xf6 times, so the pointer in the dynamic buffer becomes pwrite.
74_set_pc_back
Sets the direct call pointer back to the ret gadget so incrementing stops.
76_set_malloc
The indirect pointer is still strstr, which is a problem while preparing pwrite arguments, because pwrite's first argument is a file handle (an integer) and would crash as strstr's first argument. This frame sets the indirect pointer to malloc, whose GOT entry is in range and which succeeds with a single integer argument.
78_write_x0
Writes direct_call_X0 with 40, the estimated handle for /proc/self/mem.
80_write_x1
Partially overwrites direct_call_X1 to point at the shellcode in the dynamic buffer.
82_write_x2
Writes direct_call_X2 with the integer length of the shellcode.
84_write_end_special and 86_write_start_special
Copy the pointer to pwrite into direct_call_fptr (entry 14) using the same method as other pointer copies from the dynamic buffer. pwrite is called immediately, overwriting __stack_chk_fail with the shellcode.
88_write_scf
Partially overwrites the indirect call register so it points to the GOT entry for _stack_chk_fail. __stack_chk_fail runs immediately, running the shellcode.
How reliable is this exploit?
Because of ASLR guessing, the attack works roughly 1 time in 255, with a second, smaller source of unreliability. There is one other source of unreliability. Occasionally, binder (the part of Android that passes messages between processes) performs a secondary allocation while the attack is running, in which case header checks fail and it crashes. This happens a lot with the debugger attached, but less than 10% of the time in normal operation.
Could it be made more reliable? The researcher has two ideas, both needing substantial work. To remove the 1 in 16 chance when guessing the dynamic buffer location, it might be possible to overwrite the second lowest byte of the previous pointer in the dynamic buffer allocation before the attack starts. As discussed, that causes the buffer to be reallocated at that address, moving the allocation to a consistent offset from dynamic_base before the attack runs.
Glossary
- 0-click attack: An attack that needs no action from the victim, triggered just by receiving data such as a message.
- AC-3 / EAC-3: The technical names for Dolby Digital and Dolby Digital Plus audio formats.
- Allocator: The part of a program that hands out blocks of memory on request.
- ASLR (Address Space Layout Randomisation): An operating system defence that loads code and data at randomised addresses each run, so attackers cannot rely on fixed addresses.
- Audio block: A small unit inside a syncframe that carries audio data and optional fields.
- Baps (bit allocation pointers): Values the decoder writes into memory while decoding audio blocks.
- Binder: Android's system for passing messages and data between processes.
- Bitstream: A stream of binary data read bit by bit, as audio files are.
- Buffer: A reserved block of memory used to hold data temporarily.
- Buffer overflow: Writing more data into a buffer than it can hold, spilling into neighbouring memory.
- CVE: A public identifier for a known security vulnerability.
- DD / DD+: Dolby Digital and Dolby Digital Plus, audio compression formats.
- dlopen: A function that loads a shared library at runtime.
- Dynamic buffer: In this decoder, an 85827-byte scratch area that contains the skip buffer.
- EMDF (Extensible Metadata Delivery Format): The metadata format carried in the skip buffer.
- EMDF container: The unit of EMDF data inside one syncframe, starting with the marker 'X8' and a length.
- Evo heap: The decoder's custom memory area for EMDF payloads, a single slab with one moving pointer and no freeing.
- execmem: Permission to make memory executable; the media process lacks it.
- File descriptor: A small number a program uses to refer to an open file.
- Function pointer: A variable holding the address of code to call.
- Gadget: A short sequence of existing instructions ending in a return, used in ROP.
- GOT (Global Offset Table): A table of addresses of external functions and data that a program uses at runtime.
- Guard page: A memory page marked inaccessible, placed next to important data so that overruns hit it and crash instead of corrupting things.
- Heap: The area of memory used for data whose size is only known at runtime.
- Heap header: Bookkeeping data an allocator stores next to each allocation.
- Integer overflow: A number growing too large for its fixed-size storage and wrapping around to a small value.
- Kernel: The core of the operating system, with the highest privileges.
- Leak capability: In this bug, the ability to read past the filled part of the skip buffer.
- libc: The standard C library providing common functions such as
fopenandmemcpy. - mediacodec: The Android process and context that handles media decoding.
- memcpy: A standard function that copies bytes from one memory location to another.
- mprotect: A function that changes the permissions of memory, for example making it executable.
- Nibble: Four bits, half a byte; here, one hexadecimal digit of an address.
- OEM: Original Equipment Manufacturer, a company that makes phones.
- Offset: A distance in bytes from a known starting point.
- Payload: A unit of data inside an EMDF container, with an identifier, a size and bytes.
- PLT (Procedure Linkage Table): A small stub a program uses to call external functions.
- Pointer: A variable holding a memory address.
- ProcFS: A virtual filesystem exposing process information;
/proc/self/memlets a process read and write its own memory. - Program counter (PC): The register holding the address of the next instruction to run.
- pwrite: A function that writes data to a file at a given position.
- RCS: Rich Communication Services, the newer messaging standard that supports media.
- ROP (Return-Oriented Programming): Building behaviour from existing code snippets that end in a return, when injecting new code is not possible.
- Sandbox: A restricted environment that limits what a process can do.
- Scudo: Android's memory allocator, which stores headers next to allocations.
- Secondary allocation: A large allocation that scudo handles separately from small ones.
- SELinux: Android's rule system controlling what each process may access.
- Shellcode: A small piece of machine code an attacker wants to run.
- Skip buffer: The buffer that holds the skip data (
skipfld) of a syncframe. - Skip pointer: The pointer the decoder uses to work out where to write skip data.
- SMS: The traditional text messaging standard.
- Static buffer: In this decoder, a 692855-byte area holding the decoder's main state, including the evo heap.
- strstr: A standard function that finds one string inside another.
- Syncframe: A self-contained chunk of a DD+ stream that can be decoded on its own.
- Syncword: A special marker ('X8' here) that tells the decoder where a container starts.
- Transcription: Turning speech in an audio file into text automatically.
- UDC (Dolby Unified Decoder): The library that decodes Dolby Digital and Dolby Digital Plus audio.
- variable_bits: A helper that reads a number of variable length from the bitstream, with no upper limit.
- WRITE DYNAMIC: The researcher's name for writing attacker data into the dynamic buffer by chaining syncframes.
- WRITE DYNAMIC FAST: A variant that writes data and moves the skip pointer in the same syncframe.
- WRITE STATIC: The researcher's name for writing to chosen offsets in the static buffer once the heap length and
payload_extraare controlled.