Protecting RISC-V Processors against Physical Attacks Stefan - - PowerPoint PPT Presentation

protecting risc v processors
SMART_READER_LITE
LIVE PREVIEW

Protecting RISC-V Processors against Physical Attacks Stefan - - PowerPoint PPT Presentation

www.iaik.tugraz.at S C I E N C E P A S S I O N T E C H N O L O G Y Protecting RISC-V Processors against Physical Attacks Stefan Mangard, Robert Schilling, Thomas Unterluggauer, Mario Werner


slide-1
SLIDE 1

www.iaik.tugraz.at 

u www.iaik.tugraz.at

S C I E N C E  P A S S I O N  T E C H N O L O G Y

Protecting RISC-V Processors against Physical Attacks

Stefan Mangard, Robert Schilling, Thomas Unterluggauer, Mario Werner Graz University of Technology March 28th, 2019

slide-2
SLIDE 2

www.iaik.tugraz.at 

Attack Settings

Graz University of Technology 2

Processor RAM

Network

I/O Interfaces

Computer System

slide-3
SLIDE 3

www.iaik.tugraz.at 

Classic Setting: Attacks Via The (Network) Interfaces

Graz University of Technology 3

Processor RAM

Network

I/O Interfaces

Computer System

slide-4
SLIDE 4

www.iaik.tugraz.at 

Classic Setting: Attacks Via The (Network) Interfaces

Graz University of Technology 4

Processor RAM

Network

I/O Interfaces

Computer System

slide-5
SLIDE 5

www.iaik.tugraz.at 

The Secure Processor Setting

Graz University of Technology 5

Processor

RAM Network I/O Interfaces

Memory Encryption

slide-6
SLIDE 6

www.iaik.tugraz.at 

Physical Attack Setting: Also Processor is Attacked

Graz University of Technology 6

Processor

RAM Network I/O Interfaces

Example attacks: power analysis, fault attacks, …

slide-7
SLIDE 7

www.iaik.tugraz.at 

Small Faults – Big Effects

1 bit

determines your privilege level

determines your access rights

determines whether a password is considered correct or not

Changes completely the meaning of an opcode

Graz University of Technology 7

slide-8
SLIDE 8

www.iaik.tugraz.at 

Fault Attacks - Relevance

Traditional fields

secure elements

smart cards, …

New fields:

IoT, automotive, etc.

Example: Privilege escalation on Linux (Niek Timmers, Cristofaro Mune: Escalating Privileges in Linux Using Voltage Fault Injection. FDTC 2017: 1-8)

Graz University of Technology 8

slide-9
SLIDE 9

www.iaik.tugraz.at 

Fault Attacks – How?

Most popular techniques

Voltage glitches

Laser

Effects

Changes in data, pointers, …

Changes in program flow: skip of instruction pointer, induction of branches, …

Graz University of Technology 9

Rowhammer

slide-10
SLIDE 10

www.iaik.tugraz.at 

Fault Attacks – What Can We Do?

Graz University of Technology 10

slide-11
SLIDE 11

www.iaik.tugraz.at 

Fault Attacks – What Can We Do?

Graz University of Technology 11

Control flow graph integrity

Mario Werner, Thomas Unterluggauer, David Schaffenrath, Stefan Mangard. “Sponge- Based Control-Flow Protection for IoT Devices”. In: Euro S&P 2018

slide-12
SLIDE 12

www.iaik.tugraz.at 

Fault Attacks – What Can We Do?

Graz University of Technology 12

Branch Integrity

Robert Schilling, Mario Werner, Stefan Mangard. “Securing Conditional Branches in the Presence of Fault Attacks”. In: DATE 2018

slide-13
SLIDE 13

www.iaik.tugraz.at 

Fault Attacks – What Can We Do?

Graz University of Technology 13

Memory Access

Robert Schilling, Mario Werner, Pascal Nasahl, Stefan Mangard. “Pointing in the Right Direction-Securing Memory Accesses in a Faulty World”. In: ACSAC 2018

slide-14
SLIDE 14

www.iaik.tugraz.at 

Fault Attacks – What can we do?

Graz University of Technology 14

slide-15
SLIDE 15

www.iaik.tugraz.at 

