Uds Fuzzing
Uds Fuzzing
Game Over
Thomas Sermpinis
@cr0wtom
whoami
• Thomas Sermpinis (a.k.a. cr0wtom)
• I want to hack everything I get my hands on
• ESPECIALLY CARS
• I want to make the world a safer place
• Addicted to TROOPERScon
THOMAS WORLD
x 0 TIME
000101 0-0
Introduction to UDS
LEVEL 0-0
x 3
UDS who?
• Unified Diagnostic Services
(UDS) - ISO-14229
Specification Requirements
Application
UDSonCAN UDSonFR UDSonIP UDSonK-Line UDSonLIN
Transport
DoCAN CoFR DoIP Not Applicable LIN
Network
fi
UDS who?
• Unified Diagnostic Services
(UDS) - ISO-14229
Specification Requirements
Application
UDSonCAN UDSonFR UDSonIP UDSonK-Line UDSonLIN
Transport
DoCAN CoFR DoIP Not Applicable LIN
Network
fi
UDS who?
• Unified Diagnostic Services
(UDS) - ISO-14229
Specification Requirements
Application
UDSonCAN UDSonFR UDSonIP UDSonK-Line UDSonLIN
Transport
DoCAN CoFR DoIP Not Applicable LIN
Network
fi
Message Structure
Message Structure
11-bit IDs
0x0 - 0x7
29-bit IDs
0x00000000 -
0xFFFFFFFF
5
ff
Message Structure
0: Singe Frame
ff
Message Structure
0x00 - 0xFF
11-bit IDs ISO-TP Related frame
data -
0x0 - 0x7 1st Nibble of the Byte
0: Singe Frame
Several standardised IDs
29-bit IDs 1: First Frame
ff
Message Structure
ff
Message Structure
ff
Message Structure
00 00 00 00 00 00 00 00
0x00 - 0xFF 0x00 - 0xFF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11-bit IDs ISO-TP Related frame
data -
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0x0 - 0x7 1st Nibble of the Byte
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0: Singe Frame Several standardised Applicable data by 00 00 00 00 00 00 00 00
Several standardised IDs sub-function bytes for
00 00 00 00 00 00 00 00
29-bit IDs 1: First Frame each service the service 00 00 00 00 00 00 00 00
0x00000000 - 2: Consecutive Frame
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0xFFFFFFFF 3: Flow Control Frame
Rest of them are Rest of them are
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
manufacturer specific 00 00 00 00 00 00 00 00
manufacturer 00 00 00 00 00 00 00 00
ff
Message Structure
00 00 00 00 00 00 00 00
0x00 - 0xFF 0x00 - 0xFF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11-bit IDs ISO-TP Related frame
data -
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0x0 - 0x7 1st Nibble of the Byte
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0: Singe Frame Several standardised Applicable data by 00 00 00 00 00 00 00 00
Several standardised IDs sub-function bytes for
00 00 00 00 00 00 00 00
29-bit IDs 1: First Frame each service the service 00 00 00 00 00 00 00 00
0x00000000 - 2: Consecutive Frame
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0xFFFFFFFF 3: Flow Control Frame
Rest of them are Rest of them are
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
manufacturer specific 00 00 00 00 00 00 00 00
manufacturer 00 00 00 00 00 00 00 00
ff
UDS Services
Request Response
Service
SID SID
fi
fi
fi
UDS Services
Request Response
Service
SID SID
fi
fi
fi
UDS Services
Request Response
Service
SID SID
fi
fi
fi
UDS Services
Request Response
Service
SID SID
fi
fi
fi
Negative Responses
Request Response
Service
SID SID
fi
fi
fi
Negative Responses
Requirements
LEVEL 1-1
x 3
•A vehicle :P
• Some software
10
The vehicle
11
The way to interface
12
The tools
• Libraries: • Tools:
• ISO-TP • can-utils
• python-can • caringcaribou
• python cantools • Scapy
• canmap
13
Caring Caribou
• Security testing tool for Automotive
• Modular
Reference: https://github.com/CaringCaribou/caringcaribou
14
Caring Caribou
Reference: https://github.com/CaringCaribou/caringcaribou
15
THOMAS WORLD
x 2 TIME
002001 1-1
Fuzz it already
LEVEL 1-2
x 3
Fuzzing / Enumeration
• Supply of expected or unexpected input
17
00 00 00 00 00 00 00 00
0x00 - 0xFF 0x00 - 0xFF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11-bit IDs ISO-TP Related frame
data -
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0x0 - 0x7 1st Nibble of the Byte
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0: Singe Frame Several standardised Applicable data by 00 00 00 00 00 00 00 00
Several standardised IDs sub-function bytes for
00 00 00 00 00 00 00 00
29-bit IDs 1: First Frame each service the service 00 00 00 00 00 00 00 00
0x00000000 - 2: Consecutive Frame
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0xFFFFFFFF 3: Flow Control Frame
Rest of them are Rest of them are
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
manufacturer specific 00 00 00 00 00 00 00 00
manufacturer 00 00 00 00 00 00 00 00
19
ff
ARB ID Enumeration
• Target IDs?
• 11-bit or 29-bit?
20
ARB ID Enumeration
• UDS Request
21
ARB ID Enumeration
• UDS Request
22
ARB ID Enumeration
23
ARB ID Enumeration
23
ARB ID Enumeration
23
ARB ID Enumeration
23
ARB ID Enumeration
24
ARB ID Enumeration
24
ARB ID Enumeration
24
ARB ID Enumeration
24
ARB ID Enumeration
24
Service ID Enumeration
00 00 00 00 00 00 00 00
0x00 - 0xFF 0x00 - 0xFF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11-bit IDs ISO-TP Related frame
data -
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0x0 - 0x7 1st Nibble of the Byte
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0: Singe Frame Several standardised Applicable data by 00 00 00 00 00 00 00 00
Several standardised IDs sub-function bytes for
00 00 00 00 00 00 00 00
29-bit IDs 1: First Frame each service the service 00 00 00 00 00 00 00 00
0x00000000 - 2: Consecutive Frame
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0xFFFFFFFF 3: Flow Control Frame
Rest of them are Rest of them are
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
manufacturer specific 00 00 00 00 00 00 00 00
manufacturer 00 00 00 00 00 00 00 00
25
ff
Service ID Enumeration
• Similar to ARB ID enumeration
Service ID Enumeration
• UDS Request
27
Service ID Enumeration
• UDS Request
27
Service ID Enumeration
28
Service ID Enumeration
29
Service Sub-Function
Enumeration
00 00 00 00 00 00 00 00
0x00 - 0xFF 0x00 - 0xFF 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
11-bit IDs ISO-TP Related frame
data -
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0x0 - 0x7 1st Nibble of the Byte
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0: Singe Frame Several standardised Applicable data by 00 00 00 00 00 00 00 00
Several standardised IDs sub-function bytes for
00 00 00 00 00 00 00 00
29-bit IDs 1: First Frame each service the service 00 00 00 00 00 00 00 00
0x00000000 - 2: Consecutive Frame
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
0xFFFFFFFF 3: Flow Control Frame
Rest of them are Rest of them are
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
manufacturer specific 00 00 00 00 00 00 00 00
manufacturer 00 00 00 00 00 00 00 00
30
ff
Service Sub-Function
Enumeration
• Enumeratingsub-functions is not as
straight forward
THOMAS WORLD
x 3 TIME
004001 1-1
LEVEL 1-3
x 3
33
ECUReset (0x11)
34
ECUReset
Service Sub-
Sub-Function Name
ID Function ID
35
ECUReset
36
ECUReset
37
Write Data by
Identifier (0x2E)
• Predefined memory locations
38
Write Data by
Identifier (0x2E)
• Supplying
unexpected amount and type
of data can potentially result in
crashes and memory overflows
39
Game Over???
Not Yet…
Write Data by
Identifier (0x2E)
•A lot of use-cases with DIDs which are
writeable from un-authenticated users
• Secret keys
• Passwords
• Mileage
• Commands that get executed in the
underlying OS …
41
Write Data by
Identifier (0x2E)
42
Write Data by
Identifier (0x2E)
Noteworthy Services
44
THOMAS WORLD
x 5 TIME
006001 2-2
LEVEL 2-1
x 2
• Seed/Key
Algorithm implemented and
obscured by the manufacturer
46
Seed Request
2. Calculate key
Random Seed Send
3. Calculate key
Send Calculated Key
Reference: https://www.riscure.com/uploads/2018/06/Riscure_fault-injection-on-diagnosis-protocols-presentation.pdf
47
UDS Security Access
48
ARB ID Enumeration
49
ARB ID Enumeration
49
ARB ID Enumeration
49
ARB ID Enumeration
49
ARB ID Enumeration
49
Common Attacks
• Pre-Calculated Key Fuzzing and brute-
forcing
• Fault Injection
Seed Request
2. Calculate key
Random Seed Send
3. Calculate key
Send Calculated Key
52
UDS Security Access
Client ECU
Seed Request
2. Calculate key
Random Seed Send
3. Calculate key
Send Calculated Key
52
THOMAS WORLD
x 7 TIME
008001 2-2
Is it really random?
LEVEL 2-2
x 2
Seed Randomness
• Whatif we could request the same seed more
than once?
• CANdid vulnerability
54
Seed Randomness
55
Seed Randomness
Client ECU
Seed Request
2. Calculate key
Random Seed Send
3. Calculate key
Send Calculated Key
56
THOMAS WORLD
x 8 TIME
019001 2-2
LEVEL 3-1
x 2
58
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
Desired Seed?
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
No
Desired Seed?
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
No
Desired Seed?
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
Yes
Desired Seed?
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
Yes Pre-Calculated
Desired Seed?
Key Send
59
fi
Seed Randomness
Issue hard ECUReset to the target ECU
ECU Reboots
Seed Received
59
fi
UDS_FUZZ Module
60
UDS_FUZZ Module
• CaringCaribou seemed like the proper
target
Seed_Randomness_Fuzzer
62
Demo time
Seed_Randomness_Fuzzer
64
Seed_Randomness_Fuzzer
65
Seed_Randomness_Fuzzer
65
Seed_Randomness_Fuzzer
66
Seed_Randomness_Fuzzer
66
Seed_Randomness_Fuzzer
66
Seed_Randomness_Fuzzer
66
Seed_Randomness_Fuzzer
• Evaluationscript for the source of
randomness in the tested ECU
019001 2-2
x 9 TIME
THOMAS WORLD
Delay_Fuzzer
• Whatif we already have a seed/pre-
calculated key pair?
Delay_Fuzzer
70
Demo time^2
Delay_Fuzzer
72
Game Over
Delay_Fuzzer
74
Delay_Fuzzer
74
Delay_Fuzzer
74
Delay_Fuzzer
74
Delay_Fuzzer
74
Delay_Fuzzer
74
Pre-calculated key
interception
Client ECU
Seed Request
2. Calculate key
Seed Send
3. Calculate key
Send Calculated Key
75
Pre-calculated key
interception
76
THOMAS WORLD
x 0 TIME
000000 0x00
LEVEL \x00
x 0
Mitigations
• HSMs start to appear on embedded devices
Thomas Sermpinis
cr0wsplace.com