Credit is owed to David Kaplan for this research.

The IBM X-Force Application Security Research Team has discovered a remote code execution (RCE) vulnerability in MIUI, which we privately disclosed to Xiaomi in January.

A New Flaw for Xiaomi

MIUI is the flavor of Android (currently based on Android 6.0) developed by Xiaomi. While developed primarily for use on Xiaomi’s own devices, MIUI builds are freely available for numerous devices from other vendors.

Xiaomi is currently the third-largest smartphone manufacturer in the world, behind Samsung and Apple, in terms of devices shipped. More than 70 million devices were delivered in 2015, and many millions of these may be impacted by this vulnerability.

The vulnerability we discovered allows for a man-in-the-middle (MitM) attacker to execute arbitrary code as the highly privileged Android system user. It has been remediated by Xiaomi from MIUI Global Stable version 7.2, and IBM strongly recommended that users update their firmware as soon as possible to ensure they are not vulnerable.

We would also like to commend Xiaomi’s security team for excellent incident response. Within days of disclosure, the vulnerability was confirmed and classified, and we were provided with details of when a fix would be delivered.

Inside the Remote Code Execution Process

IBM found a vulnerability that allowed an attacker to execute code on a target device via a MitM attack. This attack also involved code injection inside of the update framework. These attack vectors are not new and have been previously disclosed in other platforms.

The vulnerability resides in the analytics package, which is present in various applications that come with MIUI. All applications with the analytics package are vulnerable to remote code execution via MitM. We identified at least four vulnerable applications in the MIUI developer Rom version 6.1.8, including the built-in browser app. These had differing sets of privileges and capabilities.

An RCE vulnerability in any of these applications allows attacker-supplied code to run with the privileges of its host app. If a vulnerable application was found to be running as the system user, a good portion of the Android’s user space would be compromised. IBM identified such an app running as the system user and being vulnerable to code injection, which we then managed to successfully exploit in our lab.

Vulnerability Details

The vulnerability itself is conceptually straightforward. The analytics package polls a RESTful web service periodically to determine whether there is an update available. The server responds with the following short JSON response:

“force”: 0,

“md5”: “3238b0f5af9931fc73a43eb02a2ee528”,

“url”: “http://update.address/update.apk”,

“v”: “1.8.0”

The response is parsed to determine whether the current version is less than the version advertised in the update response. If so, the Android application package (APK) referred to by the URL key is downloaded and extracted to the file system within the local application sandbox context. This code is then loaded by the host application and executed.

The update transaction is performed over an insecure transport link such as HTTP. A MitM attack would allow a malicious user to inject a JSON response to force an update by replacing the URL and MD5 hash with those of a malicious APK containing arbitrary code. Since there is no cryptographic verification of the update code itself, the analytics package will replace itself with the attacker-supplied version via Android’s DexClassLoader mechanism.

Mitigating the Vulnerability

This class of vulnerability seems to be a recurring theme in the security community. To mitigate such vulnerabilities, developers should take care to only transact code-related data over a verified, secure transport with certificate pinning such as TLS. Additionally, the code itself should be cryptographically signed and properly verified by the host application prior to execution.

Furthermore, we believe that a discussion should take place as to whether any application should have the ability to execute unsigned code via DexClassLoader, dynamic library injection or any other method on the Android platform. The recurring incidents of what are essentially identical bugs might indicate that the platform should consider exerting a great level of control over such activities and change the default policy to block these actions.

More from Software Vulnerabilities

X-Force releases detection & response framework for managed file transfer software

5 min read - How AI can help defenders scale detection guidance for enterprise software tools If we look back at mass exploitation events that shook the security industry like Log4j, Atlassian, and Microsoft Exchange when these solutions were actively being exploited by attackers, the exploits may have been associated with a different CVE, but the detection and response guidance being released by the various security vendors had many similarities (e.g., Log4shell vs. Log4j2 vs. MOVEit vs. Spring4Shell vs. Microsoft Exchange vs. ProxyShell vs.…

MSMQ QueueJumper (RCE Vulnerability): An in-depth technical analysis

13 min read - The security updates released by Microsoft on April 11, 2023, addressed over 90 individual vulnerabilities. Of particular note was CVE-2023-21554, dubbed QueueJumper, a remote code execution vulnerability affecting the Microsoft Message Queueing (MSMQ) service. MSMQ is an optional Windows component that enables applications to exchange messages via message queues that are reachable both locally and remotely. This analysis was performed in collaboration with the Randori and X-Force Adversary Services teams, by Valentina Palmiotti, Fabius Watson, and Aaron Portnoy. Research motivations…

X-Force prevents zero day from going anywhere

8 min read - This blog was made possible through contributions from Fred Chidsey and Joseph Lozowski. The 2023 X-Force Threat Intelligence Index shows that vulnerability discovery has rapidly increased year-over-year and according to X-Force’s cumulative vulnerability and exploit database, only 3% of vulnerabilities are associated with a zero day. X-Force often observes zero-day exploitation on Internet-facing systems as a vector for initial access however, X-Force has also observed zero-day attacks leveraged by attackers to accomplish their goals and objectives after initial access was…

Topic updates

Get email updates and stay ahead of the latest threats to the security landscape, thought leadership and research.
Subscribe today