CODEBLUE 2014.12.18-19	
Takahiro Matsuki (FFRI)
Dennis Kengo Oka (ETAS)
!  Introduction
!  About ECU Software
!  Overview of TriCore
!  Investigation and Confirmation of Attack Methods
!  Demo
!  Summary and Future Plans
2
!  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 microcontrollers have specific security countermeasures
preventing software attacks?
!  If software is vulnerable, by adjusting traditional software attacks to
ECU microcontroller architecture, it is possible to execute attacks?
3
!  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
Environment	
◦  Library, Compiler
◦  Content of the code generated by development tools	
◦  Reverse engineering methods of the program files	
4
About ECU Software	
5
!  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 2015
!  50% infotainment, 30% powertrain and transmission, 10% chassis
control, 10% body and comfort
6
!  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, power windows, climate control, etc…
!  ABS/ESP control unit
◦  Regulating brake pressure, traction control, cornering brake control, etc…
7
!  Typical feedback control system
!  1. Monitor input. e.g. timer, sensors, CAN
!  2. Calculate or lookup appropriate response
!  3. Generate corresponding outputs	
8
!  Fully custom, proprietary software
!  Unix-based proprietary software
!  Standardized software. e.g. AUTOSAR
9
Overview of TriCore	
10
!  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, Nissan, Opel, Peugeot, Porsche, Renault, Seat,
Toyota, Volkswagen, Volvo
11
!  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
!  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 material of the User’s Manual
13
!  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 Board Infineon Starter Kit TC1797
◦  FlexECU development platform
!  Reverse Engineering of the Binary
◦  Possible to Disassemble using IDA Pro
!  File Format is ELF for Siemens TriCore
14
Investigation and Confirmation
of Attack Methods	
15
!  Non-Memory Corruption
Vulnerabilities
◦  Access Control Issues
◦  Encryption Strength Issues
◦  Inappropriate Authentication
◦  Conflictions
◦  Certificate / Password
Management Issues
◦  etc.
Since it was difficult to obtain and analyze actual ECU
Software, we hypothesized about the possibility of memory
corruption vulnerabilities.	
!  Memory Corruption
Vulnerabilities
◦  Buffer Overflow
◦  Integer Overflow
◦  Use After Free
◦  Null Pointer Dereferences
◦  Format String Bugs
◦  etc.
16
!  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 are possible because C++ code is executable with TriCore
!  Null Pointer Dereference
◦  Trap occurs by access to memory address zero, hypothesized attacks are possible	
17
!  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
!  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	
main()	
 check(f_ptr)	
receive()	
compare()	
success()	
failure()	
19	
f_ptr = &compare()
failure() { ...
}
success() { ....
}
compare() { ...
}
receive() {
// receive input value
input = …
char buffer[10];
strcpy( buffer, input );
}
check( f_ptr ) {
// call receive() to receive incoming values
receive();
// call compare() using a function pointer
f_ptr();
}
main () {
function_ptr = &compare;
…
check( function_ptr );
}
!  Example Code	
20
!  Memory Layout	
Address	
0x8000 010C	
0x8000 013C	
0x8000 0170	
0x8000 017C	
0x8000 0188	
…	
0xD000 8FC8	
0xD000 8FE0	
Variable	
check()	
receive()	
compare()	
success()	
failure()	
…	
buffer[]	
function_ptr	
21
main()	
 check(f_ptr)	
