QSEE privilege escalation vulnerability and exploit
A buffer overflow in the Widevine trustlet's diagnostic command allows overwriting session pointers and a command function pointer, enabling code execution within Qualcomm's Secure Execution Environment (QSEE). An attacker with code execution in the mediaserver process could exploit this to run arbitrary code in the secure world.
bits-please.blogspot.com
Published on bits-please.blogspot.com
In this blog post we'll discover and exploit a vulnerability which will allow us to gain code execution within Qualcomm's Secure Execution Environment (QSEE). I've responsibly disclosed this vulnerability to Google and it has been fixed - for the exact timeline, see the "Timeline" section below.
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
Likely a missing bounds check on the length of user-supplied data before copying it into a fixed-size global buffer in the diagnostic command handler.
Impact
An attacker with code execution in the mediaserver process could gain code execution within QSEE, potentially allowing them to modify the normal world kernel and bypass Android's security model.
What the attacker needed
Code execution in mediaserver process; ability to send commands to Widevine trustlet
The fix
The vulnerability was fixed by Google after responsible disclosure.
How it was found
- Send a crafted command to the Widevine trustlet with the diagnostic command code and a flag that selects the vulnerable code path.
- The trustlet copies the user-supplied data into a global buffer without checking the length, overflowing into adjacent memory.
- Use the overflow to overwrite session pointers to point within the secapp region, then probe memory to locate the trustlet's own data segment.
- Use the nonce-based write primitive to write arbitrary values to chosen memory locations.
- Overwrite a function pointer in the command dispatch table with the address of attacker-controlled code.
- Invoke the corresponding command to execute the code within QSEE.
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.
Qualcomm's Secure Execution Environment (QSEE) is a separate, highly protected part of a phone's processor that runs small programs called trustlets, which handle sensitive tasks like DRM decryption. The Widevine trustlet had a bug where a specially crafted command could overflow a buffer and overwrite nearby data, including pointers to session objects and a table of function pointers. By carefully manipulating these pointers, an attacker who already controls a media-related process could redirect execution to their own code inside the secure environment.
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.