the story of (in)-secure arms racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfsamsung galaxy note ii...
TRANSCRIPT
![Page 1: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/1.jpg)
Speakers
Arms RaceThe story of (in)-secure bootloaders
Lee Harrison, Kang Li
Shmoocon 2014
![Page 2: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/2.jpg)
● Players
○ Device Manufacturers (Samsung, Apple, Qualcomm)
○ Service Providers (AT&T, Verizon)
○ Device “Owners”
Mobile Device Ecosystem
![Page 3: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/3.jpg)
● Break the Lockdown
○ Do not have root access
Installing unofficial apps ○ Can not run non-stock kernels
Loading customized kernels○ Can not replace boot loaders
Helping break the layers above
The Need to Study Bootloaders
![Page 4: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/4.jpg)
● Multiple case studies of
○ Do not have root access
Installing unofficial apps ○ Can not run non-stock kernel
Loading customized kernels○ Can not replace boot loaders
Replacing bootloaders
What this Talk is about
![Page 5: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/5.jpg)
● No newly discovered bootloader flaws.
● All bugs have been patched.
● All bugs were found independently by us. ○ one was disclosed by others first.
● Then why make this talk?○ Bootloader security is unique (and fun).
Disclaimers
![Page 6: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/6.jpg)
● Unique aspects of bootloader security ○ Severe time-pressure on product delivery
○ Threat source■ From device owners■ Physical access
○ Some mistakes found were unconventional
Why Make This Talk?
![Page 7: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/7.jpg)
External Flash Memory Card
Sim Card
eFUSE
Serial Number
Minimal allowed version
Warranty Void
Kernel Lock
Certificate hashes
eMMC --Internal Flash
ROM
Partition Table
Kernel Images
Boot loaders
PrimaryBootLoader
![Page 8: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/8.jpg)
Boot Flow Overview
Power on, execute ROM
Verify and execute code
Load code from flash Kernel
Sometimes many stages of code must be loaded
![Page 9: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/9.jpg)
Stage N+1 BootloaderImage
Signature
Hash1 == Hash2
Stage-NBootloader
Public Key
D
Flash
Header
Bootloader Image Verification (simplified)
?
Memory
![Page 10: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/10.jpg)
Case #1 Samsung Galaxy S3
● Released in mid-2012● Based on the Qualcomm MSM8960 chipset
http://static.trustedreviews.com/94/000023989/3659/s3fronts.jpg
![Page 11: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/11.jpg)
Goal: Boot a customized kernel image
![Page 12: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/12.jpg)
S3 Boot Flow
BootROM (PBL) SBL1 SBL2 SBL3
ResourcePower Manager
TrustZoneKernel
ABOOT Kernel
![Page 13: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/13.jpg)
➔ Kernel image is loaded twice by ABOOT
First load the code for execution
Second load for verification
![Page 14: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/14.jpg)
![Page 15: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/15.jpg)
for (p in partitions) {if (strcmp(p.name, “boot”) == 0) {
load_partition_to_memory(p)break
}}
for (p in partitions) {if (stricmp(p.name, “boot”) == 0) {
if (load_and_verify_signature(p)) boot_kernel()
else show_error()}
}
Loading and Verification
VerificationLoading
![Page 16: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/16.jpg)
for (p in partitions) {if (strcmp(p.name, “boot”) == 0) {
load_partition_to_memory(p)break
}}
for (p in partitions) {if (stricmp(p.name, “boot”) == 0) {
if (load_and_verify_signature(p)) boot_kernel()
else show_error()}
}
Notice any difference?
VerificationLoading
![Page 17: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/17.jpg)
for (p in partitions) {if (strcmp(p.name, “boot”) == 0) {
load_partition_to_memory(p)break
}}
for (p in partitions) {if (stricmp(p.name, “boot”) == 0) {
if (load_and_verify_signature(p)) boot_kernel()
else show_error()}
}
Notice any difference?
VerificationLoadingstrcmp:case sensitive
stricmp:case in-sensitive
![Page 18: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/18.jpg)
Exploit:Edit the GPT and add a “BOOT” partition before the “boot” partition
GPT Header
“BOOT” entry
“boot” entry
Verified
Loaded
Stock image
Custom image
Flash
![Page 19: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/19.jpg)
Patched when S3 was updated to Android 4.1.
They altered the signature verification to only load the kernel image once.
Case Closed
![Page 20: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/20.jpg)
Case #2 Samsung Galaxy Note II
Released in Fall 2012Based on Samsung’s Exynos 4 Quad SoC
![Page 21: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/21.jpg)
Goal: Boot a customized kernel image
![Page 22: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/22.jpg)
Exynos 4 (Note II) Boot Flow
BootROM BL1 BL2 BL3
TrustZoneKernel
Kernel
![Page 23: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/23.jpg)
Kernel Load// flash_read(mem_dst, disk_src, size)
flash_read(&boot_header, ptn_start, HEADER_SIZE);if (memcmp(boot_header.magic, "ANDROID!") == 0) {
// load kernel to 0x40008000, verify it// copy ramdisk to 0x42000000
}
Later...jump to 0x40008000
![Page 24: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/24.jpg)
Some Secret !flash_read(&boot_header, ptn_start, HEADER_SIZE);if (memcmp(boot_header.magic, "ANDROID!") == 0) {
// load kernel to 0x40008000, verify it// copy ramdisk to 0x42000000
} else {flash_read(0x40008000, ptn_start, 0x800000);
}Later...jump to 0x40008000
![Page 25: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/25.jpg)
Likely a debug branch flash_read(&boot_header, ptn_start, HEADER_SIZE);if (memcmp(boot_header.magic, "ANDROID!") == 0) {
// load kernel to 0x40008000, verify it// copy ramdisk to 0x42000000
} else {flash_read(0x40008000, ptn_start, 0x800000);
}Later...jump to 0x40008000
![Page 26: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/26.jpg)
A small victory!● That “else” branch lets us run unsigned code
● Custom kernel booting was made possible
![Page 27: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/27.jpg)
A small victory!● That “else” branch lets us run unsigned code
● Custom kernel booting was made possible
● But … the load action is very primitive
Need to develop a customized kernel loader
![Page 28: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/28.jpg)
Case #2.1 Samsung Galaxy Note II
Can we modify the early bootloader stages?
Goal: to simplify custom kernel loading
![Page 29: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/29.jpg)
Changing the bootloader
Problem: Bootloader is signed
Any modification breaks the signature
How to solve this?
![Page 30: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/30.jpg)
BL1 Verification● BL1 is verified by BootROM
● BootROM uses a fixed key inside the CPU
● How can this help?
![Page 31: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/31.jpg)
BL1 Verification● BL1 is verified by BootROM
● BootROM uses a fixed key inside the CPU.
● The same key was used across all CPUs of the same model.
![Page 32: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/32.jpg)
Jackpot● The ODROID-X hobby board shipped with a
BL1 that didn't check the signature of the second stage (BL2).
![Page 33: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/33.jpg)
Make a Custom Bootloader● If we glue their BL1 with a patched BL2/3
then we can boot a custom kernel.
● Custom bootloader created!
The BootROM is still able to validate the BL1, and then the custom BL2/3 will run without checking the signature of future stages
![Page 34: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/34.jpg)
Another Challenge● Bootloader partition is not exposed
○ Can’t read or write bootloader from Android
![Page 35: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/35.jpg)
Bootloader on the eMMCBootloader is on the protected Boot 1 partition
Android can only see the blue partition
http://www.ureach-inc.com/global/Porducts-Flash-emmc.html
![Page 36: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/36.jpg)
Writing the Bootloader● How can we overwrite the Boot 1 partition?
![Page 37: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/37.jpg)
Writing the Bootloader● How can we overwrite the Boot 1 partition?
Update from Vendor requires flashing BL !!
Phone has a special “download mode” that allows flashing files to the eMMC.
![Page 38: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/38.jpg)
One more problem!
Download mode checks file signatures when flashing.
![Page 39: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/39.jpg)
So close...
http://www.creativityfuse.com/wp-content/uploads/2010/09/frustration.gif
![Page 40: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/40.jpg)
The “else” branch!
We can write code to modify the signature check function in the running bootloader, and then load it through the else branch.
This lets us flash the custom bootloader to the device
Claim victory again!
How to disable the checking during flashing
![Page 41: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/41.jpg)
Case #2.2 Samsung Galaxy Note II ● Bad News
○ The else branch was removed in firmware update
○ Added blacklisting of old bootloaders
![Page 42: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/42.jpg)
http://instructional1.calstatela.edu/lkamhis/tesl565_sp11/gimbrone_zabayle/bouncers.jpg
![Page 43: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/43.jpg)
We need a new mechanism for putting the custom bootloader on the eMMC Boot partition
Let’s investigate the firmware update mechanism
![Page 44: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/44.jpg)
Flash Signature Checking● What kind of checks are performed?
○ RSA-2048
● Under what condition is the check performed?○ Partitions with certain names, such as “BOOT”
● Where does it get the partition information?
![Page 45: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/45.jpg)
Partition Information Table● Secondary partition table
● Additional partition metadata○ id, filesystem
● Root user can edit this table
![Page 46: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/46.jpg)
GPT
PIT
BOOT
RECOVERY
Flash
![Page 47: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/47.jpg)
Pit Header
BOOT entry
RECOVERY entry
GPT
PIT
BOOT
RECOVERY
FlashPIT
![Page 48: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/48.jpg)
Pit Header
BOOT entry
RECOVERY entry
GPT
PIT
BOOT
RECOVERY
FlashPIT
part_id: 11fs_type: raw
PIT Entry
![Page 49: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/49.jpg)
Bypassing the Flash Check● Create a duplicate PIT entry for the
bootloader partition
● Change the partition name to avoid checking
● The entries would point to the same location on the eMMC
![Page 50: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/50.jpg)
Original PITPit Header
BOOT entry
BOOT data
![Page 51: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/51.jpg)
Custom PITPit Header
BOOT entry
MYBOOT entry
BOOT data
![Page 52: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/52.jpg)
Custom PITPit Header
BOOT entry
MYBOOT entry
BOOT data
Sig-checked during flash
Not sig-checked during flash
![Page 53: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/53.jpg)
Success● This was effective in bypassing the signature
check.
● The custom bootloader from Case 2.1 was now flashable
![Page 54: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/54.jpg)
Case #2.3 Note II Lightning Round
Samsung added a signature check on the PIT area at boot time in a new bootloader revision.
![Page 55: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/55.jpg)
● The PIT area could no longer be altered to add custom entries.
![Page 56: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/56.jpg)
But… downgrade works➔ ...the developers forgot to blacklist the
previous bootloader file.
![Page 57: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/57.jpg)
Case #3 Samsung Galaxy S4
● Released in April 2013● Based on the Qualcomm Snapdragon 600● Some service providers also requested to
lock down their version of devices.
![Page 58: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/58.jpg)
Goal: Boot a custom kernel
![Page 59: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/59.jpg)
S4 Boot Flow
BootROM (PBL) SBL1 SBL2 SBL3
Resource PowerManager
TrustZoneKernel
ABOOT Kernel
![Page 60: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/60.jpg)
ABOOT
Flash
RAM
Executionreaches hereRamdisk_IMG
Kernel_IMG
Hdr
0x0
0xFFFFFFFF
![Page 61: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/61.jpg)
ABOOT
Flash
RAM
Ramdisk_IMG
Kernel_IMG
HdrRamdisk_IMG
Kernel_IMG
Hdrmmc_read
0x0
0xFFFFFFFF
![Page 62: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/62.jpg)
How Sections Load Into Memory// mmc_read(disk_src, mem_dst, size)
mmc_read( ptn_start, &hdr, PAGE_SIZE );mmc_read( kernel_start, hdr.kernel_addr, hdr.ksize );mmc_read( ramdisk_start, hdr.rd_addr, hdr.rdsize );
![Page 63: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/63.jpg)
ABOOT
Flash
RAM
Ramdisk_IMG
Kernel_IMG
HdrRamdisk_IMG
Kernel_IMG
Hdrmmc_read
What can go wrong?
0x0
0xFFFFFFFF
![Page 64: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/64.jpg)
Who controls hdr?// Load sections into memorymmc_read( ptn_start, &hdr, PAGE_SIZE );mmc_read( kernel_start, hdr.kernel_addr, hdr.ksize );mmc_read( ramdisk_start, hdr.rd_addr, hdr.rdsize );
![Page 65: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/65.jpg)
Who controls hdr?// Load sections into memorymmc_read( ptn_start, &hdr, PAGE_SIZE );mmc_read( kernel_start, hdr.kernel_addr, hdr.ksize );mmc_read( ramdisk_start, hdr.rd_addr, hdr.rdsize );
User controlled values
![Page 66: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/66.jpg)
Spot the problem?● No input validation
● Able to load code anywhere
● Even on top of the bootloader
![Page 67: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/67.jpg)
Exploit● Second mmc_read loads a combined kernel
+ ramdisk
● Third mmc_read overwrites the signature checking function
● First published by Dan Rosenberg● Affected many other vendors (e.g. LG)
![Page 68: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/68.jpg)
Flash
Ramdisk_IMG
Kernel_IMG
Hdr
Modified Flash
Ramdisk_IMG
Kernel_IMG
Hdr
ABOOT
RAM
Hdr
0x0
0xFFFFFFFF
Patch Code
First mmc_read
![Page 69: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/69.jpg)
Flash
Ramdisk_IMG
Kernel_IMG
Hdr
Ramdisk_IMG
Kernel_IMG
Hdr
ABOOT
RAM
Kernel_IMG
Hdr
0x0
0xFFFFFFFF
Patch Code
Ramdisk_IMG
Modified Flash
Second mmc_read
![Page 70: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/70.jpg)
Flash
Ramdisk_IMG
Kernel_IMG
Hdr
Ramdisk_IMG
Kernel_IMG
Hdr
Boot Loader
RAM
Kernel_IMG
Hdr
0x0
0xFFFFFFFF
Patch Code
Ramdisk_IMG
Patch Code
Modified Flash
Third mmc_read
![Page 71: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/71.jpg)
● Six bootloader software errors○ Case sensitive vs insensitive search ○ Additional debugging (else) branch ○ Failed to revocation signed modules○ Forgot to blacklist old bootloader○ Missing integrity check to PIT table○ Failed to validate the image header
● Most of them are NOT conventional memory vulnerabilities.
Summary
![Page 72: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/72.jpg)
● Problems are not limited to a single vendor.○ Samsung is very responsive to troubleshoot.○ All bugs shown are patched in Samsung devices.○ Some bugs are common across vendors.
● Vendors are often open to allow loading customized kernels.
● The “distrust” comes from service providers.
Summary
![Page 73: The story of (in)-secure Arms Racecobweb.cs.uga.edu/~kangli/src/bootloader.pdfSamsung Galaxy Note II Released in Fall 2012 Based on Samsung’s Exynos 4 Quad SoC Goal: Boot a customized](https://reader033.vdocuments.net/reader033/viewer/2022052015/602d05547bc82a19f9537bb6/html5/thumbnails/73.jpg)
Thanks!
lee2704 @uga.edu kangli @uga.edu