receive()	
compare()	
success()	
Failure()	
check() calls f_ptr() which now points to success()
(0x8000 017C) instead of compare() (0x8000 0170)
22
!  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
Considering Attacks
Possibilities Using TriCore’s
Control Mechanism	
24
!  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
Attack Methods Using the
Context Management
Mechanism	
26
!  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 dedicated command, used for
passing parameters	
27
Reference: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
28
Reference: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
29
!  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/schedule.php?act=detail&item=44	
30
!  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 restore crafted Upper context (including
return address) and run arbitrary code.
31
!  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
!  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
Attack Methods Using the
Interrupt and Trap Mechanisms	
34
!  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
◦  BIV | (ICR.PIPN << 5)
!  ICR (Interrupt Control
Register)
Reference: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
ISR is user-definedPIPN 0~255	
35
!  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
executed.
Reference: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
36
!  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
!  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 untested	
◦  In the real project, the 0xA segment is
mapped on the Flash memory, and may
not be overwritable.
!  The TVT is similarly overwritten
38
!  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
39
Verification on an Evaluation
Board	
40
!  HP EliteBook 2530p, Win7, Centrino2
◦  HIGHTEC Free TriCore Entry Tool Chain
◦  BUSMASTER
!  Infineon TriBoard TC1797 V5.0
!  ETAS ES592.1
41
ES592.1	
 TriBoard	
 Notebook	
Ethernet	
CAN	
 USB	
42
43
Demo	
44
Summary and Future Plans	
45
!  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 CSA, it is possible to execute arbitrary code
◦  By altering the interrupt/trap vector tables, it is impossible to execute arbitrary code
!  Created vulnerable ECU software and conducted an attack demo
!  This research is a result of a study of logical attack methods and a demo
conducted on a vulnerable software sample. This study does NOT
indicate anything about existing threats on actual ECU software.
46
!  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
!  Consider Countermeasures
◦  Consider countermeasures of ECU software vulnerabilities	
◦  Consider measures to efficiently discover vulnerabilities resulting
from programming errors	
47
Thank you
48
Address	
 Region	
0x8000 0000	
 Code	
…
0xA000 F000 BIV	
…
0xD000 4FC0	
 CSA	
…	
0xD000 9004(?)	
 Heap	
…
0xD000 8FF8	
 Stack	
49
Reference: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
50
!  TriCore has memory protections built in the hardware.
◦  Possible to restrict access to memory regions below:
!  Data RW
!  Instruction Fetching
◦  Trap on Access Violation
!  Can use for debugging
◦  Can globally disable memory protections
!  Things to consider
◦  Functions like DEP
◦  Disabled by default on simulators and evaluation boards
◦  The settings on a real ECU can be a barrier for exploitation
51
!  CSA is managed by linked lists
◦  Unused CSA List (FCX: Free Context List )
◦  Used CSA List (PCX: Previous Context List )
◦  Pointers to the head element in each list are stored in the FCX
and PCX registers
!  However, they are not the raw address so conversion is needed
Resourcce: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
52
!  Check whether ISR EntryPoint can be overwritten
with a jump instruction(JLA)
!  Operand addresses on instructions like JLA are
expressed in 24 bits
◦  Conversion between 24bit⇔32bit is necessary to
understand the assembly.
Resource: Tricore Architeture Overview
http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44	
53
!  Division by zero does not result in an exception	
!  Can change the value of CSFR with a mtcr instruction
◦  Can be exploited with a privilege escalation
vulnerabilityNeeds further investigation
!  Memory Integrity Error Mitigation (TriCore 1.3.1)
◦  Needs further investigation
54

