Ffri Security, Inc. · TSE:3692
Ffri Security — CODEBLUE 2014
48 slides from Ffri Security's conference presentation, Dec 18, 2014
Slide 1: CODEBLUE 2014: Takahiro Matsuki (FFRI), Dennis Kengo Oka (ETAS)
CODEBLUE 2014.12.18-19 Takahiro Matsuki (FFRI) Dennis Kengo Oka (ETAS)
Slide 2: Agenda
Introduction About ECU Software Overview of TriCore Investigation and Confirmation of Attack Methods Demo Summary and Future Plans 2
Slide 3: Can ECU software be attacked like CAN bus messages?
Previous research has shown that vehicle ECUs can be targeted by attackers through injection of messages on the CAN bus – what about ECU software? ECU microcontroller architecture is different from traditional PC architecture; therefore, traditional software attacks do not work? ECU microcontr
Slide 4: Research items: hardware, architecture and development environment
ECU Hardware and Software Configuration ◦ ECU functions and microcontrollers, bus, I/O Interface ◦ What microcontrollers are used ECU Microcontroller Architecture ◦ Program Execution Method ◦ Instruction Execution Flow, Register, Memory Layout ECU Software Execution Environment and Development
Slide 5: About ECU Software
About ECU Software >a
Slide 6: Modern cars contain many electronic control units
Basically every modern production car has a multitude of electronic control units to provide safety- as well as comfort functions. Average vehicle has up to 70 ECUs >20,000,000 lines of source code Electronic components are estimated to cost about 50% of the automotive production costs by 20
Slide 7: Types of ECUs and their functions
Engine control unit ◦ Fuel amount and mixture, air and fuel delivery timing, valve timing, ignition timing, emission control, etc… Transmission control unit ◦ Gear change, shift lock, shift solenoids, pressure control solenoids, etc… Body control unit ◦ Central locking, immobilizer system, pow
Slide 8: Typical feedback control system
Typical feedback control system 1. Monitor input. e.g. timer, sensors, CAN 2. Calculate or lookup appropriate response 3. Generate corresponding outputs 8
Slide 9: Types of ECU software
Fully custom, proprietary software Unix-based proprietary software Standardized software. e.g. AUTOSAR 9
Slide 10: Overview of TriCore
Overview of TriCore 10
Slide 11: Microcontroller for vehicle ECUs
Microcontroller for Vehicle ECUs Manufactured and sold by Infineon ◦ Spin off of Semiconductor Unit from the German manufacturer Siemens AG ECUs With TriCore ◦ Bosch EDC17 & MED17, Siemens Car Manufacturers Using ECUs with TriCore ◦ Audi, BMW, Citroen, Ford, Honda, Hyundai, Mercedes-Benz, Ni
Slide 12: TriCore command set, registers and model used
Command Set ◦ 32 bit RISC Architecture Unique Register Configuration ◦ Completely separated address and data registers ◦ A0~A16, D0~D16 Model Number and Specifications of the Microcontroller Used in this Research ◦ TC1797 (AUDO Future) TriCore Architecture 1.3.1 Clock 180 MHz 12
Slide 13: Research of open information and specification documents
Research of Open Information and Specification Documents on the Web ◦ Official User’s Manual Most reliable information source Focused on memory related charts/diagrams Keyword search for security related terms security, protection, password ◦ TriCore Architecture Overview Summarized mate
Slide 14: Research papers and developer tools searched
Searched Research Papers ◦ TriCore Emulator Porting TriCore to QEMU ◦ Porting Linux Kernel to TriCore Searched for Information/Tools for Software Developers of ECU Software ◦ Development Environment TASKING VX-toolset for TriCore (Evaluation Edition) Compiler, IDE with simulator ◦ Evaluation
Slide 15: Investigation and Confirmation of Attack Methods
Investigation and Confirmation of Attack Methods 15
Slide 16: Memory corruption and non-memory corruption vulnerabilities
Non-Memory Corruption Memory Corruption Vulnerabilities Vulnerabilities ◦ Access Control Issues ◦ Buffer Overflow ◦ Encryption Strength Issues ◦ Integer Overflow ◦ Use After Free ◦ Inappropriate Authentication ◦ Null Pointer Dereferences ◦ Conflictions ◦ Format String Bugs ◦ Certificate / Passwo
Slide 17: Buffer overflow, integer overflow and format string bug
Buffer Overflow ◦ Stack Overflow ◦ Heap Overflow Integer Overflow ◦ Hypothesized that integer overflows can cause of heap overflows Format String Bug ◦ Possible to overwrite an arbitrary value in an arbitrary address, hypothesized that attacks are possible Use After Free ◦ Implied attacks ar
Slide 18: Stack overflows and heap overflows
Stack Overflows ◦ For TriCore, unlike x86 and others, the return address is saved in the address register (A11) instead of the stack, therefore overwriting the return address using a stack overflow is not possible. Heap Overflows ◦ Will examine TriCore’s heap management in the near future 18
Slide 19: Possibilities of a stack overflow attack
Possibilities of a Stack Overflow Attack ◦ If the buffer and function pointer exist on the stack in the following code flow, it is possible to change the execution flow of the program by a stack overflow receive() main() check(f_ptr) success() compare() f_ptr = &compare() failure() 19
Slide 20: Example code
Example Code failure() { ... check( f_ptr ) { } // call receive() to receive incoming values receive(); // call compare() using a function pointer success() { .... f_ptr(); } } main () { compare() { ... function_ptr = &compare; } … check( function_ptr ); receive() { } // receive input value input
Slide 21: Memory layout
Memory Layout Address Variable 0x8000 010C check() 0x8000 013C receive() 0x8000 0170 compare() 0x8000 017C success() 0x8000 0188 failure() … … 0xD000 8FC8 buffer[] 0xD000 8FE0 function_ptr 21
Slide 22: Function pointer overwrite flow
receive() main() check(f_ptr) success() compare() Failure() check() calls f_ptr() which now points to success() (0x8000 017C) instead of compare() (0x8000 0170) 22
Slide 23: Issues
Issues ◦ If compiler optimization is “on”, the function pointer will be stored in the address register ◦ Unclear whether there are similar code patterns in actual ECU software 23
Slide 24: Attack possibilities using TriCore's control mechanism
Considering Attacks Possibilities Using TriCore’s Control Mechanism 24
Slide 25: Preconditions and TriCore's control mechanism
Preconditions ◦ It is possible to overwrite data by using memory corruption vulnerabilities ◦ Under the above condition, considered ways to execute arbitrary code TriCore’s Control Mechanism ◦ Context Management Mechanism ◦ Interrupt/Trap Mechanism 25
Slide 26: Attack Methods Using the Context Management Mechanism
Attack Methods Using the Context Management Mechanism 26
Slide 27: About context
About Context ◦ The register value is CSA (Context Save Area) Saves and restores in TriCore’s unique memory space Types of Context ◦ 2 Types: Upper context and Lower context ◦ Upper context call command, interrupt, automatically saves when trapped ◦ Lower context Explicitly saved by using a
Slide 28: Reference: TriCore Architecture Overview
Reference: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 28
Slide 29: Reference: TriCore Architecture Overview
Reference: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 29
Slide 30: CSA is managed by link lists
CSA is Managed by Link Lists ◦ Used CSA List (PCX) , Unused CSA List (FCX) ◦ Pointer to the first element of each list is PCX, stored in FCX register However, needs to be converted because it is not a raw address Reference: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/
Slide 31: CSA overwriting and CSA injection methods
Method 1:CSA Overwriting ◦ By overwriting any return address saved in the CSA using a memory corruption vulnerability, it is possible to run code of an arbitrary address Method 2:CSA Injection ◦ By overwriting a Link word of the CSA using a memory corruption vulnerability, it is possible to rest
Slide 32: Return address rewrite example in CSA
Code on the right is the result of execution without augments func1 func2 func3 Rewrite the return address (*ret) within func2 saved in the CSA to func3 address (0x80000360) When returned to func1, the A11 register value restores to func3 (0x80000360) Jump to func3 on func1 return 32
Slide 33: CSA overwrite on evaluation board
CSA overwrite using an evaluation board was possible in the same way as the simulator ◦ There are memory protections to prevent CSA overwrites by default. ◦ May be possible to exploit on actual ECU Software 33
Slide 34: Attack Methods Using the Interrupt and Trap Mechanisms
Attack Methods Using the Interrupt and Trap Mechanisms 34
Slide 35: Interrupt Vector Table and ISR
When an interruption occurs, the Interrupt Vector Table (IVT) is referred, and the Interrupt Service Routine (ISR) corresponding to the Pending Interrupt Priority Number (PIPN) is executed IVT Start Address ◦ BIV Register (Begin Interrupt Vector) Addresses of entry point of each ISR PIPN 0~255
Slide 36: Trap mechanism and Trap Vector Table
A mechanism used when an exception occurs. It is trapped and runs a specific process ◦ Causes of Traps Command exceptions, unauthorized memory access, etc… When a trap occurs, the Trap Vector Table is referred, and the Trap Service Routine corresponding to the Trap Class Number (TCN) is execut
Slide 37: Overwrite the IVT or the TVT
Method 1: Overwrite the IVT ◦ By overwriting the jump code to the ISR in the IVT, when a certain interrupt occurs, run arbitrary code Method 2: Overwrite the TVT ◦ By overwriting the TSR code in the TVT , when a certain trap occurs, run arbitrary code 37
Slide 38: IVT overwrite on simulator
BIV value 0xa00f0000 Define a ISR as __interrupt(3) hoge_isr() , a jump code to hoge_isr() is allocated to 0xa00f0060 (0xa00f00+ 32*3) , making it possible to overwrite Overwrite possible on simulator ◦ However, because whether an interrupt could be triggered intentionally is unknown, left unt
Slide 39: BIV and BTV on evaluation board
The BIV and BTV values of the evaluation board are different from the simulator ◦ BIT @ 0xF7E1FE20, BTV @ 0xF7E1FE24 Protected Overwriting from the debugger possible Tried to overwrite the code by disabling the protection and a trap2 occurred Probably cannot exploit on actual ECU software
Slide 40: Verification on an Evaluation Board
Verification on an Evaluation Board 40
Slide 41: Demo environment hardware and tools
HP EliteBook 2530p, Win7, Centrino2 ◦ HIGHTEC Free TriCore Entry Tool Chain ◦ BUSMASTER Infineon TriBoard TC1797 V5.0 ETAS ES592.1 41
Slide 42: Demo setup diagram
CAN USB ES592.1 TriBoard Notebook Ethernet 42
Slide 43: 43
43
Slide 44: Demo
Demo 44
Slide 45: Summary and Future Plans
Summary and Future Plans 45
Slide 46: Summary
Considered attack methods on ECU software in which memory corruption vulnerabilities exist If memory corruption vulnerabilities exist, it may be possible to execute arbitrary code ◦ If a buffer overflow exists, it is possible to execute arbitrary code under certain conditions ◦ By altering the C
Slide 47: Future plans
Additional Research ◦ Study other vulnerabilities and architecture specific issues Demonstrate the Threats ◦ Reverse engineering of ECU software and investigate if memory corruption vulnerabilities exist ◦ Attack actual vulnerabilities and verify if the ECUs stop or if anything abnormal occurs
Slide 48: Thank you
Thank you 48