Android mediaserver exploit – heap thermal vision
Two vulnerabilities in Android's mediaserver audio policy service allowed an attacker to increment arbitrary memory and check whether memory locations are zero, enabling ASLR bypass and arbitrary code execution within the mediaserver process without any permissions.
bits-please.blogspot.com
Published on bits-please.blogspot.com
In this blog post we'll go over two vulnerabilities I discovered which, when combined, enable arbitrary code execution within the "mediaserver" process from any context, requiring no permissions whatsoever.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The audio policy service used a user-supplied stream index to access an array without validating it, allowing out-of-bounds read and write.
What the attacker needed
No permissions required; Android 2.2 or later; ability to call mediaserver APIs
The fix
The vulnerabilities were fixed in Android 5.1 by adding validation of the stream argument against the enumeration's minimal and maximal values.
How it was found
- Call startOutput with a valid output descriptor and a large stream value to increment memory at an offset.
- Call isStreamActive with a large stream value and inPastMs set to INT_MIN to check if memory at an offset is zero.
- Use the increment primitive to modify a function pointer in an audio_hw_device structure to point to a gadget.
- Trigger the modified function via AudioFlinger::getInputBufferSize to leak the audio_hw_device address.
- Use the read primitive to read function pointers from the audio_hw_device to learn library addresses.
- Hijack a function pointer to execute arbitrary code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The mediaserver process handles audio and other media tasks on Android. Two bugs in its audio policy service let an attacker change numbers in memory and check if memory contains zero, which is enough to find and hijack function pointers, leading to code execution without needing any app permissions.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.