1 / 48

Researching iphone’s BASEBAND

Researching iphone’s BASEBAND. Sem voigtländer (@userlandkernel) Special Thanks to @posixninja. $ whoami. Sem Voigtländer 19 years, learning code and security since 13 Software Engineering and Cybersecurity Student Interested in mobile devices Non-profit research. WHY BASEBAND.

wsolis
Download Presentation

Researching iphone’s BASEBAND

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Researching iphone’s BASEBAND Sem voigtländer (@userlandkernel) Special Thanks to @posixninja

  2. $ whoami • Sem Voigtländer • 19 years, learning code and security since 13 • Software Engineering and Cybersecurity Student • Interested in mobile devices • Non-profit research

  3. WHY BASEBAND • Seperated, own os and bootrom • No direct control / entrypoint, means no ability to verify integrity and security • Radio communication: huge attack vector • Proprietary, blackbox thus likelyhood of vulns is higher • CFW for baseband = prevent ss7 attack with firewall • Consumer freedom, consumers pay it’s their right! • Pwn one and pwn many  Storytime!

  4. What is BASEBAND • Chip seperated from main os • Own SecureROM, Own RAM, Own NAND, Own CPU • Used for cellular communication (Calls, Texts, LTE) • Managed by kernel drivers • Radio / Modem can send commands

  5. BASEBAND in 32-bit mobile apple devices • Qualcomm Chip • Supports VoIP LTE calls • 32-bit ARM • Hexagon DSP • Communications via CommCenter and Kernel Extension

  6. BASEBAND Firmware in 32-bit mobile apple devices • Conform Apple’s bundle format • ARM 32-bit ELF binaries • OKL4 Kernel (hypervisor kernel) • Codesigned with ticket and certificates, sha256 signatures

  7. Qualcomm baseband Operating system • OKL4, custom proprietry variant + Linux • Crashes will dump to NVRAM instead of the filesystem • Shared memory devices over busses (HSIC) • Disassembly and symbolication in IDA:DEMO

  8. QUALCOMM FIRMWARE: BOOT STAGES

  9. QUALCOMM FIRMWARE: CODE SIGNATURES

  10. QUALCOMM FIRMWARE: Parse and load • Image is loaded into internal memory • Internal memory is protected and trusted, only available when device is on • External flash / RAM are untrusted • Image must be authenticatedwithin the trust boundary in internal memory • LOAD ELFHDR  PARSE  VALIDATE • LOAD PHDR  PARSE  VALIDATE

  11. QUALCOMM FIRMWARE: Parse and load • Image is loaded into internal memory • Internal memory is protected and trusted, only available when device is on • External flash / RAM are untrusted • Image must be authenticatedwithin the trust boundary in internal memory • LOAD ELFHDR  PARSE  VALIDATE • LOAD PHDR  PARSE  VALIDATE • HASHES  VALIDATE

  12. QUALCOMM FIRMWARE: Parse and load SECURITY • External load  Check destination and size within whitelist • Selfevaluates the arithmic to prevent overflows • Above applies to headers, certificates and other size/offset calculated items.

  13. QUALCOMM FIRMWARE: certificate chain • ITU-T X.509 v3 Format • attestation cert. (optional), attestation CA cert. and root CA cert. • Certs are signed by next cert in chain • SHA-256 hash digest of the Root CA must match value in ROM • Serverside signer can’t revoke auth, root CA signs attestation certs directly and is anchored to ROM on device.

  14. QUALCOMM FIRMWARE: certificate chain • Root CA and attestation CA are similar to SSL certificates • Attestation cert includes additional details in (OU) fields

  15. QUALCOMM FIRMWARE: OU Field (SW_ID) • Binds signature to a particular version of a particular software image • Verification fails if current version is newer than image version  Prevent downgrades

  16. QUALCOMM FIRMWARE: OU Field (HW_ID) • Binds signature to a particular device family, model and OEM • Consists of an MSMID (Family), OEM ID (Device ID), MODEL ID

  17. QUALCOMM FIRMWARE: OU Field (DEBUG) • Indicates whether debugging is on or not(2 = disabled)

  18. QUALCOMM FIRMWARE: OU Field (OEM_ID) • Humanreadble value derrived from HW_ID

  19. QUALCOMM FIRMWARE: OU Field (SW_SIZE) • Size of signed data • May consist of hash table header, hash table entries and segments • Not used for validation, informative only

  20. QUALCOMM FIRMWARE: OU Field (SHA256 / SHA1) • Used to define hash algorithm for verification •  SHA1 is considered a weakness. •  Binary patch this to use sha1 breaks signature, but its a small step

  21. Qualcomm firmware: AMSS • AMMS is the Operating system image • Contains the filesystem (YAFFS) • Contains asserts with absolute paths  source code name • ELF binary, easy to parse and analyze.

  22. QUALCOMM FIRMWARE: OSBL • OSBL is the Operating System Bootloader • Generally loaded each time the baseband is being boot up

  23. QUALCOMM FIRMWARE: DBL • DBL is the DLOAD bootloader • DLOAD is a protocol used by Qualcomm for emergency debugging and flashing • Two types of implementations of the protocol: Streaming-DLOAD and DLOAD • Commands can be fuzzed and reversed. • DLOAD mode is on the NOR of the baseband • Crashes will enforce the device into DLOAD-mode

  24. Qualcomm details (iPhone 5) • Baseband version: 9x15A-ACEHRMAZA-139510 (from sbl1) • Build name: Maverick (MAV) • Signed by: MAV-SWID3-RootCA6-DataCenter (Probably a physical signing machine name) • Software ID: 3 • EEPROM: AT24C128BN • NAND: MT29F4G16ABC, MT29F4G08ABC, MT29F2G16ABD, MT29F2G08ABD

  25. Qualcomm details (iPhone 5) • Qualcomm Hexagon DSP 6 Processor • SDK Publicly available: https://developer.qualcomm.com/download/hexagon/hexagon-sdk-v3-3-3-linux.zip

  26. SBL1 Dumping and debugging features!!! • mav_ha5.bin (HSIC A5) • Fmav_ua5.bin (UART A5) • Fmav_hq6.bin (HSIC Q6) • nAmav_nor.bin (NORDUMP) • mav_boot.bin (BOOTDUMP) • nAmav_core_a5.bin (A5 CORE DUMP) • mAmav_core_q6.bin (Q6 CORE DUMP)

  27. SBL2: Sahara mode dload EFS1 Image is loaded EFS2 Image is loaded EFS3 Image is loaded ACDB Image is Loaded APPSBL image is Loaded APPS Image is loaded LPASS Image is loaded

  28. SBL2: Sahara mode dload Q6 Firmeware image is loaded Q6 Software Image is loaded Boot authorization is done Boot checksum is done Ram section for executable code is created (Yep, executable stack) RPM (Power Management Module) is loaded

  29. ANALYZING FIRMWARE • Firmware is not encrypted • Binwalk screws up with extraction, not efficient but still informative • Radare2 is not quite helpful either without the images being extracted • Solution: DIY. ELF images can be parsed. • Why? Binary patching and more specific to the MBN file format. • Offset finder, for later use.

  30. KNOWN VULNERABILITIES IN BASEBAND FIRMWARE • Executable Stack • No Address Space Layout randomization • Buffer overflow through integer overflow in QRTK_writeq() • AT+XLOG stack based overflow

  31. FUZZING THE BASEBAND: LOGS • Logs are saved in iOS and can be synced to a PC via the AFC protocol • Logs do not contain registers, only mention the error code and when the crash occured. • To enable extensive logging call *5005*3424# • Baseband crashes are stored in Baseband NVRAM, nvitem is prohibited. • Any command to get access to NVRAM?

  32. Fuzzing the baseband: FUZZER • Through fuzzing QMI messages (new and complicated procotol  profit?) • Through fuzzing SAHARA commands • Through fuzzing SDLOAD commands • Through fuzzing DLOAD commands • Through fuzzing DIAG commands • Through fuzzing AT commands • Through maliciously crafted firmware images (E.G: Negative refs in the ELF header)

  33. FUZZING THE QMI Interface • LIBQMI: https://github.com/freedesktop/libqmi

  34. FUZZING SAHARA (SAH) • LibOpenPST: https://github.com/openpst/libopenpst/tree/master/include/qualcomm

  35. FUZZING SDLOAD • LibOpenPST • https://github.com/openpst/libopenpst/tree/master/include/qualcomm

  36. FUZZING DLOAD • LibOpenPST • https://github.com/openpst/libopenpst/tree/master/include/qualcomm

  37. FUZZING DIAG • LibOpenPST • https://github.com/openpst/libopenpst/tree/master/include/qualcomm

  38. FUZZING AT COMMANDS • Thanks to Qualcomm’s genious security... Here are all the commands: https://kernelprogrammer.com/downloads/qc-at-cmds.pdf • Software Defined Radio? HackRF One + GNU Radio! • Serial (seems disabled or hidden nowadays): • /dev/tty.debug • /dev/tty.wlan-debug

  39. Examining bugs

  40. Future developments https://kernelprogrammer.com/ https://github.com/userlandkernel/baseband-research https://github.com/posixninja/DLOADTool https://github.com/posixninja/BBTool https://github.com/posixninja/DBLTool https://github.com/posixninja/iOSUSBEnum

  41. Resources https://developer.qualcomm.com https://osmocom.org https://theiphonewiki.com https://github.com/nst/iOS-Runtime-Headers/tree/master/Frameworks/CoreTelephony.framework https://lightbulbone.com/posts/2013/08/snooping-on-commcenter/ https://github.com/freedesktop/libqmi https://github.com/openpst/libopenpst

  42. https://github.com/fgsect/scat

More Related