# Huawei Theme Manager Arbitrary Code Execution

DevFeed: [Huawei Theme Manager Arbitrary Code Execution](<https://devfeed.tech/articles/huawei-theme-manager-arbitrary-code-execution-92037.md>)

Original publisher: [Read original article](<https://blog.doyensec.com/2023/07/26/huawei-theme-arbitrary-code-exec.html>)

Published: 2023-07-25T22:00:00Z

Content type: article

Language: en

Sources: [Doyensec](<https://devfeed.tech/sources/doyensec.md>)

Topics: [huawei](<https://devfeed.tech/topics/huawei.md>), [execution](<https://devfeed.tech/topics/execution.md>), [APK](<https://devfeed.tech/topics/apk.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [apk](<https://devfeed.tech/tags/apk.md>), [auditing](<https://devfeed.tech/tags/auditing.md>), [automation](<https://devfeed.tech/tags/automation.md>), [bug-bounty](<https://devfeed.tech/tags/bug-bounty.md>), [bypass](<https://devfeed.tech/tags/bypass.md>), [code-execution](<https://devfeed.tech/tags/code-execution.md>), [doyensec](<https://devfeed.tech/tags/doyensec.md>), [doyensecurity](<https://devfeed.tech/tags/doyensecurity.md>), [exploit](<https://devfeed.tech/tags/exploit.md>), [hacking](<https://devfeed.tech/tags/hacking.md>), [huawei](<https://devfeed.tech/tags/huawei.md>), [infosec](<https://devfeed.tech/tags/infosec.md>), [java](<https://devfeed.tech/tags/java.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [offensive](<https://devfeed.tech/tags/offensive.md>), [pentest](<https://devfeed.tech/tags/pentest.md>), [pentester](<https://devfeed.tech/tags/pentester.md>), [research](<https://devfeed.tech/tags/research.md>), [reverse-engineering](<https://devfeed.tech/tags/reverse-engineering.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [security](<https://devfeed.tech/tags/security.md>), [system](<https://devfeed.tech/tags/system.md>), [themes](<https://devfeed.tech/tags/themes.md>), [vulnerability](<https://devfeed.tech/tags/vulnerability.md>)

## AI overview

The vulnerability stems from `com.huawei.ucdlockscreen` loading Java classes from a theme without validating their signatures. A crafted `.hwt` theme could therefore execute code in the highly privileged Huawei Theme Manager process, and testing reportedly yielded around 200 Android and Huawei permissions. Remote exploitation required the user to install a custom theme; Huawei's theme review process could limit malicious themes. The issue was confirmed on EMUI 9.1 and 10. The article says a 2022 update addressed it through `ucdlockscreen.apk` version 3 or later, but an attacker with physical access could replace that component with an older Huawei-signed version. Researchers also describe a theme-file bypass affecting latest EMUI 9.1 without physical access; other major EMUI versions appeared to have signature checks that mitigated it. The excerpt's central engineering lesson is to validate dynamically loaded code as well as the component that loads it.

## Source excerpt

Back in 2019, we were lucky enough to take part in the newly-launched Huawei mobile bug bounty. For that, we decided to research Huawei's Themes. The Themes Manager allows custom themes on EMUI devices to stylize preferences, and the customization of lock screens, wallpapers and icons. Processes capable of making these types of system-wide changes need to have elevated privileges, making them valuable targets for research as well as exploitation. Background When it comes to implementing a lockscreen on EMUI, there were three possible engines used: com.ibimuyu.lockscreen com.vlife.huawei.emuilock com.huawei.ucdlockscreen When installing a theme, the SystemUI.apk verifies the signature of the application attempting to make these changes against a hardcoded list of trusted ones. From what we observed, this process seems to have been implemented properly, with no clear way to bypass the signature checks. That said, we discovered that when com.huawei.ucdlockscreen was used, it loaded additional classes at runtime. The signatures of these classes were not validated properly, nor were they even checked. This presented an opportunity for us to introduce our own code. Taking a look at the structure of the theme archive files (.hwt), we see that the unlock screen elements are packaged as follows: Looking in the unlock directory, we saw the theme.xml file, which is a manifest specifying several properties. These settings included the dynamic unlock engine to use (ucdscreenlock in our case) and an ext.properties file, which allows for dynamic Java code loading from within the theme file. Let's look at the file content: This instructs the dynamic engine (com.huawei.ucdlockscreen) to load com.huawei.nova.ExtensionJarImpl at runtime from the NOVA6LockScreen2019120501.apk. Since this class is not validated, we can introduce our own code to achieve arbitrary code execution. What makes this even more interesting is that our code will run within a process of a highly privileged applic