SlideShare a Scribd company logo
Hacking The TomTom Runner Part 2
Vulnerability Research and Exploitation of an IoT Device
Luis Grangeia | @lgrangeia
October 2015
Confraria de Segurança da Informação
Overview
• Disclaimer
• Brag
• From Vulnerability to Exploit:
• Controlling execution
• Exfiltrating data
• Bootloader
• Firmware encryption
• Firmware validation
• Risk Assessment + Recommendations
Disclaimer
“I’m not a lawyer”
Disclaimer
1. Security research should not be illegal
2. TomTom has been contacted and has full
details of vulnerabilities
3. TomTom has mitigated the vulnerability in
a recent firmware version
(though it does not completely prevent the problem…)
Brag
“Mom, I did it.”
Brag
• I found and took advantage of a memory
corruption vulnerability,
• And used it to gain control of a closed
embedded system running proprietary software
• A few security hurdles had to be crossed
• Fellow hackers helped
• hello pmsac and poupas!
• No screwdriver or hardware hacking tricks were
used
Starting Point
•One TomTom Runner GPS
Watch
•Encrypted Firmware
updates
Finish Line
•Ability to modify existing
firmware and flash it on the
watch
•Fun ideas for the future:
• Implement phone
notifications on watch
• Use watch as a hacking
platform
(wrist worn ubertooth!)
From Vulnerability to Exploit
“opening” the device
• Atmel ATSAM4S8C
• Main “CPU” (MCU):
• Micron N25Q032A13ESC40F
• Serial flash memory (4MB)
• Texas Instruments CC2541:
• Bluetooth Module
• CSR SiRF starV 5e GNSS
• GPS Module (off screen)
• Main Firmware file
• Firmware for the GPS Module
• Language resource files (eng / ger/
por / etc.)
• Manifest files (configuration
settings)
• Firmware for the BLE Module
EEPROM File structure
• Device contains 4MB EEPROM with a primitive filesystem
• Each file can be read or written to via USB (and
bluetooth)
• Name structure is 32 bit values
• Coincident with firmware files
EEPROM File structure
Firmware Upgrade
MCU Atmel
EEPROM
PC
(Via USB)
1
Internal
Flash
2
3
1. Put firmware file on the EEPROM memory
2. Bootloader verifies presence of new firmware
on EEPROM, verifies if it’s valid
3. Bootloader decrypts firmware and writes it on
internal flash
Vulnerability
•Ability to crash the watch with a large
language file
•Got to control execution
• How?
Language Files
• List of NUL terminated
ASCII strings
• First 4 bytes: length of all
strings inc. nulls (little
endian)
• Next 4 bytes: number of
strings (little endian)
Big language file
• String buffer
over 6000
bytes
• Result: Crash!
Language files
• Device resets (interesting)…
• A mistery file appears (0x00013000)…
First crash!
Address Space
• Collected a LOT of crash dumps
• Read (and must read more) ARM documentation
• Note:
• This is an ARM Cortex M4 CPU
• Works in ARM Thumb-32 mode exclusively
• No ASLR (predictable)
• Not many memory controls (SRAM is executable)
• LR [R14] =
0x00426a75
subroutine call return
address
• PC [R15] =
0x2001bf54 program
counter
• We’re in SRAM (heap
or stack)
• Return address is in
Flash region
• Nice.
Google brain implant FTW
http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/
Language Files
After some fiddling...
R0 = 0x00000000
R1 = 0xffffffe3
R2 = 0x00000002
R3 = 0x00000029
R12 = 0x00000000
LR [R14] = 0x00441939 subroutine call return
address
PC [R15] = 0x000000cc program counter
Bedside Reading for the last two months
Masterplan for exploitation
1. Exfiltrate memory regions via loading values
into registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
1. Load Values into registers and crash
.syntax unified
.thumb
// Load VTOR address
ldr r2, =0xE000ED08
ldr r3, [r2]
// add offset to hardfault function ptr
mov r1, #0x04
add r2, r3, r1
// load hardfault address
ldr r3, [r2]
// This crashes always (explain why)
mov r1, #0x00
bx r1
• 0xe000ed08 - Vector Table
Offset Register
• Get address of VTOR
• Get address of hardfault
function (0x0040bfa1 on 1.8.42)
Masterplan for exploitation
1. Exfiltrate memory regions via loading values into
registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
2. Find crash routine and modify it to
improve bandwidth
• Slowly dumped crash handler and sub-routines
• Method: load addresses into registers, crash
• Wrote a script to read crash files and build a binary for
disassembly
2. Find crash routine and modify it to
improve bandwidth
• Crash handler does:
• Read some addresses
• Calls functions
• sprintf()’s the crashlog string to a string in the stack
• calls a fwrite()-like function to dump that string into the
EEPROM
Modified crash function (1/2)
.syntax unified
.thumb
// save lr, resize stack
push {r0-r12, lr}
sub.w sp, sp, #616
bl fillup
// Arguments for write()
mov.w r1, #512
add r0, sp, #100
// call write()
ldr r7, =0x00410e39
blx r7
/* shrink back stack */
add.w sp, sp, #616
pop {r0-r12, lr}
bx lr
• Rewritten crash function
• Does not crash 
• Dumps 372 bytes of memory
per call
Modified crash function (2/2)
fillup:
add r4, sp, #100
// “Crashlog” string
ldr r7, =0x73617243
str r7, [r4], #4
ldr r7, =0x676f6c68
str r7, [r4], #4
// Base address of ROM read:
ldr r7, =0x00408706
add r4, sp, #108
mov r3, #94
lp1:
ldr r8, [r7], #4
str r8, [r4], #4
sub r3, #1
cbz r3, end
b lp1
end:
bx lr
• Rewritten crash function
• Does not crash 
• Dumps 372 bytes of memory
per call
Other fun payloads written
• Wrote another payload to find ASCII strings on the
flash address space and dump that region
• (too big to fit in a slide)
Masterplan for exploitation
1. Exfiltrate memory regions via loading values into
registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
Dump the bootloader to extract AES keys
• Dumped the entire Bootloader section
• 0x00400000 - 0x00408000
• Took around 90 device reboots (32kb)
• Bootloader has to:
• Initialize device
• Check for presence of new firmware file
• Validate, decrypt, and flash new firmware
• Boot into main firmware
• AES key must be present!
Dump the bootloader to extract AES keys
• Loaded bootloader.bin into IDA PRO
• Found interesting data structures:
• AES S-Boxes
• MD5 Init functions and data structures
• Firmware upgrade function
Firmware upgrade function
• This is the graph of the firmware
upgrade function
• Two different MD5 checks
• AES decryption
Finding the AES key
• AES protocol “expands” the original key into a number of
separate round keys. AES 128 produces 11 round keys on
this process.
• I found the AES key expansion function expanding a key
from RAM.
• Later I found the key was loaded into RAM from flash
earlier in the exec flow.
• The key from flash is not the correct key!
• What sort of magic is this?
Finding the AES key – QEMU Debugging
• Used QEMU + IDA to “step through” the execution of the
bootloader
• Lots of problems here: QEMU does not cleanly emulate
this MCU – Had to change some addresses/registers
while debugging
• Stepped through:
• The key loading from Flash
• Jumped to the AES key expansion function
Finding the AES key – QEMU Debugging
• Turns out that the AES key expansion function was
modifying a single byte of the original key from flash
• Firmware key obtained from memory
• Eureka moment right here 
• This defeats bruteforcing through the bootloader’s
bytestream for the AES key
• Clever move by TomTom that increased attack cost by
several nights worth of sleep 
Firmware key
• We can now decrypt the firmware files from
download.tomtom.com
• AES 128 / ECB mode, as predicted 
• Still not totally clean: Some sort of “glitch” on first byte
of every 16 byte block:
• pmsac cracked this! (explain how!)
Firmware deobfuscation
Firmware deobfuscation
Firmware validation
• Firmware file is validated before flashing
• MD5 is used here, twice:
• An outter MD5 (cyphertext+AESKey)
• Poor man’s HMAC
• An inner MD5: MD5(plaintextfirmware)
• Poupas helped a lot on this
Risk Assessment
Vulnerability
• Firmware upgrade path is compromised
• Can flash any watch with modded firmware /
backdoor with physical access to it
• Can remotely implant a backdoor by doing a
MiTM attack to ‘download.tomtom.com’
• Can enable hidden functions on cheaper devices
(ie. Turn a TomTom Runner into a Multisport)
Risk
•Risk to users is fairly low
•Risk to TomTom is unknown:
• hardware can be used to run “homebrew”
firmware
• Might actually be good for sales
Recommendation
•Use SSL for download.tomtom.com!
•Use RSA / assymetric crypto to sign firmware
•Prevent firmware downgrades
•Must upgrade bootloader in the field
• quite a bit risky, but can be done
Reward to hackers
Thanks!
Questions?
Luis Grangeia | @lgrangeia
October 2015
Confraria de Segurança da Informação

