Full Report
Memory Tagging Extensions (MTE) is a memory corruption protection that was widely considered to be a killer of these types of bugs. The idea is to use the upper bits of a 64 bit pointer to give a random value to it. If the tag of the memory is different than the pointer being used, then a fault occurs, stopping the exploit. The author of this post bought a Pixel 8, enabled MTE then tried to find a vulnerability that would work around these protections. They ended up targeting the JIT memory of the Arm Mali GPU driver. When accessing a page that doesn't have a valid memory mapping, the GPU will increase the size of the space. However, there isn't proper locking when this occurs. So, a race condition allows for an invalid state to be created to cause pseudo-memory corruption. Using some black magic, it's possible to mess with the mappings of the JIT memory. In particular, a section of memory can be treated as unmapped, even though it really isn't. Since the section is freed, it can be allocated as a standard kernel memory allocation. Eventually, using some allocation magic, it's possible to get this memory to be used in the kernel (including kernel code) but still available to the GPU. Now, it's possible to rewrite the kernel from the GPU in order to compromise everything. So, how does this bypass MTE? Well, there's no memory corruption! The pages array in the kernel and the GPU mappings of the JIT are valid from a memory corruption perspective. Since these are accessing physical pages, the MTE protections are not in place. Overall, an interesting look into how some bugs do not care about MTE. The post goes too deep into the weeds of GPUs and kernel for me to understand but it's interesting to get the generic flow none-the-less.
Analysis Summary
# Vulnerability: Arm Mali GPU JIT Race Condition MTE Bypass
## CVE Details
- **CVE ID:** CVE-2023-6241
- **CVSS Score:** 8.8 (High) - *Based on typical local privilege escalation metrics for this driver.*
- **CWE:** CWE-362 (Race Condition), CWE-664 (Improper Control of a Resource Through its Lifetime)
## Affected Systems
- **Products:** Devices featuring Arm Mali GPUs with Command Stream Frontend (CSF) architecture.
- **Versions:** Arm Mali Driver versions prior to **r47p0**.
- **Configurations:** Google Pixel 7 and Pixel 8 series; specifically tested on Pixel 8 with Kernel Memory Tagging Extension (MTE) enabled.
## Vulnerability Description
The flaw is a logic-based race condition within the memory management unit of the Arm Mali GPU driver. Specifically, it involves the Just-In-Time (JIT) memory allocation mechanism.
When the GPU accesses a page without a valid mapping, it attempts to increase the address space. Due to improper locking during this operation, a race condition allows a "pseudo-memory corruption" state. An attacker can manipulate JIT memory mappings such that a section of memory is treated as "unmapped" and freed by the kernel, while the GPU retains a valid entry to the underlying physical pages. This allows a hardware-level "Use-After-Free" where the GPU can read/write to physical pages that the kernel has reclaimed for other purposes (such as kernel code or page tables).
## Exploitation
- **Status:** PoC demonstrated by GitHub Security Lab; successfully gains root and kernel code execution.
- **Complexity:** High (Requires precise timing and "allocation magic" to align GPU mappings with kernel structures).
- **Attack Vector:** Local (Malicious Android application).
## Impact
- **Confidentiality:** High (Total access to kernel memory).
- **Integrity:** High (Ability to rewrite kernel code and bypass MTE).
- **Availability:** High (Can cause system crashes or permanent state changes).
## Remediation
### Patches
- **Arm Mali Driver:** Update to version **r47p0** or later (Released Dec 14, 2023).
- **Android OS:** Apply the **March 2024 security update** or later.
### Workarounds
- No specific software workaround is available other than updating the driver/firmware. MTE does **not** mitigate this specific flaw because the GPU accesses physical memory directly, bypassing the CPU-based MTE tag checks.
## Detection
- **Indicators of compromise:** Unusual GPU memory pressure or patterns indicating JIT spray/exhaustion.
- **Detection methods:** Standard kernel integrity monitoring (like Samsung Knox or Google’s GKI protections) might detect the resulting kernel code modifications, though the initial exploit happens at a layer lower than CPU-based hardware protections.
## References
- **Vendor Advisory:** [Arm Security Center - Mali GPU Driver Vulnerabilities](https://developer.arm.com/Arm%20Security%20Center/Mali%20GPU%20Driver%20Vulnerabilities)
- **Technical Analysis:** [hXXps://github.blog/security/vulnerability-research/gaining-kernel-code-execution-on-an-mte-enabled-pixel-8/](https://github.blog/security/vulnerability-research/gaining-kernel-code-execution-on-an-mte-enabled-pixel-8/)
- **Android Bulletin:** [hXXps://source.android.com/docs/security/bulletin/2024-03-01](https://source.android.com/docs/security/bulletin/2024-03-01)