Fastboot Oem Vuln: Android Bootloader Vulnerabilities in Vendor Customizations

Fastboot Oem Vuln: Android Bootloader Vulnerabilities in Vendor Customizations

fastboot oem vuln: Android Bootloader Vulnerabilities in Vendor Customizations Roee Hay Aleph Research, HCL Technologies Abstract dition to the main SoC, devices also have ad-hoc ICs (e.g. device sensors), each of which may contain its own We discuss the fastboot interface of the Android boot- firmware, oftentimes updatable over-the-air. loader, an area of fragmentation in Android devices. We Much room for fragmentation (and bugs), we decided then present a variety of vulnerabilities we have found to focus our research on one area, the fastboot inter- across multiple Android devices. Most notable ones in- face. clude Secure Boot & Device Locking bypasses in the Motorola and OnePlus 3/3T bootloaders. Another crit- ical flaw in OnePlus 3/3T enables easy attacks by ma- 2 Secure Boot & ABOOT licious chargers – the only prerequisite is a powered- off device to be connected. An unexpected attack vec- Android devices implement Secure Boot through a tor in Nexus 9 is also shown – malicious headphones. chain-of-trust, with a root certificate stored in hardware. Other discovered weaknesses allow for data exfiltration The first bootloader (PBL) verifies the authenticity of the (including a memory dumping of a Nexus 5X device), next one. The next bootloader verifies the one after and enablement of hidden functionality such as access to the so forth, until executions reaches ABOOT. Code flows device’s modem diagnostics and AT interfaces , and at- to ABOOT which verifies the authenticity of the boot tacks against internal System-on-Chips (SoCs) found on or recovery partitions (possibly with another key-pair), the Nexus 9 board. prepares the Linux kernel, Device Tree Blob (DTB) and initramfs archive in memory, and transfers execution to the Linux kernel. initramfs is a (gzipped) cpio 1 Introduction archive that gets populated into rootfs (a RAM file- system mounted at the root path [2]) during the Linux The code running in Android devices comes from multi- initialization. It contains init, the first user space ple sources. Top-down, we have the user space which process. Among its duties, init triggers the partition consists of the Android Open Source Project (AOSP), mounts. dm-verity then verifies the integrity of spec- oftentimes customized by the OEM. Then, we have the ified partitions under fstab (e.g. the system parti- Linux Kernel, which may also contain OEM customiza- tion). Since dm-verity uses a public-key stored un- tions and drivers for controlling and interacting with var- der rootfs (/verity key), an untrusted initramfs ious peripheral SoCs found on the device’s board. The means untrusted partitions that dm-verity verifies. See next level is a chain of bootloaders which either originate Figure 1 which depicts the chain-of-trust in Qualcomm from the OEM or the chipset manufacturer: At its low- MSM SoCs [3]. est level, we have in Boot ROM the Primary Bootloader Apart from the normal boot flow, ABOOT has another (PBL), which is written by the chipset manufacturer, and mode of operation – the fastboot mode, that gives de- then usually a series of bootloaders that end with the late- vice owners a way to interface with the bootloader, im- stage Android (Applications) Bootloader (ABOOT). The plementing features such as bootloader unlocking, lock- latter implements the fastboot interface (with a notable ing, flashing and other OEM extensions (which this re- absence in Samsung-branded devices), and is fully cus- search focuses on). Due to the fact ABOOT takes such a tomizable by the OEM. Not forgetting TrustZone, which critical part in the device’s boot, and runs before the OS provides security mechanisms (such as secure storage, (so TrustZone, for example, may have a different state), DRM, supporting Secure Boot and more [1]). In ad- discovered vulnerabilities may have a critical severity PBL flow. Second, adversaries with ADB access can reboot the device into the fastboot mode by issuing the adb SBL reboot bootloader command. ADB access requires ABOOT that the victim has enabled USB debugging on his Devel- opment Tools UI, and that an authorized the USB host is boot.img connected. This can happen, for example, when develop- ers use their own device for testing. PC malware await- Linux Kernel ing on their machine can then gain an ADB session and initramfs reboot into fastboot [9]. Another threat is malicious USB ports [10, 11] (e.g. malicious chargers at airports), target- system.img ing devices with an enabled-ADB. (Once connected, the victim has to authorize the charger.). vendor.img In addition to the bootloader flaws we have found and describe in this paper, we also discovered a Figure 1: Qualcomm MSM Chain-of-Trust (simplified) couple of critical “foot in the door” vulnerabilities (now patched) in Nexus 9 and OnePlus 3/3T, that re- lax the aforementioned requirements, allowing fast- too. From unauthorized access to SoCs on the device boot access by unauthorized malicious chargers (One- to bypassing Secure Boot and bootloader locking. In this Plus 3/3T, CVE-2017-5622) and headphones (Nexus 9, paper we will see a few good examples. CVE-2017-0510/0648). Charger Boot Mode ADB Access in OnePlus 3/3T When one connects a powered-off OnePlus 3/3T device 3 Bootloader Locking to a charger, the bootloader will load the platform with the charger boot mode. The platform OS must not en- Android devices have two states, locked, where OS in- able any sensitive USB interfaces because otherwise it tegrity is guaranteed through Secure / Verified Boot, and could easily be attacked by malicious USB ports. Much unlocked, where there is no security assurance. The abil- to our surprise, when we first connected our powered-off ity to transition between the states, backed by TrustZone, OnePlus 3/3T devices, running a vulnerable OxygenOS is up to the discretion of the OEM. Some devices always version, we noticed that we had ADB access. allow unlocking, some require an authorization code pro- Analysis showed that in the vulnerable versions of vided by the vendor, and some don’t. In any case, since OxygenOS some init script instruction started adbd the integrity guarantees are void when the device tran- when the platform ran in the charger boot mode sitions from the locked to unlocked states, according (Figure 2). The on charger event is triggered if to Google [4], bootloaders must adhere to the follow- ro.bootmode equals charger, as can be seen from ing guidelines: (1) Transitioning from the locked to un- AOSP’s init.cpp. Despite that, although ADB is run- locked states (and vice versa) requires the user’s consent ning, in order to protect against malicious USB ports (2) It yields a factory reset (i.e. losing user data). targeting devices with enabled adbd , Android has had One notable vulnerability [5, 6] in TrustZone had ADB authorization for quite some time (since Jelly-bean been discovered by Gal Beniamini, which was later used [12]) – any attempt to gain an ADB session with an unau- to defeat the Motorola Bootloader locking [7]. An- thorized host should be blocked. It turns out, however, other prominent device-locking related vulnerability was that OxygenOS of OnePlus 3/3T contains a customized found by Dan Rosenberg [8], again in Motorola Trust- adbd binary that disables authorization if the platform is Zone implementation. started in the charger boot mode (see Figure 3). The All vulnerabilities described in this paper assume the malicious charger can then use the open ADB session device is in the locked state. in order to reboot into fastboot, simply by issuing the reboot bootloader command. 4 Attacking fastboot Unauthorized Access to FIQ Debugger via Head- The fastboot interface can be triggered in various phones in Nexus 9 In Nexus 9, malicious headphones ways. First, a physical adversary can take leverage of can take leverage of the dual functionality of the head- the fact that in most Android devices, a key combina- phones jack, which, when a certain voltage threshold on tion upon boot will cause the bootloader to load the fast- the MIC pin is reached, turns that channel into a UART boot mode instead of commencing with the normal boot debug interface [13]. Although this normally results in on charger <hit enter to activate fiq debugger> debug> [...] debug> help mkdir /dev/usb-ffs/adb 0770 shell shell FIQ Debugger commands: mount functionfs adb /dev/usb-ffs/adb uid=2000, pc PC status gid=2000 regs Register dump write /sys/class/android_usb/android0/f_ffs/ allregs Extended Register dump aliases adb bt Stack trace setprop persist.sys.usb.config adb reboot [<c>] Reboot with command <c> setprop sys.usb.configfs 0 reset [<c>] Hard reset with command <c> setprop sys.usb.config adb irqs Interupt status [...] kmsg Kernel log version Kernel version sleep Allow sleep while in FIQ Figure 2: init.qcom.usb.rc: on charger init nosleep Disable sleep while in FIQ event handler of OnePlus 3/3T console Switch terminal to console cpu Current CPU cpu <number> Switch to CPU<number> ps Process list sysrq sysrq options __int64 sub_400994() sysrq <param> Execute sysrq with <param> { [...] getprop("ro.boot.mode", &v94, &byte_4D735C); Figure 4: Nexus 9 FIQ Debugger if ( !(unsigned int)strcmp(&v94, 'charger') ) auth_required_50E088 = 0; [...] debug> reboot oem-42 } debug> [...] ###[ Bootloader Mode ]### Figure 3: adb authorization bypass in OnePlus 3/3T hboot> ? #. <command> : <brief description> security_command: 1. boot : no desc. [...] 23. i2cr : no desc. Nexus and Pixel devices in bootloader and kernel debug 24. i2cw : no desc. messages (sometimes only when specifically enabled), in 25. i2crNoAddr : no desc. Nexus 9, the platform OS kernel also attaches the FIQ 26. i2cwNoAddr : no desc. 27. i2cdetect : no desc. debugger to that channel (Figure 4).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us