More Related Content

What's hot

[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기
NAVER D2
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
Angel Boy
 
취미로 엔진 만들기
취미로 엔진 만들기취미로 엔진 만들기
취미로 엔진 만들기
Jiho Choi
 
CNIT 121: 17 Remediation Introduction (Part 1)
CNIT 121: 17 Remediation Introduction (Part 1)CNIT 121: 17 Remediation Introduction (Part 1)
CNIT 121: 17 Remediation Introduction (Part 1)
Sam Bowne
 
TDOH x 台科 pwn課程
TDOH x 台科 pwn課程TDOH x 台科 pwn課程
TDOH x 台科 pwn課程
Weber Tsai
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
Sam Bowne
 
Deel 1 beginsituatie overzicht
Deel 1 beginsituatie overzicht Deel 1 beginsituatie overzicht
Deel 1 beginsituatie overzicht
sofie
 
R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱jungjinwouk
 
SEH overwrite and its exploitability
SEH overwrite and its exploitabilitySEH overwrite and its exploitability
SEH overwrite and its exploitability
FFRI, Inc.
 

What's hot (9)

[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기[131]해커의 관점에서 바라보기
[131]해커의 관점에서 바라보기
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
취미로 엔진 만들기
취미로 엔진 만들기취미로 엔진 만들기
취미로 엔진 만들기
 
CNIT 121: 17 Remediation Introduction (Part 1)
CNIT 121: 17 Remediation Introduction (Part 1)CNIT 121: 17 Remediation Introduction (Part 1)
CNIT 121: 17 Remediation Introduction (Part 1)
 
TDOH x 台科 pwn課程
TDOH x 台科 pwn課程TDOH x 台科 pwn課程
TDOH x 台科 pwn課程
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
 
Deel 1 beginsituatie overzicht
Deel 1 beginsituatie overzicht Deel 1 beginsituatie overzicht
Deel 1 beginsituatie overzicht
 
R2서버정진욱
R2서버정진욱R2서버정진욱
R2서버정진욱
 
SEH overwrite and its exploitability
SEH overwrite and its exploitabilitySEH overwrite and its exploitability
SEH overwrite and its exploitability
 

Similar to Reverse Engineering the TomTom Runner pt. 2

Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
infodox
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
Alexander Bolshev
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
idsecconf
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CanSecWest
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
midnite_runr
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.
Priyanka Aash
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010
Tsukasa Oi
 
Advanced Windows Exploitation
Advanced Windows ExploitationAdvanced Windows Exploitation
Advanced Windows Exploitation
UTD Computer Security Group
 
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Atollic
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devices
Yashin Mehaboobe
 
Exploiting the windows kernel
Exploiting the windows kernelExploiting the windows kernel
Exploiting the windows kernel
Japneet Singh
 
Demystifying Secure enclave processor
Demystifying Secure enclave processorDemystifying Secure enclave processor
Demystifying Secure enclave processor
Priyanka Aash
 
Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4
Digital Bond
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
Arti Parab Academics
 
BIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptxBIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptx
SamiWhoo
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
Lyon Yang
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Scott K. Larson
 
Solnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsecSolnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsec
PacSecJP
 
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveDEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
Felipe Prado
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Lyon Yang
 

Similar to Reverse Engineering the TomTom Runner pt. 2 (20)

Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010
 
Advanced Windows Exploitation
Advanced Windows ExploitationAdvanced Windows Exploitation
Advanced Windows Exploitation
 
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devices
 
Exploiting the windows kernel
Exploiting the windows kernelExploiting the windows kernel
Exploiting the windows kernel
 
Demystifying Secure enclave processor
Demystifying Secure enclave processorDemystifying Secure enclave processor
Demystifying Secure enclave processor
 
Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
 
BIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptxBIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptx
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
 
Solnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsecSolnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsec
 
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveDEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 

More from Luis Grangeia

Inteligência Artificial: Breve Introdução
Inteligência Artificial: Breve IntroduçãoInteligência Artificial: Breve Introdução
Inteligência Artificial: Breve Introdução
Luis Grangeia
 
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find ThemBSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
Luis Grangeia
 
Computer Forensics
Computer ForensicsComputer Forensics
Computer Forensics
Luis Grangeia
 
Heartbleed && Wireless
Heartbleed && WirelessHeartbleed && Wireless
Heartbleed && Wireless
Luis Grangeia
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...
Luis Grangeia
 
RSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do InfosecRSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do Infosec
Luis Grangeia
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and Future
Luis Grangeia
 
IBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointIBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's Standpoint
Luis Grangeia
 
Confraria Security And IT - End Point Security
Confraria Security And IT - End Point SecurityConfraria Security And IT - End Point Security
Confraria Security And IT - End Point Security
Luis Grangeia
 

More from Luis Grangeia (9)

Inteligência Artificial: Breve Introdução
Inteligência Artificial: Breve IntroduçãoInteligência Artificial: Breve Introdução
Inteligência Artificial: Breve Introdução
 
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find ThemBSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
 
Computer Forensics
Computer ForensicsComputer Forensics
Computer Forensics
 
Heartbleed && Wireless
Heartbleed && WirelessHeartbleed && Wireless
Heartbleed && Wireless
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...
 
RSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do InfosecRSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do Infosec
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and Future
 
IBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointIBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's Standpoint
 
Confraria Security And IT - End Point Security
Confraria Security And IT - End Point SecurityConfraria Security And IT - End Point Security
Confraria Security And IT - End Point Security
 

Recently uploaded

Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
amsjournal
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))
shivani5543
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 