Sponge-Based Control-Flow Protection

Graz University of Technology 15

slide-16
SLIDE 16

www.iaik.tugraz.at 

Control Flow Integrity is Critical

Robert Schilling Graz University of Technology 16

slide-17
SLIDE 17

www.iaik.tugraz.at 

Control Flow Integrity is Critical

Robert Schilling Graz University of Technology 17

slide-18
SLIDE 18

www.iaik.tugraz.at 

Control Flow Integrity is Critical

Robert Schilling Graz University of Technology 18

slide-19
SLIDE 19

www.iaik.tugraz.at 

Control Flow Integrity is Critical

Robert Schilling Graz University of Technology 19

slide-20
SLIDE 20

www.iaik.tugraz.at 

Control Flow Integrity is Critical

Robert Schilling Graz University of Technology 20

slide-21
SLIDE 21

www.iaik.tugraz.at 

Main Idea

Sponge-based Control-Flow Protection (SCFP)

Hardware supported CFI scheme

Encrypts the instruction stream with small granularity

Program can only be decrypted correctly as long it is executed correctly

Costs

Highly configurable in terms of security and cost

RV32IM AEE-Light: ~10% runtime, ~20% code size

Robert Schilling Graz University of Technology 21

slide-22
SLIDE 22

www.iaik.tugraz.at 

High Level Concept

Graz University of Technology 22

slide-23
SLIDE 23

www.iaik.tugraz.at 

High Level Concept

Graz University of Technology 23

slide-24
SLIDE 24

www.iaik.tugraz.at 

High Level Concept

Graz University of Technology 24

slide-25
SLIDE 25

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 25

slide-26
SLIDE 26

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 26

slide-27
SLIDE 27

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 27

slide-28
SLIDE 28

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 28

slide-29
SLIDE 29

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 29

slide-30
SLIDE 30

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 30

slide-31
SLIDE 31

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 31

slide-32
SLIDE 32

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 32

slide-33
SLIDE 33

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 33

slide-34
SLIDE 34

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 34

slide-35
SLIDE 35

www.iaik.tugraz.at 

Decryption/Execution Example

Graz University of Technology 35

slide-36
SLIDE 36

www.iaik.tugraz.at 

RISC-V ISA Integration - Branches

Graz University of Technology 36 

Branches additional have an associated patch that is applied conditionally

New BPEQ, BPNE, BPLT, BPLTU, BPGE, and BPGEU instructions

slide-37
SLIDE 37

www.iaik.tugraz.at 

RISC-V ISA Integration – Calls

Graz University of Technology 37

Indirect Calls Direct Calls

slide-38
SLIDE 38

www.iaik.tugraz.at 

Prototype Implementation

Graz University of Technology 38 

LLVM-based toolchain

RI5CY-based hardware

AEE-Light with PRINCE in APE-like mode

~30kGE of area for SCFP at 100MHz in UMC65

~10% runtime and ~20% code size overhead

slide-39
SLIDE 39

www.iaik.tugraz.at 

Protected Conditional Branches

slide-40
SLIDE 40

www.iaik.tugraz.at 

Motivation

Control-flow integrity (CFI) measures restrict the control-flow to valid execution traces

Branching decisions require extra protection

Examples of critical applications

Password checks, signature verification, …

Graz University of Technology 40

PW check Continue Enter System Do Nothing

slide-41
SLIDE 41

www.iaik.tugraz.at 

Classical Conditional Branch

Graz University of Technology 41

slide-42
SLIDE 42

www.iaik.tugraz.at 

Faulting Conditional Branches

Graz University of Technology 42

Faulting the branch Fault the comparison Fault the operands

slide-43
SLIDE 43

www.iaik.tugraz.at 

Design Goals

Graz University of Technology 43

Maximum flexibility concerning redundancy encoding of data (x, y)

Arithmetic codes are efficient for number encoding

Linear codes are used for strings

Minimal changes to hardware

slide-44
SLIDE 44

www.iaik.tugraz.at 

Step 1: Encoded Comparison in Software

Efficiently possible e.g. for AN Codes

Output of comparison: n-bit symbol for true or n-bit symbol for false

Graz University of Technology 44

slide-45
SLIDE 45

www.iaik.tugraz.at 