CODE BLUE 2014 : A security assessment study and trial of Tricore-powered automotive ECU by DENNIS KENGO OKA & TAKAHIRO MATSUKI

  • 1.
    CODEBLUE 2014.12.18-19 Takahiro Matsuki(FFRI) Dennis Kengo Oka (ETAS)
  • 2.
    !  Introduction !  AboutECU Software !  Overview of TriCore !  Investigation and Confirmation of Attack Methods !  Demo !  Summary and Future Plans 2
  • 3.
    !  Previous researchhas 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 microcontrollers have specific security countermeasures preventing software attacks? !  If software is vulnerable, by adjusting traditional software attacks to ECU microcontroller architecture, it is possible to execute attacks? 3
  • 4.
    !  ECU Hardwareand 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 Environment ◦  Library, Compiler ◦  Content of the code generated by development tools ◦  Reverse engineering methods of the program files 4
  • 5.
  • 6.
    !  Basically everymodern 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 2015 !  50% infotainment, 30% powertrain and transmission, 10% chassis control, 10% body and comfort 6
  • 7.
    !  Engine controlunit ◦  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, power windows, climate control, etc… !  ABS/ESP control unit ◦  Regulating brake pressure, traction control, cornering brake control, etc… 7
  • 8.
    !  Typical feedbackcontrol system !  1. Monitor input. e.g. timer, sensors, CAN !  2. Calculate or lookup appropriate response !  3. Generate corresponding outputs 8
  • 9.
    !  Fully custom,proprietary software !  Unix-based proprietary software !  Standardized software. e.g. AUTOSAR 9
  • 10.
  • 11.
    !  Microcontroller forVehicle 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, Nissan, Opel, Peugeot, Porsche, Renault, Seat, Toyota, Volkswagen, Volvo 11
  • 12.
    !  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
  • 13.
    !  Research ofOpen 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 material of the User’s Manual 13
  • 14.
    !  Searched ResearchPapers ◦  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 Board Infineon Starter Kit TC1797 ◦  FlexECU development platform !  Reverse Engineering of the Binary ◦  Possible to Disassemble using IDA Pro !  File Format is ELF for Siemens TriCore 14
  • 15.
  • 16.
    !  Non-Memory Corruption Vulnerabilities ◦ Access Control Issues ◦  Encryption Strength Issues ◦  Inappropriate Authentication ◦  Conflictions ◦  Certificate / Password Management Issues ◦  etc. Since it was difficult to obtain and analyze actual ECU Software, we hypothesized about the possibility of memory corruption vulnerabilities. !  Memory Corruption Vulnerabilities ◦  Buffer Overflow ◦  Integer Overflow ◦  Use After Free ◦  Null Pointer Dereferences ◦  Format String Bugs ◦  etc. 16
  • 17.
    !  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 are possible because C++ code is executable with TriCore !  Null Pointer Dereference ◦  Trap occurs by access to memory address zero, hypothesized attacks are possible 17
  • 18.
    !  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
  • 19.
    !  Possibilities ofa 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 main() check(f_ptr) receive() compare() success() failure() 19 f_ptr = &compare()
  • 20.
    failure() { ... } success(){ .... } compare() { ... } receive() { // receive input value input = … char buffer[10]; strcpy( buffer, input ); } check( f_ptr ) { // call receive() to receive incoming values receive(); // call compare() using a function pointer f_ptr(); } main () { function_ptr = &compare; … check( function_ptr ); } !  Example Code 20
  • 21.
    !  Memory Layout Address 0x8000010C 0x8000 013C 0x8000 0170 0x8000 017C 0x8000 0188 … 0xD000 8FC8 0xD000 8FE0 Variable check() receive() compare() success() failure() … buffer[] function_ptr 21
  • 22.
    main() check(f_ptr) receive() compare() success() Failure() check() callsf_ptr() which now points to success() (0x8000 017C) instead of compare() (0x8000 0170) 22
  • 23.
    !  Issues ◦  Ifcompiler 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
  • 24.
    Considering Attacks Possibilities UsingTriCore’s Control Mechanism 24
  • 25.
    !  Preconditions ◦  Itis 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
  • 26.
    Attack Methods Usingthe Context Management Mechanism 26
  • 27.
    !  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 dedicated command, used for passing parameters 27
  • 28.
    Reference: Tricore ArchitetureOverview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 28
  • 29.
    Reference: Tricore ArchitetureOverview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 29
  • 30.
    !  CSA isManaged 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/schedule.php?act=detail&item=44 30
  • 31.
    !  Method 1:CSAOverwriting ◦  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 restore crafted Upper context (including return address) and run arbitrary code. 31
  • 32.
    !  Code onthe 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
  • 33.
    !  CSA overwriteusing 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
  • 34.
    Attack Methods Usingthe Interrupt and Trap Mechanisms 34
  • 35.
    !  When aninterruption 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 ◦  BIV | (ICR.PIPN << 5) !  ICR (Interrupt Control Register) Reference: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 ISR is user-definedPIPN 0~255 35
  • 36.
    !  A mechanismused 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 executed. Reference: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 36
  • 37.
    !  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
  • 38.
    !  BIV value0xa00f0000 !  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 untested ◦  In the real project, the 0xA segment is mapped on the Flash memory, and may not be overwritable. !  The TVT is similarly overwritten 38
  • 39.
    !  The BIVand 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 39
  • 40.
    Verification on anEvaluation Board 40
  • 41.
    !  HP EliteBook2530p, Win7, Centrino2 ◦  HIGHTEC Free TriCore Entry Tool Chain ◦  BUSMASTER !  Infineon TriBoard TC1797 V5.0 !  ETAS ES592.1 41
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
    !  Considered attackmethods 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 CSA, it is possible to execute arbitrary code ◦  By altering the interrupt/trap vector tables, it is impossible to execute arbitrary code !  Created vulnerable ECU software and conducted an attack demo !  This research is a result of a study of logical attack methods and a demo conducted on a vulnerable software sample. This study does NOT indicate anything about existing threats on actual ECU software. 46
  • 47.
    !  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 !  Consider Countermeasures ◦  Consider countermeasures of ECU software vulnerabilities ◦  Consider measures to efficiently discover vulnerabilities resulting from programming errors 47
  • 48.
  • 49.
    Address Region 0x8000 0000 Code … 0xA000 F000 BIV … 0xD000 4FC0 CSA … 0xD000 9004(?) Heap … 0xD000 8FF8 Stack 49
  • 50.
    Reference: Tricore ArchitetureOverview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 50
  • 51.
    !  TriCore hasmemory protections built in the hardware. ◦  Possible to restrict access to memory regions below: !  Data RW !  Instruction Fetching ◦  Trap on Access Violation !  Can use for debugging ◦  Can globally disable memory protections !  Things to consider ◦  Functions like DEP ◦  Disabled by default on simulators and evaluation boards ◦  The settings on a real ECU can be a barrier for exploitation 51
  • 52.
    !  CSA ismanaged by linked lists ◦  Unused CSA List (FCX: Free Context List ) ◦  Used CSA List (PCX: Previous Context List ) ◦  Pointers to the head element in each list are stored in the FCX and PCX registers !  However, they are not the raw address so conversion is needed Resourcce: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 52
  • 53.
    !  Check whetherISR EntryPoint can be overwritten with a jump instruction(JLA) !  Operand addresses on instructions like JLA are expressed in 24 bits ◦  Conversion between 24bit⇔32bit is necessary to understand the assembly. Resource: Tricore Architeture Overview http://www.infineon-ecosystem.org/download/schedule.php?act=detail&item=44 53
  • 54.
    !  Division byzero does not result in an exception !  Can change the value of CSFR with a mtcr instruction ◦  Can be exploited with a privilege escalation vulnerabilityNeeds further investigation !  Memory Integrity Error Mitigation (TriCore 1.3.1) ◦  Needs further investigation 54

Editor's Notes

  • #3 イントロ、目的 1p ETAS ECUソフトウェアについて 2,3p ETAS TriCore とは? 10p FFRI 理論上の攻撃手法とシミュレータでの試行 9(3x3)p FFRI 評価ボードを用いた検証環境 2,3p ETAS 検証結果・デモ(15min) 12月上旬打合せ ETAS まとめと今後の方針 1p, FFRI Total 30~35 slides デモ候補 4つ
  • #10 ECUソフトの種類
  • #12 http://www.infineon.com/cms/jp/product/microcontroller/development-tools-software-and-kits/tricore-tm-development-tools-software-and-kits/starterkits-and-evaluation-boards/starter-kit-tc1797-tc1197/channel.html?channel=db3a30431f848401011fa273b2eb3473 TriCore を搭載しているECUの例 他にもあるはず http://www.motormods.co.uk/protected_ecu_remapping.html http://www.evc.de/en/product/bsl/ecu.asp 国産メーカーではほとんどのメーカーでBosch系ECUの採用実績があるが、利用されているマイコンは三菱自動車を除きTC176x系となる。
  • #14 Vol1 280 Vol2 576 Vol.1, Vol.2あわせて約850ページあり、全部は読むのはとても大変だが、 TriCore Architecture Overview という Infineon の資料がわかりやすい
  • #15 QEMUにTriCoreをポーティング Portierung der TriCore-Architektur auf QEMU (2014/03/23)
  • #18 Use After Free(関数ポインタ上書き)
  • #20 スタック上に関数ポインタがあれば、それを上書きすることでコードフローを変更することができる (ETASさんのアイデア)
  • #22 スタック上に関数ポインタがあれば、それを上書きすることでコードフローを変更することができる (ETASさんのアイデア)
  • #24 スタック上に関数ポインタがあれば、それを上書きすることでコードフローを変更することができる (ETASさんのアイデア)
  • #29 Lower Context に D2 が2つある。1つは D1 の間違いと思われる。
  • #31 CSAのアロケーションと解放はハードウェアが自動的に行う アドレス変換ロジックは重要ではない
  • #33 main => CSA1 に保存 call func1 => CSA2 に保存 call func2 => CSA3 に保存 シミュレータ PCX 初期値 0x4d013f 固定の可能性 対応アドレス 0xd0004fc0 +0xC : リターンアドレスの場所 0xd0004fcc 実際のECUでも固定ならば攻撃障壁が低い 以降 64バイト毎にリターンアドレスが存在
  • #34 PCX 初期値は 0xD0005400 あたり
  • #36 Interrupt Vector Table Pending Interrupt Priority Number Interrupt Service Routine
  • #37 Trap Vector Table Trap Service Routine トラップ発生要因 命令による例外 不正なメモリアクセス non-maskable Interrupt (NMI) トラップ識別番号(TIN) トラップは常に有効で無効化不可 割り込みは無効化できる(maybe) 割り込みと同様に通常のコード実行を中断するが、CPUの優先度は変更しない IVTとは分離されている
  • #38 BIV レジスタ値のコントロール可否 おそらく不可 PIPN は 0~255 のいずれか BIV の値が実機で固定かどうか
  • #39 BIV レジスタ値のコントロール可否 おそらく不可 PIPN は 0~255 のいずれか BIV の値が実機で固定かどうか 攻撃成立条件 実機にて、Interrupt Vector Table のアドレス BIV (Begin Interrupt Vector) の値が固定 ISR(割り込みハンドラ)の仕様がわかっている PIPN(割り込み番号) Interrupt Vector Table が書き換え可能 Flashメモリへのマップやメモリ保護機構のため 書き換え不可の場合は攻撃不可 メモリ破壊脆弱性にて任意アドレスの値を書き換え可能 BTV レジスタの値(トラップベクタテーブルのベースアドレス) シミュレータ上での値 0xa00f2000 (固定?) 割り込みベクタテーブルと異なりデータがある 0xa00f20f4 まで TSR のエントリはTCN 0 ~ 7に対応 TCN0 => 0xa00f2000 TCN1 => 0xa00f2020 TCN2 => 0xa00f2040 TCN3 => 0xa00f2060 TCN4 => 0xa00f2080 TCN5 => 0xa00f20a0 TCN6 => 0xa00f20c0 TCN7 => 0xa00f20e0
  • #40 endInit protected
  • #53 CSAのアロケーションと解放はハードウェアが自動的に行う アドレス変換ロジックは重要ではない