Android Kernel Security Analysis
Android Kernel Security Analysis
Abstract EF:
ET1 ET2 ET2
With the mobile phone market exceeding one billion units CVE root privileges
sold in 2023, ensuring the security of these devices is critical.
However, recent research has revealed worrying delays in Figure 1: The exploitation flow EF is a vulnerability-agnostic
the deployment of security-critical kernel patches, leaving chain of exploitation techniques ET, with one ET elevating a
devices vulnerable to publicly known one-day exploits. While primitive to a more powerful form [8]. EF leverages the capa-
the mainline Android kernel has seen an increase in defense bilities of a vulnerability to gain root privileges ultimately.
mechanisms, their integration and effectiveness in vendor-
supplied kernels are unknown at a large scale.
In this paper, we systematically analyze publicly available Despite the importance of mobile security, recent stud-
one-day exploits targeting the Android kernel over the past ies [13, 27, 43, 61, 67] have revealed that Android’s security-
three years. We identify multiple exploitation flows repre- critical kernel patches often lag significantly behind the main-
senting vulnerability-agnostic strategies to gain high privi- stream Linux kernel. In over 20 % of cases, delays exceed-
leges. We then demonstrate that integrating defense-in-depth ing one year occur [61], mainly due to the downstream ap-
mechanisms from the mainline Android kernel could mitigate proach of most Android vendors. This delayed deployment of
84.6 % of these exploitation flows. In a subsequent analysis of security-critical patches creates opportunities for malicious
994 devices, we reveal a widespread absence of effective de- actors to attack the Android Linux kernel. While these attacks
fenses across vendors. Depending on the vendor, only 28.8 % would be classified as one-day exploits due to the known na-
to 54.6 % of exploitation flows are mitigated, indicating a ture of their vulnerabilities, they effectively function as zero-
4.62 to 2.951 times worse scenario than the mainline kernel. day exploits during the extensive unpatched period. The sever-
Further delving into defense mechanisms, we reveal weak- ity of this situation is underscored by findings from Google
nesses in vendor-specific defenses and advanced exploitation Project Zero [9, 49] and Threat Analysis Group [50], which
techniques bypassing defense implementations. As these de- highlight a prevalence of exploits in the wild targeting these
velopments pose additional threats, we discuss potential solu- unpatched vulnerabilities in the Android kernel.
tions. Lastly, we discuss factors contributing to the absence On the defensive side, the mainline Android kernel has
of effective defenses and offer improvement recommenda- seen an increase in vulnerability-agnostic defenses preventing
tions. We envision that our findings will guide the inclusion one-day exploits. While these defense-in-depth mechanisms
of effective defenses, ultimately enhancing Android security. may be readily available, their integration and effectiveness
in vendor-supplied kernels are unknown. Consider, for exam-
ple, the case of the Pegasus spyware. Using BadBinder, an
1 Introduction exploit [46] known since 2019, malicious actors can infect
target devices with their payload. While an effective defense
Over the past decade, the mobile phone market has reached
has been available for over 10 years [47], its rollout status
an all-time high, with more than one billion units sold in 2023.
in vendor-provided kernels is entirely opaque. The question-
Given our daily reliance on mobile phones for communication,
able deployment or absence of such defenses leaves devices
financial transactions, and personal data storage, this surge
vulnerable to one-day exploitation flows (see Figure 1), thus
in device adoption underscores the critical need for robust
creating a significant security gap in the Android ecosystem.
security measures protecting these devices.
Malicious actors can exploit this and mount attacks against
1 Factors 1−0.288 1−0.546
of 1−0.846 and 1−0.846 , respectively. insufficiently protected devices based on public exploits.
Search for Identify Techniques Identify defenses preventing Availability for Advancement in two
Exploit collector exploitation techniques
one-day exploits exploit flow classification kernel versions
exploitation techniques
One-Day Exploit Collection Exploit Analysis Defense Identification (see 5.2.3 and 5.2.4).
Weaknesses in
custom defenses
(see 5.2.5 and 5.2.6).
Kernel source
code
Metadata
Factors potentially
Identified Inclusion and
Web crawler Kernel collector storage contributing to this
Firmware image devices effectiveness
Android Kernel Collection Metadata Extraction Defense Analysis situation (see 6).
Figure 2: The high-level workflow of our study where indicates fully automated and indicates mostly automated.
1533 kernel source codes. Our analysis reveals that a signifi- lection consists of one-days exploiting memory safety vul-
cant portion of the analyzed device firmwares lacks multiple nerabilities, as the Android kernel has established defenses
defenses, and some of the defenses are flawed, leaving de- to prevent their exploitation. By including other vulnerabili-
vices vulnerable to multiple of the one-day exploitation flows ties, such as logical (e.g., CVE-2022-22706) and GPU (e.g.,
analyzed in our one-day exploitation analysis. CVE-2023-33107) flaws, we expect that the susceptibility
Our analysis reveals four Novel Findings. First, we reveal to one-day exploits increases as the mainline Android ker-
the widespread absence (see Section 5.3.1) of included and nel does not yet effectively mitigate them. Our study spans
effective defenses against one-day exploitation flows across the last 3 years, from 2020 to November 2023. This aligns
vendors. Second, we demonstrate advancements in two ex- with Google Project Zero’s efforts to track zero-day exploits
ploitation techniques (see Sections 5.2.3 and 5.2.4). While targeting Android devices. Earlier public exploits are less
these advancements enable bypassing the defense intended documented, so we focus on this more recent timeframe [48].
against the base techniques, we discuss potential solutions.
Third, we uncover 4 and 2 weaknesses (see Sections 5.2.5
and 5.2.6) in Samsung’s and Huawei’s custom defense, respec- 4.1 Identified Exploitation Techniques
tively. Lastly, we discuss (see Section 6) factors potentially We observe that most one-day exploits have distinct exploita-
contributing to the absence of effective defenses and offer tion flows to convert one or more memory safety vulnerabili-
improvement recommendations. ties into either an arbitrary read-and-write primitive or code
modification (see Table 1). By examining these exploitation
4 One-Day Exploitation Analysis flows, we identify 10 exploitation techniques.
We refer to an exploitation technique as a strategy for turn-
In this section, we elaborate on our systematic analysis of all ing one exploitation primitive into a more powerful one, with
publicly available one-day exploits targeting memory safety examples of primitives being n-byte OOB write, UAF write,
vulnerabilities in the Android Linux kernel over the past three program counter control, or arbitrary read and write. We clas-
years. We identify and examine 26 exploits, demonstrating sify exploitation techniques based on strategies that recur over
that their exploitation flow uses one or more of the 10 exploita- multiple one-days and are reasonably generic [8]. An example
tion techniques outlined in Section 4.1. These techniques fol- of a technique is control-flow hijacking, which turns program
low a generic strategy for transforming an exploit primitive counter control into code execution and is used by multiple
into a more powerful one. In Section 4.2, we demonstrate that one-days. Another example is the unlink operation, which
defense-in-depth mechanisms present in the Android kernel may turn an OOB or UAF write of a double-linked list into a
v6.1 can mitigate 22 (i.e., 84.6 %) one-day exploitation flows. once-triggerable write or read primitive.
Lastly, Section 4.3 demonstrates that the remaining 4 one-day ET1: Unlink Operation. By exploiting a vulnerability,
exploits either exploit substantially powerful vulnerabilities or an adversary ensures that a victim object resides in the same
can be mitigated by a defense currently in development [44]. memory slot as a double-linked list, i.e., list_head with
One-Day Exploits. We obtained 26 one-day exploits (see next and prev (see Listing 1). The adversary then initiates
Table 1) from public sources, e.g., Google Project Zero [49], the unlinking via list_del, resulting in a write to the victim
Blackhat [35], Github [41], or other websites [58]. Our se- object. The one-days CVE-2019-2215, CVE-2019-2025, and
1 struct list_head { 1 struct binder_thread { 1 u64 access_ok(const void __user *addr, u64 size) {
2 struct list_head *next; 2 struct list_head wait; 2 return (u64)((u65)addr + (u65)size <= (u65)current->
3 struct list_head *prev; 3 struct task_struct *task; addr_limit + 1);
4 }; 4 }; 3 }
5 /* Unlinks element e */ 5 void remove_wait_queue( 4 u64 copy_from_user(void *to, const void __user *from, u64 n) {
6 void list_del(list_head *e) { binder_thread *bt) { 5 u64 res = n;
7 e->next->prev = e->prev; 6 /* Trigger unlinking */ 6 if (access_ok(from, n))
8 e->prev->next = e->next; 7 list_del(&bt->wait); 7 res = raw_copy_from_user(to, from, n);
9 } 8 } 8 return res;
9 }
Listing 1: Unlinking operation. Listing 2: Trigger unlinking.
Listing 3: Userspace data copy function validates with
access_ok whether addr refers to userspace memory.
iovec array
binder_thread_1 binder_thread_2 ① binder_thread_1 binder_thread_2 ②
wait: wait: wait: wait:
next next next next iov_len
prev prev prev prev iov_base
CVE ² ⋔ / ® Ó
CVE-2019-2215 ✓ ✗ ✓ ✓
Figure 6: Dirty PageTable: With an arbitrary page table level CVE-2019-2025 ✓ ✓
2 write capability, an attacker tampers the D_Page_M entry to CVE-2020-0030 ✓ ✗ ✓ ✓
refer to an arbitrary page as writable and user accessible. CVE-2021-1968,-1969,-1940 ✓ ✓ ✗
CVE-2021-0920 ✓ ✓
CVE-2021-1905 ✓ ✓ ✗
CVE-2022-22265 ✓
capabilities (e.g., signalfd_ctx for CVE-2023-21400) to CVE-2021-25369,-25370 ✗ ✓ ✗ ✗ ✓
CVE-2016-3809,-2021-0399 ✓ ✓ ✓ ✗
reside in the same memory slot as a page table used for user CVE-2022-20409 ✓
address translation. Figure 6 shows this, where an adversary CVE-2023-21400 ✓ ✶ ✗
CVE-2022-28350 ✶ ✗
has an arbitrary overwrite to the page-table entry D_Page_M CVE-2020-29661 ✶ ✗
due to the cross-cache attack. By triggering the overwrite, CVE-2021-22600 ✓
CVE-2020-0423 ✓ ✗ ✓ ✓
they gain control over the page frame number of this entry. CVE-2022-22057 ✓ ✗ ✓ ✓
Reading or writing to the user address using this page-table CVE-2023-26083,-0266 ✗ ✗
CVE-2020-0041 ✓ ✓
entry gives them arbitrary physical memory access. CVE-2019-2205 ✓ ✓
ET9: DirtyPipe. The DirtyPipe attack [30] exploits an CVE-2019-2025 ✓ ✓ ✗ ✓ ✓
uninitialized variable to escalate privileges. The CVE-2022- CVE-2020-3680 ✓ ✓ ✗ ✓ ✓
CVE-2022-20421 ✓
0847 vulnerability allows to use the pipe_buffer.flags CVE-2022-0847 ✓
variable uninitialized. Consequently, this vulnerability allows CVE-2021-4154
CVE-2021-38001 ✓ ✓ ✗
overwriting of any file contents in the page cache, also in the NO_NUMBER (∼2021) ✓ ✓
case of read-only files, which results in privilege escalation. ² DM1: CONFIG_DEBUG_LIST DM2: CONFIG_ARM64_UAO DM3: kmalloc-cg-*
⋔ DM4: CONFIG_CFI_CLANG / DM5: CONFIG_BPF_JIT_ALWAYS_ON
ET10: DirtyCred. The DirtyCred exploit [34] allows an ® DM6: CONFIG_SLAB_FREELIST_HARDENED DM7: CONFIG_INIT_ON_ALLOC_DEFAULT_ON
DM8: KSMA protection Ó DM9: Samsung RKP DM10: Huawei HKIP
attacker to escalate privileges. It exploits a file UAF to free
a writable file currently in use. Prior to this invalid free, it
performs a write operation to the file and stalls this write DM3: kmalloc-cg-*. Linux kernels above v5.13 sup-
operation. After the free, it reclaims the file object for a read- port heap segregation at the allocator cache level. It separates
only high-privilege file. Continuing the stalled write operation caches to provide a designated cache for security-critical data
now writes to the read-only high-privilege file. With this file marked as accounted, such as for msg_msg, pipe_buffer,
manipulation, DirtyCred can, e.g., overwrite a kernel module file, and task_struct. For generic caches, a cache for
with malicious code to construct an arbitrary read and write. non-security-critical data (i.e., kmalloc-*) and a cache for
security-critical data (i.e., kmalloc-cg-*) are created. Free
and available cached objects will never share the same mem-
4.2 Defenses to Prevent Exploitation Flows
ory slots within these caches. Hence, this mitigates the
We identify 10 defense-in-depth mechanisms present in the pipe_buffer overwrite (ET3) and unlink operation (ET1
Android kernel v6.1 or provided by vendors. They prevent with security-critical objects), as these techniques rely on
exploitation techniques and, hence, exploitation flows, with security-critical and non-security-critical data sharing the
the findings shown in Table 1 and detailed in Table 2. same memory slot. While adversaries might consider cross-
DM1: CONFIG_DEBUG_LIST. This defense includes cache attacks, three challenges arise with this approach, mak-
checks in del_list whether e->next->prev == e and ing the transition infeasible. First, for generic caches, the
e->prev->next == e. If these checks fail, the entry will success rate significantly decreases to 40 % [60], with failure
not be unlinked. Thus, it mitigates the unlink operation (ET1). scenarios potentially resulting in a crash. The small success
In Figure 3, for instance, overwriting from step ② to ③ is rate makes this approach impractical since the cross-cache
prevented as iovec->iov_base is not equal to bt1.wait. reuse only pertains to a small part of the exploit and may need
DM2: CONFIG_ARM64_UAO. User-Access Over- multiple repetitions. Second, exploits that engage in cross-
ride (UAO) [9] is a hardware-enforced defense that aims cache attacks typically rely on prior in-cache reuse attacks
to mitigate addr_limit overwrite (ET2). It introduces to stabilize the exploit. For instance, CVE-2022-22265 sta-
new unprivileged load and store instructions that behave bilizes by in-cache reallocating the double-freed slot of the
like privileged ones when the UAO bit is set. This restricts pipe_buffer as an iovec multiple times. Separating the
user-data copy functions, e.g., copy_*_user, from being pipe_buffer from objects intended for stabilizing, such as
misused to read from or write to kernel addresses directly. iovec, makes the exploit unstable, mostly resulting in a crash,
Level 0
Android 13, 12, 11, 10 and 9, being 25.7 %, 21.3 %, 17.3 %, D_Table_1
read-only
gible market share at the moment, is also considered.
② 4 kiB Page
We decided to start with phones released in November Level 3
Level 2
2018 (5 years from the start of this work), as the lifespan of kernel pgd
Level 1 D_Page
Android phones is 4-6 years (4y for Huawei, 5y for Google, Level 0
D_Table_1
D_Table_2
1 GiB Page
and 6y for Samsung) [17, 54]. Hence, our selection ensures a D_Table_M ❷
D_Block_M
writable kernel code
❸ user/kernel accessible
comprehensive overview of the current device landscape. ❶ writable
5.2.1 Mainline Defenses in Downstreamed Kernels 5.2.3 Advanced Kernel-Space Mirroring Attack
7 of the 8 mainline defense mechanisms are intrinsically tied Despite the KSMA mitigation patch, we present an advance-
to the core functionality of the Android kernel: ment in reenabling KSMA. Its prerequisite is the same con-
• Associating specific defenses with versions (i.e., DM3). straint write capability as the base KSMA (ET8), but it uses
• Not compiling dangerous functions (i.e., DM5). it twice: First, it changes the mapping of the level 0 PGD
• Replacing non-hardened with hardened functions (i.e., to writable, and second, it maliciously inserts the page-table
DM1/4/6/7/8). entry into the PGD. For a 48 bit VA_SIZE system with 4-level
For example, CONFIG_DEBUG_LIST (DM1) uses the hard- translation, our technique triggers the write three times, as
ened function __list_add_valid to validate metadata depicted before ① and after ② the attack in Figure 7. The
in double-linked lists. Another example is kmalloc-cg-* first write changes the PGD mapping to writable ❶, while the
(DM3), which utilizes a segregated set of allocator caches second changes the PGD entry to user accessible ❷. The third
for kernel versions 5.13 and above. The exception is write inserts then the entry ❸ in the page-table level 1.
lsy f
n
g
e
kal el.el
.bi
m
① ② ③
war
ms
t.i
Experiments. For the first weakness, we use the same
nel
Kernel ELF &
Firm
n
boo
ker
ker
setup as for our advanced KSMA technique and overwrite Boot Image Kernel Binary Symbols
Extraction Extraction Conversion
unprotected page-table pages to perform KSMA. We then
implement POCs for the other weaknesses on a Samsung
Galaxy S20 FE, where we modify the kernel code to obtain Figure 8: Workflow of extracting kernel.elf and kallsyms
the corresponding primitive. For the second weakness, we from the firmware, required for the defense detection.
use the introduced write primitive for a page table used for a
userspace address translation to successfully perform Dirty
PageTable. For the third weakness, we demonstrate that we detection. It first extracts the boot image ① using open-source
can drain the protected pages with memory exhaustion. We tools, which requires different tools [22, 31, 32, 51, 55] as ven-
then prompt the kernel to allocate a page that should be pro- dors encode the boot image differently. It then extracts the
tected, but this is not due to memory exhaustion. For the fourth kernel binary ② using unpack_bootimg [35]. Lastly, it uses
weakness, we demonstrate that RKP does not mitigate control- kallsyms_finder and vmlinux_to_elf to reconstruct the
flow hijacking to arbitrary functions. As a result, control-flow symbols (i.e., kallsyms) and convert the kernel binary to an
protection does not prevent the 6 CFH attacks we analyzed. analyzable ELF (i.e., kernel.elf) ③ [40].
The kallsyms and kernel.elf components form the ba-
sis of defense detection. Our Python script uses kallsyms to
5.2.6 Huawei HKIP Weaknesses
identify global functions within the kernel binary, allowing
We examine Huawei’s HKIP [25], particularly regarding the us to deduce the active defense mechanisms. The presence of
protection against KSMA and Dirty PageTable. __list_add_valid in kallsyms, for instance, indicates the
Analysis. We observe that HKIP is only included in cer- status of CONFIG_DEBUG_LIST (DM1). Our script does simi-
tain devices and enabled in about 62 %. In the following, we lar assessments for other defenses (see Table 3). It uses the
analyze HKIP and experimentally demonstrate the absence kernel.elf to determine the status of KSMA protection
of protection for crucial page-table pages. (DM8) and CONFIG_SLAB_FREELIST_HARDENED (DM6).
Findings. First, HKIP protects page-table pages that For KSMA protection, all PGDs (e.g., swapper_pg_dir)
are allocated for kernel address translations (e.g., via must be mapped in a read-only section. The presence of
pte_alloc_one) in a specific virtual address range. As a re- calling get_random_long within __kmem_cache_create
sult, HKIP does not protect page tables for userspace address indicates the status of CONFIG_SLAB_FREELIST_HARDENED.
translations, leaving devices vulnerable to Dirty PageTable. Our evaluation also includes five features for system
Second, while HKIP protects the ttbr (hardware register security; KASLR (CONFIG_RANDOMIZE_BASE), code write
that stores the current PGD for address translation) switch, protection (CONFIG_STRICT_KERNEL_RWX), freelist random-
it may not be compatible with frequent ttbr switching de- ization (CONFIG_SLAB_FREELIST_RANDOM), restricting user
fenses, i.e., software PAN (CONFIG_ARM64_SW_TTBR0_PAN) access in kernel (CONFIG_ARM64_(SW_TTBR0_)PAN), and
switches the ttbr for each copy_*_user and Meltdown pro- Meltdown protection (CONFIG_UNMAP_KERNEL_AT_EL0).
tection (CONFIG_UNMAP_KERNEL_AT_EL0) for each user ker- Evaluated Firmwares. Out of the 1698 released and 1109
nel switch. No device has HKIP with either one of these two collected devices, our analysis extracted 994 firmwares, re-
enabled, leaving these devices vulnerable to KSMA. sulting in a collection rate of 58.5 %, which aligns with prior
Experiments. We could not run experiments with the work on reverse engineering firmwares [11, 14, 64].
Huawei kernel source codes as they either had compilation Due to the unavailability of certain firmwares, our analysis
errors, no defconfig (e.g., ranchu64) viable for virtual en- could not cover all released devices. However, we observed
vironments or failed to boot in QEMU. Therefore, we adapted that the missing firmwares are distributed either normally
a Google kernel v4.14 to tag pages that HKIP would have regarding device age, such as those from Huawei and Vivo,
protected. For our page-table manipulation attacks, we ex- or tailored to older devices, as seen with Xiaomi and Realme.
perimentally observed that HKIP does not protect page-table Given our finding that older devices tend to include fewer
pages that KSMA and Dirty PageTable manipulate. defenses, our analysis provides conservative results. Thus, we
anticipate the real-world scenario to be even more concerning.
5.3 Analysis of Firmwares
5.3.1 Analysis Results
This work refers to the firmware as the stock ROM, the origi-
nal software loaded onto the device by the vendor. It consists We fully automate the detection of included defenses. Table 5
of multiple images [4], such as the system and boot image. presents the defenses included for each vendor’s firmwares.
Figure 8 shows the automated workflow of our implemented Our results indicate a lack of basic defenses (e.g., PAN and
Python script, extracting the necessary metadata for defense KASLR) and a significant lack of defenses against one-day ex-
① 1 Google 6 Samsung
2 Realme 7 Motorola
3 OnePlus 8 Huawei
❶ 4 Xiaomi 9 Oppo
5 Vivo 10 Fairphone
②
(a) Ground truth (b) Ranking
Xiaomi nan% nan% 0.7% 4.9% 88.1% 5.6% 0.7% nan% nan% nan% Samsung nan 26.0 25.5 23.3 19.8 15.2 7.9 7.2 2.3 nan
80%
Oppo nan% 5.3% 6.1% 21.1% 25.4% 28.9% 10.5% 2.6% nan% nan% Xiaomi nan nan 26.0 26.0 12.1 16.1 12.0 nan nan nan 20
Vivo 3.5% 1.4% 3.5% 14.6% 29.9% 26.4% 7.6% 8.3% 2.1% 2.8% Oppo nan 26.0 26.0 26.0 18.2 13.0 12.0 10.0 nan nan
60% Vivo 22.0 26.0 26.0 25.1 15.2 12.8 12.0 10.0 4.0 4.0 15
Realme nan% nan% nan% 5.9% 44.4% 27.4% 14.1% 5.9% 2.2% nan%
Realme nan nan nan 26.0 12.6 11.2 10.9 10.0 4.0 nan
Huawei 1.7% 1.7% 7.6% 13.4% 55.5% 5.9% 8.4% 5.9% nan% nan%
40% Huawei 22.0 26.0 24.4 21.1 15.7 12.0 21.0 10.0 nan nan
10
Motorola nan% 2.9% 9.6% 10.6% 21.2% 26.9% 14.4% 13.5% 1.0% nan%
Motorola nan 26.0 26.0 26.0 18.2 13.1 11.9 10.0 4.0 nan
Google nan% nan% nan% 11.5% 11.5% 11.5% nan% 57.7% 7.7% nan%
Google nan nan nan 22.0 12.0 12.0 nan 10.0 4.0 nan
20% 5
Oneplus nan% nan% nan% 4.8% 16.7% 23.8% 21.4% 23.8% 7.1% 2.4%
Oneplus nan nan nan 26.0 14.3 14.4 12.0 10.0 4.0 4.0
Fairphone nan% nan% nan% 33.3% nan% 33.3% 33.3% nan% nan% nan% Fairphone nan nan nan 26.0 nan 10.0 12.0 nan nan nan
0% 0
.10
.18
.4
.9
.14
.19
.4
.10
.15
.1
.10
.18
.4
.9
.14
.19
.4
.10
.15
.1
v4
v4
v5
v6
v4
v4
v5
v6
v3
v3
v4
v4
v5
v5
v3
v3
v4
v4
v5
v5
Figure 11: Applied Android kernel versions for each vendor. Figure 12: Susceptible exploitation flows per version/vendor.
[1] Martín Abadi, Mihai Budiu, Ulfar Erlingsson, and Jay [14] Andrei Costin, Jonas Zaddach, Aurélien Francillon, and
Ligatti. Control-Flow Integrity. In CCS, 2005. Davide Balzarotti. A large-scale analysis of the security
of embedded firmwares. In USENIX Security, 2014.
[2] Al Viro. iov_iter: saner checks on copyin/copyout, 2017.
[15] Samsung Knox Documentation. Real-time Ker-
URL: https://git.kernel.org/pub/scm/linux/
nel Protection (RKP), 2023. URL: https:
kernel/git/torvalds/linux.git/commit/?id=
//docs.samsungknox.com/admin/fundamentals/
09fc68dc66f7597bdc8898c991609a48f061bed5.
whitepaper/core-platform-security/real-
[3] Android. Kernel Control Flow Integrity, 2022. URL: time-kernel-protection/.
https://source.android.com/docs/security/ [16] Zeinab El-Rewini and Yousra Aafer. Dissecting residual
test/kcfi. apis in custom android roms. In CCS, 2021.
[4] Android. Overview, 2024. URL: https:// [17] Everphone. What is the average smartphone lifespan?,
source.android.com/docs/core/architecture/ 2023. URL: https://web.archive.org/web/
partitions. 20231123081219/https://everphone.com/en/
blog/smartphone-lifespan/.
[5] AppBrain. Top Android OS versions, 2023. accessed:
28.11.2023. URL: https://web.archive.org/web/ [18] Sadegh Farhang, Mehmet Bahadir Kirdan, Aron Laszka,
20231128122419/https://www.appbrain.com/ and Jens Grossklags. An empirical study of android
stats/top-android-sdk-versions. security bulletins in different vendors. In WWW, 2020.
[6] AppBrain. Top manufacturers, 2023. accessed: [19] Qian Feng, Rundong Zhou, Chengcheng Xu, Yao Cheng,
14.09.2023. URL: https://web.archive.org/web/ Brian Testa, and Heng Yin. Scalable Graph-based Bug
20230915054021/https://www.appbrain.com/ Search for Firmware Images. In CCS, 2016.
stats/top-manufacturers.
[20] Julien Gamba, Mohammed Rashed, Abbas Razagh-
[7] Brandon Azad. An iOS hacker tries panah, Juan Tapiador, and Narseo Vallina-Rodriguez.
Android, 2020. URL: https:// An analysis of pre-installed android software. In S&P,
googleprojectzero.blogspot.com/2020/12/ 2020.
an-ios-hacker-tries-android.html. [21] Daniel Gruss, Moritz Lipp, Michael Schwarz, Richard
Fellner, Clémentine Maurice, and Stefan Mangard.
[8] Brandon Azad. A survey of recent ios
KASLR is Dead: Long Live KASLR. In ESSoS, 2017.
kernel exploits, 2020. URL: https://
googleprojectzero.blogspot.com/2020/06/a- [22] Hemanth. Extractor of SpreadTrum firmware files with
survey-of-recent-ios-kernel-exploits.html. extension pac, 2023. URL: https://github.com/
HemanthJabalpuri/pacextractor.
[9] Ian Beer. Mind the Gap, 2022. URL: https://
googleprojectzero.blogspot.com/2022/11/. [23] Grant Hernandez, Dave Jing Tian, Anurag Swarnim Ya-
dav, Byron J. Williams, and Kevin R. B. Butler. Bigmac:
[10] Erik Buchanan, Ryan Roemer, Hovav Shacham, and fine-grained policy analysis of android firmware. In
Stefan Savage. When Good Instructions Go Bad: Gener- USENIX Security, 2020.
alizing Return-Oriented Programming to RISC. In ACM
Conference on Computer and Communications Security [24] Qinsheng Hou, Wenrui Diao, Yanhao Wang, Xiaofeng
(CCS), 2008. Liu, Song Liu, Lingyun Ying, Shanqing Guo, Yuanzhi
Li, Meining Nie, and Haixin Duan. Large-scale secu-
[11] Daming D Chen, Maverick Woo, David Brumley, and rity measurements on the android firmware ecosystem.
Manuel Egele. Towards automated dynamic analysis In International Conference on Software Engineering
for linux-based embedded firmware. In NDSS, 2016. (ICSE), 2022.
[32] Bjoern Kerler. oppo_decrypt, 2023. URL: https:// [45] Seth Jenkins. Exploiting CVE-2022-42703 -
github.com/bkerler/oppo_decrypt. Bringing back the stack attack, 2022. URL:
https://googleprojectzero.blogspot.com/
[33] Zhenpeng Lin. How AUTOSLAB Changes 2022/12/exploiting-CVE-2022-42703-
the Memory Unsafety Game, 2021. URL: bringing-back-the-stack-attack.html.
https://grsecurity.net/how_autoslab_
changes_the_memory_unsafety_game. [46] Maddie Stone. Bad Binder: Android In-
The-Wild Exploit, 2019. URL: https:
[34] Zhenpeng Lin, Yuhang Wu, and Xinyu Xing. DirtyCred: //googleprojectzero.blogspot.com/2019/11/
Escalating Privilege in Linux Kernel. In ACM, 2022. bad-binder-android-in-wild-exploit.html.
[35] Zhenpeng Lin, Xinyu Xing, Zhaofeng Chen, and Kang [47] Maddie Stone. CONFIG_DEBUG_LIST=y, 2020.
Li. Bad io_uring: A New Era of Rooting for Android, URL: https://twitter.com/maddiestone/
2023. URL: https://i.blackhat.com/BH-US-23/ status/1245834936629616640?lang=de.
Presentations/US-23-Lin-bad_io_uring.pdf.
[48] Maddie Stone. Detection Deficit: A Year in Review
[36] Linux Kernel Driver DataBase. CON- of 0-days Used In-The-Wild in 2019, 2020. URL:
FIG_ARM64_UAO: Enable support for User Access https://googleprojectzero.blogspot.com/
Override (UAO), 2024. URL: https://cateee.net/ 2020/07/detection-deficit-year-in-review-
lkddb/web-lkddb/ARM64_UAO.html. of-0.html.
[37] Kangjie Lu, Marie-Therese Walter, David Pfaff, Ste- [49] Maddie Stone. 2022 0-day In-the-Wild
fan Nümberger, Wenke Lee, and Michael Backes. Un- Exploitation...so far, 2023. URL: https:
leashing Use-Before-Initialization Vulnerabilities in the //googleprojectzero.blogspot.com/2022/
Linux Kernel Using Targeted Stack Spraying. In NDSS, 06/2022-0-day-in-wild-exploitationso-
2017. far.html.
Table 4: Statistical results of firmware extraction and kernel Table 5: Included defenses averaged over all firmwares for
code collection. each vendor. ✶ inidcates that it is ineffective while ✩ indicates
that it is ineffective for kernels <v5.11.
Vendors Firmware Extraction Kernel Code
#devices #available #extracted #collected Vendor ² / ⋔ ✩ ® ✶ ¥ © ç Ó
Samsung 197 190 164 654 Samsung 60 49 26 8 63 96 25 5 84 100 91 27 16 39
Xiaomi 278 151 143 188 Xiaomi 89 94 74 0 93 98 10 1 97 100 97 10 83
Oppo 229 145 114 29 Oppo 50 49 19 0 44 95 37 13 91 100 95 49 14
Vivo 69 65 27 5 67 96 44 22 95 98 88 73 22
Vivo 307 178 144 30 Realme 91 91 34 2 89 100 36 22 100 100 99 47 44
Realme 307 137 135 135 Huawei 15 18 67 0 20 92 12 13 97 100 79 87 14 62
Huawei 182 121 119 218 Motorola 62 58 34 1 59 90 44 29 89 100 79 58 31
Motorola 115 112 104 246 Google 88 88 100 8 88 100 65 65 100 100 100 77 65
Oneplus 83 83 52 10 83 100 69 55 100 100 100 90 55
Google 26 26 26 9 Fairphone 67 67 33 0 67 100 33 33 100 100 100 67 33
OnePlus 54 46 42 21 ² CONFIG_DEBUG_LIST / CONFIG_BPF_JIT_ALWAYS_ON ⋔ CONFIG_CFI_CLANG kmalloc-cg-*
Fairphone 3 3 3 3 CONFIG_INIT_ON_ALLOC_DEFAULT_ON CONFIG_ARM64_UAO ® CONFIG_SLAB_FREELIST_HARDENED
KSMA protection CONFIG_RANDOMIZE_BASE ¥ CONFIG_STRICT_KERNEL_RWX
Total 1698 1109 994 1533
© CONFIG_ARM64_(SW_TTBR0_)PAN ç CONFIG_SLAB_FREELIST_RANDOM CONFIG_UNMAP_KERNEL_AT_EL0
Ó Samsung RKP Huawei HKIP
symbols. For instance, CONFIG_SLAB_FREELIST_HARDENED Table 6: ✓ indicates defenses available for mainline Android
only includes inline functions and member variables. To de- kernel from v3.10 to v6.1, while ✗ indicates that the defense
tect the presence of this defense, our approach analyzes the is not required for the specific version.
kernel binary, more specifically, the function where these in- Kernel ² / ⋔ ® ¥ © ç
line calls are executed, e.g., get_random_long within func- v3.10 ✓ ✗ ✓
v3.18 ✓ ✓ ✓ ✓ ✓ ✓
tion kmem_cache_open. Executing the call indicates the pres- v4.4 ✓ ✓ ✓ ✓ ✓ ✓ ✓
ence of this defense. To detect the presence of the KSMA pro- v4.9 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
v4.14 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
tection, swapper_pg_dir and tramp_pg_dir must also be v4.19 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
mapped read-only. For instance, these pages might be mapped v5.4 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
v5.10 ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
between __start_rodata and __init_begin. v5.15 ✓ ✓ ✓ ✓ ✓ ✗ ✓ ✓ ✓ ✓ ✓ ✓ ✓
v6.1 ✓ ✓ ✓ ✓ ✓ ✗ ✓ ✓ ✓ ✓ ✓ ✓ ✓
² CONFIG_DEBUG_LIST / CONFIG_BPF_JIT_ALWAYS_ON ⋔ CONFIG_CFI_CLANG kmalloc-cg-*
A.2 Statistical Results of Firmware Extraction CONFIG_INIT_ON_ALLOC_DEFAULT_ON CONFIG_ARM64_UAO ® CONFIG_SLAB_FREELIST_HARDENED
KSMA protection CONFIG_RANDOMIZE_BASE ¥ CONFIG_STRICT_KERNEL_RWX
© CONFIG_ARM64_(SW_TTBR0_)PAN ç CONFIG_SLAB_FREELIST_RANDOM CONFIG_UNMAP_KERNEL_AT_EL0
Table 4 illustrates the extractable firmwares. Our success rate
of 58.5 % (with a collection and extraction rate of 65.3 % Table 7: The susceptibility reduction (i.e., Susc Reduc)
and 89.6 %) from produced devices to extractable firmwares against one-days of high-end to low-end devices.
aligns with prior work [11, 14, 64]. The two main reasons for Vendor Low-End High-End Susc Reduc
extraction failure were that our approach did not recognize Devices Susc Devices Susc in %
the correct format or that part of the firmware was corrupted. Samsung Galaxy A(1,2,3,5)4 5.5 Galaxy S23.* 4.5 18.2
Xiaomi Redmi 12.* 12.0 13T.* 12.0 0.0
Oppo A(3,9)8 12.0 Find X2.* 10.0 16.7
Vivo Y(100,27) 11.0 X100.* 4.0 63.6
Realme C(33,53,55) 10.7 Neo 5.* 10.0 6.2
Huawei Nova 11.* 15.5 P60.* 10.0 35.5
Motorola G(1,5,8)4.* 10.7 Edge 40.* 8.5 20.3
OnePlus Nord 3.* 10.0 11.* 7.0 30.0
Mean 23.8