Step 1: Encoded Comparison in Software

Graz University of Technology 45

How to securely branch based on the n-bit symbol?

slide-46
SLIDE 46

www.iaik.tugraz.at 

Step 2: Use a standard branch for the actual branching

Graz University of Technology 46

Use a standard branch for the actual branching ….

slide-47
SLIDE 47

www.iaik.tugraz.at 

Step 3: Link Comparison Result to CFI State

Graz University of Technology 47

… and link it to the CFI state.

slide-48
SLIDE 48

www.iaik.tugraz.at 

Example: Protected Conditional Branch

1. Compute the encoded comparison 2. Perform a conditional branch 3. At the branch target: Link the redundant condition value with the CFI state

Graz University of Technology 48

Wrong branch and wrong condition lead to invalid CFI state

𝐽1 𝐽2 𝑐𝑠 𝑑𝑝𝑜𝑒 = 𝑈𝑠𝑣𝑓 𝑉𝑞𝑒𝑏𝑢𝑓(𝑑𝑝𝑜𝑒) 𝐽6 𝐽7 𝑉𝑞𝑒𝑏𝑢𝑓(𝑑𝑝𝑜𝑒) 𝐽8 𝐽9

𝑇1 𝑇2 𝑇3 𝑇6

𝑇6 𝑇7 𝑇8

𝑇8 𝑇9

𝑑𝑝𝑜𝑒 = EncCmp

𝑇4

slide-49
SLIDE 49

www.iaik.tugraz.at 

Prototype Evaluation

Added new branch instruction to inject first operand to the CFI state

LLVM-based toolchain

Automatically identifies conditional branches

Encodes dependent data-flow graph to AN-code domain

Inserts software-based comparison algorithm

Overhead on par with state-of-the-art duplication approaches

Graz University of Technology 49

slide-50
SLIDE 50

www.iaik.tugraz.at 

Secure Memory Access

Graz University of Technology 50

slide-51
SLIDE 51

www.iaik.tugraz.at 

Faulting the Pointer

Faulted pointer redirects the memory access

Graz University of Technology 51

ptr

Memory Some data Secret

slide-52
SLIDE 52

www.iaik.tugraz.at 

Faulting the Memory Access

Faulted pointer redirects the memory access

Faulting the memory access itself leads to a wrong access

Graz University of Technology 52

ptr

Memory Some data Secret

slide-53
SLIDE 53

www.iaik.tugraz.at 

Pointer Protection with Residue Codes

Use multi-residue code to protect the pointer

Gives direct access to the functional value  no expensive decoding required

Supports pointer arithmetic

Redundancy stored in the pointer

Graz University of Technology 53

slide-54
SLIDE 54

www.iaik.tugraz.at 

Protecting the Memory Accesses

Write memory in the form 𝑛𝑓𝑛 𝑞 = 𝑚𝑞 𝐸𝑆𝑓𝑕

Inverse to read data back 𝐸𝑆𝑓𝑕 = 𝑚𝑞

−1 𝑛𝑓𝑛[𝑞]

Xor operation  chosen for low-overhead

𝑛𝑓𝑛 𝑞 = 𝑞 ⊕ 𝐸𝑆𝑓𝑕, 𝐸𝑆𝑓𝑕 = 𝑞 ⊕ 𝑛𝑓𝑛 𝑞

Problems with granularity

Use a byte-wise linking granularity to support arbitrary accesses

Graz University of Technology 55

slide-55
SLIDE 55

www.iaik.tugraz.at 

Prototype Evaluation

FPGA prototype based PULP by ETH Zurich with 5% area

  • verhead

ISA extension residue arithmetic and linked memory accesses

Custom LLVM compiler prototype transforms all pointers

Transformed all data pointers, protected all pointer arithmetic, replaced all memory accesses

~7% runtime and ~10% code size overhead

Graz University of Technology 56

slide-56
SLIDE 56

www.iaik.tugraz.at 

Graz University of Technology 57

slide-57
SLIDE 57

www.iaik.tugraz.at 

Stefan.Mangard@iaik.tugraz.at https://Cybersecurity-Campus.tugraz.at

Graz University of Technology 58

We are hiring PhD students, postdocs, senior researchers, faculty