Recently uploaded (20)

Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))gray level transformation unit 3(image processing))
gray level transformation unit 3(image processing))
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 

Reverse Engineering the TomTom Runner pt. 2

  • 1. Hacking The TomTom Runner Part 2 Vulnerability Research and Exploitation of an IoT Device Luis Grangeia | @lgrangeia October 2015 Confraria de Segurança da Informação
  • 2. Overview • Disclaimer • Brag • From Vulnerability to Exploit: • Controlling execution • Exfiltrating data • Bootloader • Firmware encryption • Firmware validation • Risk Assessment + Recommendations
  • 4. Disclaimer 1. Security research should not be illegal 2. TomTom has been contacted and has full details of vulnerabilities 3. TomTom has mitigated the vulnerability in a recent firmware version (though it does not completely prevent the problem…)
  • 6. Brag • I found and took advantage of a memory corruption vulnerability, • And used it to gain control of a closed embedded system running proprietary software • A few security hurdles had to be crossed • Fellow hackers helped • hello pmsac and poupas! • No screwdriver or hardware hacking tricks were used
  • 7. Starting Point •One TomTom Runner GPS Watch •Encrypted Firmware updates
  • 8. Finish Line •Ability to modify existing firmware and flash it on the watch •Fun ideas for the future: • Implement phone notifications on watch • Use watch as a hacking platform (wrist worn ubertooth!)
  • 10. “opening” the device • Atmel ATSAM4S8C • Main “CPU” (MCU): • Micron N25Q032A13ESC40F • Serial flash memory (4MB) • Texas Instruments CC2541: • Bluetooth Module • CSR SiRF starV 5e GNSS • GPS Module (off screen)
  • 11. • Main Firmware file • Firmware for the GPS Module • Language resource files (eng / ger/ por / etc.) • Manifest files (configuration settings) • Firmware for the BLE Module
  • 12. EEPROM File structure • Device contains 4MB EEPROM with a primitive filesystem • Each file can be read or written to via USB (and bluetooth) • Name structure is 32 bit values • Coincident with firmware files
  • 14. Firmware Upgrade MCU Atmel EEPROM PC (Via USB) 1 Internal Flash 2 3 1. Put firmware file on the EEPROM memory 2. Bootloader verifies presence of new firmware on EEPROM, verifies if it’s valid 3. Bootloader decrypts firmware and writes it on internal flash
  • 15. Vulnerability •Ability to crash the watch with a large language file •Got to control execution • How?
  • 16. Language Files • List of NUL terminated ASCII strings • First 4 bytes: length of all strings inc. nulls (little endian) • Next 4 bytes: number of strings (little endian)
  • 17. Big language file • String buffer over 6000 bytes • Result: Crash!
  • 18. Language files • Device resets (interesting)… • A mistery file appears (0x00013000)…
  • 20. Address Space • Collected a LOT of crash dumps • Read (and must read more) ARM documentation • Note: • This is an ARM Cortex M4 CPU • Works in ARM Thumb-32 mode exclusively • No ASLR (predictable) • Not many memory controls (SRAM is executable)
  • 21. • LR [R14] = 0x00426a75 subroutine call return address • PC [R15] = 0x2001bf54 program counter • We’re in SRAM (heap or stack) • Return address is in Flash region • Nice.
  • 22. Google brain implant FTW http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/
  • 24. After some fiddling... R0 = 0x00000000 R1 = 0xffffffe3 R2 = 0x00000002 R3 = 0x00000029 R12 = 0x00000000 LR [R14] = 0x00441939 subroutine call return address PC [R15] = 0x000000cc program counter
  • 25. Bedside Reading for the last two months
  • 26. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 27. 1. Load Values into registers and crash .syntax unified .thumb // Load VTOR address ldr r2, =0xE000ED08 ldr r3, [r2] // add offset to hardfault function ptr mov r1, #0x04 add r2, r3, r1 // load hardfault address ldr r3, [r2] // This crashes always (explain why) mov r1, #0x00 bx r1 • 0xe000ed08 - Vector Table Offset Register • Get address of VTOR • Get address of hardfault function (0x0040bfa1 on 1.8.42)
  • 28. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 29. 2. Find crash routine and modify it to improve bandwidth • Slowly dumped crash handler and sub-routines • Method: load addresses into registers, crash • Wrote a script to read crash files and build a binary for disassembly
  • 30. 2. Find crash routine and modify it to improve bandwidth • Crash handler does: • Read some addresses • Calls functions • sprintf()’s the crashlog string to a string in the stack • calls a fwrite()-like function to dump that string into the EEPROM
  • 31. Modified crash function (1/2) .syntax unified .thumb // save lr, resize stack push {r0-r12, lr} sub.w sp, sp, #616 bl fillup // Arguments for write() mov.w r1, #512 add r0, sp, #100 // call write() ldr r7, =0x00410e39 blx r7 /* shrink back stack */ add.w sp, sp, #616 pop {r0-r12, lr} bx lr • Rewritten crash function • Does not crash  • Dumps 372 bytes of memory per call
  • 32. Modified crash function (2/2) fillup: add r4, sp, #100 // “Crashlog” string ldr r7, =0x73617243 str r7, [r4], #4 ldr r7, =0x676f6c68 str r7, [r4], #4 // Base address of ROM read: ldr r7, =0x00408706 add r4, sp, #108 mov r3, #94 lp1: ldr r8, [r7], #4 str r8, [r4], #4 sub r3, #1 cbz r3, end b lp1 end: bx lr • Rewritten crash function • Does not crash  • Dumps 372 bytes of memory per call
  • 33. Other fun payloads written • Wrote another payload to find ASCII strings on the flash address space and dump that region • (too big to fit in a slide)
  • 34. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 35. Dump the bootloader to extract AES keys • Dumped the entire Bootloader section • 0x00400000 - 0x00408000 • Took around 90 device reboots (32kb) • Bootloader has to: • Initialize device • Check for presence of new firmware file • Validate, decrypt, and flash new firmware • Boot into main firmware • AES key must be present!
  • 36. Dump the bootloader to extract AES keys • Loaded bootloader.bin into IDA PRO • Found interesting data structures: • AES S-Boxes • MD5 Init functions and data structures • Firmware upgrade function
  • 37. Firmware upgrade function • This is the graph of the firmware upgrade function • Two different MD5 checks • AES decryption
  • 38. Finding the AES key • AES protocol “expands” the original key into a number of separate round keys. AES 128 produces 11 round keys on this process. • I found the AES key expansion function expanding a key from RAM. • Later I found the key was loaded into RAM from flash earlier in the exec flow. • The key from flash is not the correct key! • What sort of magic is this?
  • 39. Finding the AES key – QEMU Debugging • Used QEMU + IDA to “step through” the execution of the bootloader • Lots of problems here: QEMU does not cleanly emulate this MCU – Had to change some addresses/registers while debugging • Stepped through: • The key loading from Flash • Jumped to the AES key expansion function
  • 40. Finding the AES key – QEMU Debugging • Turns out that the AES key expansion function was modifying a single byte of the original key from flash • Firmware key obtained from memory • Eureka moment right here  • This defeats bruteforcing through the bootloader’s bytestream for the AES key • Clever move by TomTom that increased attack cost by several nights worth of sleep 
  • 41. Firmware key • We can now decrypt the firmware files from download.tomtom.com • AES 128 / ECB mode, as predicted  • Still not totally clean: Some sort of “glitch” on first byte of every 16 byte block: • pmsac cracked this! (explain how!)
  • 44. Firmware validation • Firmware file is validated before flashing • MD5 is used here, twice: • An outter MD5 (cyphertext+AESKey) • Poor man’s HMAC • An inner MD5: MD5(plaintextfirmware) • Poupas helped a lot on this
  • 46. Vulnerability • Firmware upgrade path is compromised • Can flash any watch with modded firmware / backdoor with physical access to it • Can remotely implant a backdoor by doing a MiTM attack to ‘download.tomtom.com’ • Can enable hidden functions on cheaper devices (ie. Turn a TomTom Runner into a Multisport)
  • 47. Risk •Risk to users is fairly low •Risk to TomTom is unknown: • hardware can be used to run “homebrew” firmware • Might actually be good for sales
  • 48. Recommendation •Use SSL for download.tomtom.com! •Use RSA / assymetric crypto to sign firmware •Prevent firmware downgrades •Must upgrade bootloader in the field • quite a bit risky, but can be done
  • 50. Thanks! Questions? Luis Grangeia | @lgrangeia October 2015 Confraria de Segurança da Informação