lecture: code-reuse attacks and defenses · [zovi, rsa conference 2010] stack pointer plays an...

101
Lecture: Code-Reuse Attacks and Defenses Lucas Davi Assistant Professor for Computer Science System Security Group University of Duisburg-Essen Winter School on Binary Analysis 22 February 2017, Bochum, Germany

Upload: others

Post on 08-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Lecture: Code-Reuse Attacks and Defenses

Lucas DaviAssistant Professor for Computer Science

System Security GroupUniversity of Duisburg-Essen

Winter School on Binary Analysis22 February 2017, Bochum, Germany

Page 2: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Our Research Overview in Software and System Security

AdvancedAttacks

Return-oriented programming

without returns [ACM CCS 2010]

JIT-ROP[IEEE S&P 2013]

Best Student Paper

Stitching Gadgets [USENIX Sec. 2014]

COOP[IEEE S&P 2015]

AdvancedDefenses

Mobile Security

Mobile CFI[NDSS 2012]

XIFER[AsiaCCS 2013]

HAFIX[DAC 2015]Best Paper

ROP Filter[RAID 2014]

Isomeron[NDSS 2015]

Readactor(++)[IEEE S&P 2015,ACM CCS 2015]

Privilege Escalation on Android[ISC 2010]

XManDroid[NDSS 2012]

PSiOS[AsiaCCS 2013]

Distinguished Paper

XiOS[AsiaCCS 2015]

Best Paper

LR2[NDSS 2016]

Page 3: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Overview of this Talk

Background/Evolution of Code-Reuse Attacks

Building Code Randomization Defenses

Building Control-Flow Integrity Defenses

Remote Attestation of Embedded Systems

Code-Reuse Attacks

Page 4: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Motivating Problem

• Software increasingly sophisticated and complex

• Various developers involved

• Native Code

• Many program bugs

Large attack surface for software exploits

100 Mio LOC in premium vehicles [DAC’15 Keynote]

Page 5: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Main Attack Techniques:Code Injection and Code Reuse

Page 6: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

General Principle of Code Injection Attacks

ENTRYasm_ins, …EXIT

Basic Block (BBL) A

A

C B

ENTRYasm_ins, …EXIT

BBL B

D

Control-Flow Graph (CFG)

1 Buffer overflow

2 Code Injection3 Control-flow deviation

Data flows

Program flows

Page 7: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

General Principle of Code-Reuse Attacks

ENTRYasm_ins, …EXIT

Basic Block (BBL) A

A

C B

ENTRYasm_ins, …EXIT

BBL B

Control-Flow Graph (CFG)

1 Buffer overflow

Data flows

Program flows

2

Control-flow deviation

Page 8: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Code Injection vs. Code Reuse

Code Injection – Adding a new node to the CFG

Adversary can execute arbitrary malicious code

open a remote console (classical shellcode)

exploit further vulnerabilities in the OS kernel to install a virus or a backdoor

Code Reuse – Adding a new path to the CFG

Adversary is limited to the code nodes that are available in the CFG

Requires reverse-engineering and static analysis of the code base of a program

Page 9: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Code injection is more powerful;so why are attacks today

typically using code reuse?

Page 10: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

DATA Memoryreadable and writeable

CODE Memoryreadable and executable

Data Execution Prevention (DEP) Prevent execution from a writeable memory (data) area

A

C B

D

Memory Access Violation

Page 11: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Data Execution Prevention (DEP) cntd.

Implementations

Modern OSes enable DEP by default (Windows, Linux, iOS, Android, Mac OSX)

Intel, AMD, and ARM feature a special No-Execute bit to facilitate deployment of DEP

Side Note

There are other notions referring to the same principle

W ⊕ X – Writeable XOR eXecutable

Non-executable memory

Page 12: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Hybrid Exploits

Today‘s attacks combine code reuse with code injection

CODE Memory Ireadable and executable

Executable

DATA Memoryreadable and writeable

CODE Memory II (Libraries)readable and executable

AllocateMemory()

CopyMemory()

ChangePermission()

DATA Memoryreadable and writeable

1

2

Malicious Code

Malicious Code

Page 13: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Hybrid Exploits

Today‘s attacks combine code reuse with code injection

CODE Memory Ireadable and executable

Executable

DATA Memoryreadable and writeable

CODE Memory II (Libraries)readable and executable

AllocateMemory()

CopyMemory()

ChangePermission()

DATA Memoryreadable and writeable

1

2

3

Malicious Code

Malicious Code

Malicious Code

Page 14: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Hybrid Exploits

Today‘s attacks combine code reuse with code injection

CODE Memory Ireadable and executable

Executable

DATA Memoryreadable and writeable

CODE Memory II (Libraries)readable and executable

AllocateMemory()

CopyMemory()

ChangePermission()

CODE Memoryreadable and executable

1

2

3

4

Malicious Code

Malicious Code

Malicious Code

Page 15: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Three Decades of Runtime Exploits

Morris Worm1988

Code Injection

AlephOne1996

return-into-libcSolar Designer

1997

Borrowed Code Chunk Exploitation

Krahmer2005

Return-oriented programming

ShachamCCS 2007

Continuing Arms Race

Page 16: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Recent AttacksStagefright [Drake, BlackHat 2015]

These issues in Stagefright code critically expose 95% of Android devices, an estimated 950 million devices

Adversary

MMS

Cisco Router Exploit [2016]

Million CISCO ASA Firewalls potentially vulnerable to attacks

Page 17: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Relevance and Impact

• Web browsers repeatedly exploited

• Zero-day issues exploited in Stuxnet/Duqu [Microsoft, BH 2012]

• iOS jailbreak

High Impact of Attacks

• Microsoft Enhanced Mitigation Experience Toolkit (EMET)

• Microsoft Control Flow Guard (CFG) in Windows 10

• Google‘s compiler extension VTV (vitual table verification)

• Intel Control-Flow Enforcement Technology (CET)

Industry Efforts on Defenses

• A large body of recent literature on attacks and defenses

Hot Topic of Research

Page 18: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Overview on Return-OrientedProgramming

Page 19: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

The Big Picture

n mmo r ien ted Pro g ra ingrutRe

Page 20: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Return-Oriented Programming (ROP)[Shacham, CCS 2007]

Data Area

Code Area

Application Gadget Space(e.g., Shared

Libraries)

MEMORYApplication Address Space

Shared Libraries

MOV

ADD

ESP

CALL

LNOP

XOR

LOAD

STORE

ROP Payload 3

2 Adversary knows the memory layout (memory disclosure)

4Adversary can write ROP payload in the data area (stack/heap)

1 Adversary can hijack control-flow (buffer overflow)

Adversary can construct gadgets

Page 21: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Attack Technique: Overview

Program Stack

Return Address 1

Return Address 2

Value 1

Value 2

Return Address 3

Program Code

REG1:

REG2:

Sequence 1

asm_insPOP {PC}

Sequence 2

POP REG1POP REG2POP {PC}

Sequence 3

asm_insPOP {PC}

SP

Corrupt Control

Structures

Page 22: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Attack Technique: Overview

Program Stack

Return Address 1

Return Address 2

Value 1

Value 2

Return Address 3

Program Code

REG1:

REG2:

Sequence 1

asm_insPOP {PC}

Sequence 2

POP REG1POP REG2POP {PC}

Sequence 3

asm_insPOP {PC}

SP

Page 23: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Attack Technique: Overview

Program Stack

Return Address 1

Return Address 2

Value 1

Value 2

Return Address 3

Program Code

REG1:

REG2:

Value 1

Sequence 1

asm_insPOP {PC}

Sequence 2

POP REG1POP REG2POP {PC}

Sequence 3

asm_insPOP {PC}

SP

Page 24: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Attack Technique: Overview

Program Stack

Return Address 1

Return Address 2

Value 1

Value 2

Return Address 3

Program Code

REG1:

REG2: Value 2

Value 1

Sequence 1

asm_insPOP {PC}

Sequence 2

POP REG1POP REG2POP {PC}

Sequence 3

asm_insPOP {PC}

SP

Page 25: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Attack Technique: Overview

Program Stack

Return Address 1

Return Address 2

Value 1

Value 2

Return Address 3

Program Code

REG1:

REG2: Value 2

Value 1

Sequence 1

asm_insPOP {PC}

Sequence 2

POP REG1POP REG2POP {PC}

Sequence 3

asm_insPOP {PC}

SP

...

Page 26: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Summary of Basic Idea Perform arbitrary computation with return-into-libc

techniques

Approach Use small instruction sequences (e.g., of libc) instead of

using whole functions

Instruction sequences range from 2 to 5 instructions

All sequences end with a return (POP{PC}) instruction

Instruction sequences are chained together to a gadget

A gadget performs a particular task (e.g., load, store, xor, or branch)

Afterwards, the adversary enforces his desired actions by combining the gadgets

Page 27: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Special Aspects of ROP

Page 28: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Code Base and Turing-Completeness

GADGET SPACE

ApplicationCode

SharedLibraries

MOV reg1, 0x1

MOV reg2, 0x2

ADD reg1, reg2

RET

RET

RET

Static Analysis

Page 29: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Code Base and Turing-Completeness

GADGET SPACE

ApplicationCode

SharedLibraries

MOV

Arith.

CALL

Cond. JMP

LOADSTORELogic.

Uncond. JMP

Turing-complete language

MandatoryOptional

Static Analysis

Page 30: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Gadget Space on Different Architectures

B8 13 00 00 00 E9 C3 F8 FF FF

00 00 00 E9 C3

mov $0x13,%eax

jmp 3aae9

add %al,(%eax)

add %ch,%cl

ret

Intended Code

Unintended Code

GADGET SPACEGADGET SPACE

Architectures with memoryalignment, e.g., SPARC, ARM

Architectures with no memoryalignment, e.g., Intel x86

Page 31: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Stack Pivot[Zovi, RSA Conference 2010]

Stack pointer plays an important role

It operates as an instruction pointer in ROP attacks

Challenge

In order to launch a ROP exploit based on a heap overflow, we need to set the stack pointer to point to the heap

This is achieved by a stack pivot

Page 32: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Stack Pivot in Detail

Heap

Return Address 1

Return Address 2

Return Address 3

Stack

TOP of StackSP

Function Ptr

Code

MOV SP, REG1*

POP {PC}

Stack Pivot

label_pivot:

*REG1 is controlled by the adversary and holds beginning of ROP payload

Page 33: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Stack Pivot in Detail

Heap

Return Address 1

Return Address 2

Return Address 3

Stack

TOP of StackSP Code

MOV SP, REG1*

POP {PC}

Stack Pivot

label_pivot:

label_pivot

*REG1 is controlled by the adversary and holds beginning of ROP payload

Page 34: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Stack Pivot in Detail

Heap

Return Address 1

Return Address 2

Return Address 3

Stack

TOP of Stack

SP

Code

MOV SP, REG1*

POP {PC}

Stack Pivot

label_pivot:

*REG1 is controlled by the adversary and holds beginning of ROP payload

label_pivot

Page 35: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ROP Variants

Motivation: return address protection (shadow stack)

Validate every return (intended and unintended) against valid copies of return addresses[Davi et al., AsiaCCS 2011]

Exploit indirect jumps and calls

ROP without returns[Checkoway et al., ACM CCS 2010]

Page 36: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

1997

2001

2005

2007

2008

2009

2010

2011/2012

2013

2014

ret2libcSolar Designer

Advanced ret2libcNergal

Borrowed Code Chunk ExploitationKrahmer

ROP on x86Shacham (CCS)

ROP on SPARCBuchanan et al (CCS)

ROP on Atmel AVRFrancillon et al (CCS)

ROP RootkitsHund et al (USENIX)

ROP on PowerPCFX Lindner (BlackHat)

ROP on ARM/iOSMiller et al (BlackHat)

ROP without ReturnsCheckoway et al (CCS)

Practical ROPZovi (RSA Conference)

Pwn2Own (iOS/IE)Iozzo et al / Nils

JIT-ROPSnow et al (IEEE S&P)

Blind ROPBittau et al (IEEE S&P)

Out-Of-ControlGöktas et al (IEEE S&P)

Stitching GadgetsDavi et al (USENIX)

ROP is DangerousCarlini et al (USENIX)

Flushing AttacksSchuster et al (RAID)

Real-World Exploits

SELECTED

Page 37: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Overview of this Talk

Background/Evolution of Code-Reuse Attacks

Building Code Randomization Defenses

Building Control-Flow Integrity Defenses

Remote Attestation of Embedded Systems

Code-Reuse Attacks

Page 38: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

ASLR – Address Space Layout Randomization

Page 39: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Basics of Code Randomization ASLR randomizes the base address of code/data segments

Program Memory

Heap

Library (e.g., libc)

Stack

Application Run 1

Program Memory

Heap

Stack

Application Run 2

Library (e.g., libc)

ExecutableExecutable

Brute-Force Attack [Shacham et al., ACM

CCS 2004]

Guess Address of Library Function

Page 40: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Basics of Memory Randomization ASLR randomizes the base address of code/data segments

Program Memory

Heap

Library (e.g., libc)

Stack

Application Run 1

Program Memory

Heap

Stack

Application Run 2

Library (e.g., libc)

ExecutableExecutable

Disclosure Attacke.g., [Sotirov et al.,

Blackhat 2008]

1. Exploit disclosure vulnerability

2. Retrieve runtime ADDR

address

3. Revert all library addresses based on ADDR

Page 41: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Fine-Grained Code Randomization

ORP [Pappas et al., IEEE S&P 2012]: Instruction reordering/substitution within a BBL

ILR [Hiser et al., IEEE S&P 2012]: Randomizing each instruction‘s location

STIR [Wartell et al., ACM CCS 2012] & XIFER [Davi et al., AsiaCCS 2013]: Permutation of BBLs

Executable/Library

Application Run 1

Code Block 1

Executable/Library

Application Run 2

Code Block 2

Code Block 3

Code Block 3

Code Block 1

Code Block 2

ASLR

Page 42: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Open Question:Does fine-grained code randomization

provide a viable defense in the long run?

Page 43: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Bad News:Just-in-time code-reuse attacks (JIT-ROP)

bypass fine-grained ASLR protection[K. Z. Snow, L. Davi, A. Dmitrienko, C. Liebchen,

F. Monrose, A.-R. Sadeghi, IEEE S&P 2013, Best Student Paper]

Page 44: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

High-Level Idea

Code Page 1

INS_5

Code Pointer

Page 45: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

High-Level Idea

Code Page 1

INS_1

INS_3

INS_5

INS_6

INS_4

INS_2

Code Pointer

4KB

Scripting Engine

Page Start

Page End

DisassembleJMP INS_10

Page 46: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

High-Level Idea

Code Page 1

INS_1

INS_3

INS_4

INS_5

INS_6

INS_4

INS_2

Code Pointer

Scripting Engine

Code Page 2

INS_7

INS_9

INS_10

INS_12

INS_13

INS_11

INS_8

JMP INS_10

Page 47: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Code Randomization: Lessons Learned

1. Memory disclosure attacks are far more damaging than previously believed

→ A single address-instruction mapping leads to many leaks of code pages

2. Fine-grained ASLR can be bypassed with JIT-ROP

→ Enforce execute-only memory Software-based [Backes et al., CCS 2014]Hardware-based: Readactor(++) [with Crane et al., IEEE S&P 2015 & CCS 2015]

→ Combine code- and execution randomizationIsomeron [with Liebchen et al., NDSS 2015]

→ Mitigating memory disclosure [Gawlik et al., DIMVA 2016]

Page 48: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Overview of this Talk

Background/Evolution of Code-Reuse Attacks

Building Code Randomization Defenses

Building Control-Flow Integrity Defenses

Remote Attestation of Embedded Systems

Code-Reuse Attacks

Page 49: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Basic Idea of Control-Flow Integrity[Abadi et al., ACM CCS 2005 & TISSEC 2009]

A

B

DC

E F

Label_1

Label_2

Label_4

Label_6Label_5

Label_3

Exit(C) == Label_5

Page 50: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Label Granularity: Trade-Offs (1/2)

Many CFI checks are required if unique labels are assigned per node

A

B

DC

E F

Label_1

Label_2

Label_4

Label_6Label_5

Label_3

Exit(B) == [Label_3, Label_4, Label_5]

CFI Check

Basic Block

Label

Page 51: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Label Granularity: Trade-Offs (2/2)

Optimization step: Merge labels to allow single CFI check

However, this allows for unintended control-flow paths

A

B

DC

E F

Label_1

Label_2

Label_4

Label_6Label_5

Label_3

Exit(B) == Label_3

CFI Check

Basic Block

Label

Label_3

Label_3

Exit(C) == Label_3

Page 52: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Label Problem for Returns Static CFI label checking leads to coarse-grained

protection for returns

B

C

AA‘ B‘CALL

RET

Label_1 Label_2

Exit(C) == [Label_1, Label_2]

Program Code

Function A

CALL CCode

Function B

CALL CCode

Function C

CodeRETURN

A‘

B‘

Page 53: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Shadow Stack / Return Address Stack

B

C

AA‘ B‘CALL

RET

Shadow StackBackup storage for return addresses

CALL RET

Backup Check

Shadow stack allows for fine-grained return addressprotection but incurs higher overhead

Exit(C) == ShadowStack[TOS]Return Addr A‘

Page 54: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

CFI: Benefits and Limitations

Average overhead (without shadow stack): 16%; up to 45%

Page 55: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Hot Research Topic:“Practical” (coarse-grained) Control Flow Integrity (CFI)

Recently, many solutions proposed

kBouncer[USENIX Sec’13]

ROPecker[NDSS’14]

ROPGuard[Microsoft EMET]

CFI for COTS Binaries

[USENIX Sec’13]

CCFIR[IEEE S&P’13]

MSBlueHat

Prize

MSBlueHat

Prize

http://technet.microsoft.com/en-us/security/jj653751

EMET

Page 56: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Open Question:Practical and secure mitigation of code

reuse attacks

Turing-completeness of return-orientedprogramming

Page 57: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Negative Result:All current (published)

coarse-grained CFI solutions can bebypassed

[L. Davi, D. Lehmann, F. Monrose, A.-R. Sadeghi, USENIX Sec. 2014]

Page 58: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Big Picture

Systematic Security Analysis of Coarse-Grained CFI

Gadget Analysis

Exploit Development

Turing-complete gadget set

Gadgets to bypass heuristics

CFI Policies

Frequency of CFI Checks

Deriving a CFI policy that combines all schemes

Page 59: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

1. Systematic Security Analysis ofCoarse-Grained CFI

Page 60: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Coarse-grained CFI leads to CFG imprecision

1

2

53

4 6

2

1

11

2 2

Reducing number of

labels

Allowed paths: 1→2 and 2→1

Page 61: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Main Coarse-Grained CFI Policies

CFI Policy 1: Call-Preceded Sequences

Returns need to target a call-preceded instruction

No shadow stack required

CFI Policy 2: Behavioral-Based Heuristics

Prohibit a chain of N short sequences each consisting of less than S instructions

Application

CALL A

INS_1

INS_2

CALL B

INS_3

CALL C

INS_4

RET > S

< S

< S < S < S

1 2 N

Page 62: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Main Coarse-Grained CFI Policies

CFI Policy 1: Call-Preceded Sequences

Returns need to target a call-preceded instruction

No shadow stack required

CFI Policy 2: Behavioral-Based Heuristics

Prohibit a chain of N short sequences each consisting of less than S instructions

Application

CALL A

INS_1

INS_2

CALL B

INS_3

CALL C

INS_4

RET > S

< S

< S < S < S

1 2 N

Threshold SettingkBouncer: (N=8; S<=20)ROPecker: (N=11; S<=6)

Page 63: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Deriving a Combined CFI PolicyCFI Policy kBouncer

[USENIX Sec. 2013]

ROPecker[NDSS 2014]

ROPGuard[Microsoft EMET]

CFI for COTS Binaries[USENIX Sec. 2013]

Combined CFI Policy

CFI Policy 1Call-Preceded Sequences

CFI Policy 2Behavioral-Based Heuristics

Time of CFI Check WinAPI 2 Page Sliding

Window/Critical

Functions

WinAPI/Critical

Functions

IndirectBranch

Any Time

No Restriction CFI Policy

Here only the core policies shown. However, we consider all other deployed policies in our analysis.

Page 64: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

2. Gadget Analysis

Page 65: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Methodology

Common Library

kernel32.dll

Sequence Subset 1

Sequence Subset n

MOV

ADD

ESP

CALL

LNOP

XOR

Sequence Finder (IDA Pro)

List of Call-Preceded

Sequences

Sequence Filter(D Program)

Provide filters onReg, Ins, Opnd, Length

Gadget Generation (manual)

Search for Gadgets

LOAD

STORE

Page 66: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

(Excerpt of) Turing-Complete Gadget Set in CFI-Protected kernel32.dll

Gadget Type CALL-Preceded Sequenceending in a RET instruction

LOADRegister

EBP := pop ebpESI := pop esi; pop ebpEDI := pop edi; leaveECX := pop ecx; leaveEBX := pop edi; pop esi; pop ebx; pop ebpEAX := mov eax,edi; pop edi; leaveEDX := mov eax,[ebp-8]; mov edx,[ebp-4]; pop edi; leave

LOAD/STOREMemory

LD(EAX) := mov eax,[ebp+8]; pop ebpST(EAX) := mov [esi],eax; xor eax,eax; pop esi; pop ebpST(ESI) := mov [ebp-20h],esiST(EDI) := mov [ebp-20h],edi

Arithmetic/Logical

ADD/SUB := sub eax,esi; pop esi; pop ebpXOR := xor eax,edi; pop edi; pop esi; pop ebp

Branches unconditional branch 1 := leaveunconditional branch 2 := add esp,0Ch; pop ebpconditional LD(EAX) := neg eax; sbb eax,eax; and eax,[ebp-4]; ………………………………………………………….leave

Page 67: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Long-NOP Gadget

ROP Gadget 1

Store Registers

PrepareLong NOP

Long NOP

ResetRegisters

ROP Gadget 2

ESI

EDI

EBX

Stack

StaticConstants

Arbitrary Data Area (36 Bytes)

ESI

EDI

Page 68: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

3. Exploit Development

Adobe Reader 9.1 CVE-2010-0188

MPlayer Lite r33064 m3u Buffer Overflow Exploit

Original exploitsdetected by coarse-

grained CFI

Our instrumentedexploits bypass coarse-

grained CFI

Page 69: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Coarse-Grained CFI: Lessons Learned

1. Too many call sites available

→ Restrict returns to their actual caller (shadow stack)

2. Heuristics are ad-hoc and ineffective

→ Adjusted sequence length leads to high false positive

3. Too many indirect jump and call targets

Resolving indirect jumps and calls is non-trivial

→ Compromise: Compiler support

Page 70: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

HAFIX: Hardware Flow Integrity Extensions[O. Arias, L. Davi, M. Hanreich, Y. Jin, P. Koeberl, D. Paul,

A.-R. Sadeghi, D. Sullivan, DAC 2015 & 2016]

Page 71: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Design Decisions: Why CFI Processor Support?

CFI Processor Support based on Instruction set architecture (ISA) extensions

High efficiency

Dedicated CFI instructions

System-wide protection

CFI control state

Binding of CFI data to CFI state and instructions

Page 72: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Big Picture

State 0Normal Execution

Function Calls

Indirect Jumps

Function Returns

CFI StateOnly CFI instructions allowed

CFI Check Call

CFI Check Jump

CFI Check Return

Page 73: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Return to the Original Caller

State 0Normal Execution Label State

Stack (LSS)

CFI StateOnly CFI instructions

allowed

CFIBR label_A1

CFIRET label_A1

Function A

CALL B Code

Function B

CodeRET

label_A1

Function A

CALL BCFIRET label_A1

Function B

CodeRET

CFIBR label_A1

Code

Page 74: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

0

0,5

1

1,5

CoreMark bzip2 libquantum h264ref

Base CFI perf. Bin. size ratio

Evaluation

On average 1%-2% performance

overhead

On average 13.5%increase in code size

Page 75: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Overview of this Talk

Background/Evolution of Code-Reuse Attacks

Building Code Randomization Defenses

Building Control-Flow Integrity Defenses

Remote Attestation of Embedded Systems

Code-Reuse Attacks

Page 76: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Remote attestation checks trustworthiness of a remote

(embedded) device

Page 77: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Background: Principle of Remote Attestation

Prover

Measure software

state

Challenge

Verifier

Authentic Report

Goal: Check if prover is now in a trustworthy state

Measurement Database

VerifyReport

Attestation Protocol

Page 78: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

History of Remote Attestation

TPM Attestation

2001

Dynamic Root of Trust

2005

Software-based Attestation

2004

Property-based attestation

2004

Minimal Trust Anchors

2010

PUF-based Attestation

2011

SWARM Attestation

2015

SEDA [CCS’15]SANA [CCS’16]DARPA [WiSEC’16]

Property-based Attest. [NSPW’04]Behavior-based Trust [NSPW’04]Semantic Remote Attest. [VM’04]

AMD SVMIntel TXTIntel SGXFlicker [Eurosys’08]…

POSE [ESORICS’10]SMART [NDSS’12,DATE’14]TrustLite [Eurosys’14]

Pioneer [SOSP’05]…SWATT [SP’04]

PUFatt [DAC’14]Lightweight PUF Attest. [WiSEC’11]

Page 79: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Key Limitation:current binary attestation schemes

do not address runtime attacks

Page 80: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Problem Space of Runtime Attacks

A

B

EDC

F

X

Adversary

A

B

EDC

FDEP

Memory write

Program flow

inject maliciouscode

corrupt codepointer

Control-Flow Attack[Shacham, ACM CCS 2007]

[Schuster et al., IEEE S&P 2015]

Non-Control-Data Attack[Chen et al., USENIX Sec. 2005]

[Carlini et al., USENIX Sec. 2015]

corrupt datapointer/variable

switch(opmode)case recovery: Ccase op1: Dcase op2: E,F

Page 81: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Related Work

Control-flow integrity

(CFI) [Abadi et al.,

CCS’05]

Data-flow integrity

(DFI) [Castro et al.,

OSDI’06]

Code-pointer integrity

(CPI) [Kuznetsov et al., OSDI’14]

Remote Dynamic

Attestation [Kil et al., DSN’09]

Not suitable for control-flow attestation

Integrity-based schemes usually target a specific runtime attack class

These schemes only output whether an attack occurred but don’t attest the control-flow path

Page 82: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT[with Abera et al., CCS 2016]

Design and implementation of control-flow attestation (C-FLAT)

Detection of control-flow and non-control-data attacks

Two case studies based on embedded system software

Page 83: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Big PictureProverVerifier

Control-Flow Graph (CFG)

Analysis

App A

Path Measurement

P1 P2

LP1 App A

P1

P1 , #LP1

P2

Run-Time Path Measurement

P*x P*2

Control-Flow Validation

P*x

P*2

Page 84: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

How to attest the executed control flows without transmitting all executed

branches?

Page 85: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT Measurement FunctionCumulative Hash Value: Hi = H ( Hi-1, N )

Hi-1 -- previous hash result

N -- instruction block (node) just executed

A

B

EDC

F

H1=H(0,A)

H2=H(H1,B)

H5=H(H2,E)

H6=H(H5,F)

H3=H(H2,C) H4=H(H2,D)

Page 86: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Loops are a challenge!

Different loop paths and loop iterations lead to many valid

hash values

Page 87: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT Approach:

Treat loops as sub-graphsand report their hash values

and # of iterations separately

Page 88: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT: Loop Handling

B

C

ED

F

A

Fwhile (cond.) {…}

if (cond.) {…}

Page 89: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT: Loop Handling

B

C

ED

F

H1=H(0,A)

H2a=H(0,B)

H6a=H(H4,F)H7=H(H2b,F)

A

FH2b=H(H1,B)

H3=H(H2a,C)

H4=H(H3,D) H5=H(H3,E)

H3=H(H2a,C)

H6b=H(H5,F)

H1H6a,#H6a

H6b,#H6b

Loop Entry Hash

Loop Hash,Iteration

Page 90: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

C-FLAT loop handling includes support of nested loops, break statements, and

recursive functions

Page 91: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Implementation

Page 92: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Prototype Architecture

Implementation on Raspberry Pi 2

Measurement Engine and Attestation

Hardware

ApplicationBinary

Trampolines

Page 93: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Binary Instrumentation

Function A

BL Function B

asm_ins

Function B

PUSH {…,LR}

POP {…,PC}

asm_ins

BLX R3

Function C

asm_ins

BX LRasm_ins

Function A

BL Direct-Call

asm_ins

Function B

PUSH {…,LR}

BL Stack-Return

asm_ins

BL Reg-Call

Function C

asm_ins

BL Reg-Returnasm_ins

Trampoline per branch type

Store ContextSave LR

Lookup TargetSecure Monitor

Call

Restore ContextBranch dest

Branch Table

Saved LR

R1

R2

… …

LR

C-FLAT Measure-

mentEngine

R1R2

src,destRestore LR

…R2

Page 94: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Evaluation: Case Studies

Syringe PumpSoldering Iron Temperature Controller

Page 95: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Syringe Pump

Source: https://hackaday.io/project/1838-open-syringe-pump

• Original implementation targets Arduino boards

• We ported the code to Raspberry Pi• 13,000 instructions with 332 CFG

edges of which 20 are loops• Main functions are set-quantity and

move-syringe

Page 96: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Applying C-FLAT to Syringe Pump

while (1) {if (serialReady()) {cfa_init;processSerial();cfa_quote;

}}

1

if (input == ’+’) {action(PUSH,bolus);updateScreen();

} else if (input == ’-’) {

action(PULL,bolus);updateScreen();

}

steps = bolus * steps_per_mLif (direction == PUSH) {

/* set stepper direction */} else { /* PULL */

/* set stepper direction */}for (steps) {

/* move stepper */}

23

9

10

11

1213

4

6

7

8processSerial()

action(direction,bolus)

14

5

main()

bolus = dose of drug;volume of cylinder for a

particular heightx

Please note that this slide shows a simplified view of the Syringe pump code and control-flow graph.

Page 97: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Final Hash Measurements

steps = bolus * steps_per_mLif (direction = PUSH) {

/* set stepper direction */} else /* PULL */

/* set stepper direction */}for (steps) {

/* move stepper */}

4

6

7

8

action(direction,bolus)

5

b3 c5 ca c4 6f dc 6a d0 4a 80 10 09 af a3 59 70

e0 9a f6 48 11 65 17 94 a7 0b 06 f0 ba e4 75 75

97 78 fb fc 93 09 4e d7 ac 32 5d 65 eb 29 08 0c(#iterations)

Final Measurements for PUSH, PULL operations:

Loop Measurement:

Page 98: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

PUSH 0.1 mLUsed 0.100 mLBolus 0.100 mL[INFO] cfa_quote: 57 92 0f 9e 98 47 30 bb a5 f7 5d 2a dc 8a 7b 5f

[INFO] loop[000]: b3 c5 ca c4 6f dc 6a d0 4a 80 10 09 af a3 59 70[INFO] path[000]: 97 78 fb fc 93 09 4e d7 ac 32 5d 65 eb 29 08 0c (682)[INFO] loop[001]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (1)[INFO] loop[002]: 6d 05 6e b2 3a 27 1e 2b 78 3e f9 4c e3 a7 cb f8[INFO] path[000]: 62 f7 b8 0b 65 4b de 35 c7 05 bc 28 06 43 11 6e (2)[INFO] loop[003]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (3)[INFO] loop[004]: f5 77 b7 94 bd 6c 81 e2 2f 36 da ad cd df 56 6e[INFO] path[000]: 67 c6 5e d4 18 13 02 bc 4a 5d 60 a0 16 85 f4 ed (9)[INFO] path[001]: 78 19 af 09 0f d5 64 f4 39 b4 7a 0d 97 57 77 8c (2)[INFO] loop[005]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (1)[INFO] loop[006]: 6d 05 6e b2 3a 27 1e 2b 78 3e f9 4c e3 a7 cb f8[INFO] path[000]: 62 f7 b8 0b 65 4b de 35 c7 05 bc 28 06 43 11 6e (2)[INFO] loop[007]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (3)[INFO] loop[008]: ca 34 cb 8a 0b 8a 76 41 0f 59 e9 b2 8d 76 91 30[INFO] path[000]: 67 c6 5e d4 18 13 02 bc 4a 5d 60 a0 16 85 f4 ed (10)[INFO] path[001]: 78 19 af 09 0f d5 64 f4 39 b4 7a 0d 97 57 77 8c (2)[INFO] loop[009]: 2d 80 99 2c f1 61 b1 19 53 4d 0a 96 be be a8 1f[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (13)[INFO] loop[010]: d2 32 da 39 c8 7f 0d bb 13 c0 a7 12 7d 4b 0c ce[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (2)[INFO] loop[011]: 73 e3 be b7 33 30 58 5a 59 1b 2b c0 60 50 c6 36[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (14)[INFO] loop[012]: c2 88 83 00 68 dd 41 32 2c 0d 37 f6 d3 be fd 09[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (2)

PUSH 0.2 mLUsed 0.200 mLBolus 0.200 mL[INFO] cfa_quote: 57 92 0f 9e 98 47 30 bb a5 f7 5d 2a dc 8a 7b 5f

[INFO] loop[000]: b3 c5 ca c4 6f dc 6a d0 4a 80 10 09 af a3 59 70[INFO] path[000]: 97 78 fb fc 93 09 4e d7 ac 32 5d 65 eb 29 08 0c (1365)[INFO] loop[001]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (1)[INFO] loop[002]: 6d 05 6e b2 3a 27 1e 2b 78 3e f9 4c e3 a7 cb f8[INFO] path[000]: 62 f7 b8 0b 65 4b de 35 c7 05 bc 28 06 43 11 6e (2)[INFO] loop[003]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (3)[INFO] loop[004]: f5 77 b7 94 bd 6c 81 e2 2f 36 da ad cd df 56 6e[INFO] path[000]: 67 c6 5e d4 18 13 02 bc 4a 5d 60 a0 16 85 f4 ed (9)[INFO] path[001]: 78 19 af 09 0f d5 64 f4 39 b4 7a 0d 97 57 77 8c (2)[INFO] loop[005]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (1)[INFO] loop[006]: 6d 05 6e b2 3a 27 1e 2b 78 3e f9 4c e3 a7 cb f8[INFO] path[000]: 62 f7 b8 0b 65 4b de 35 c7 05 bc 28 06 43 11 6e (2)[INFO] loop[007]: eb 16 88 8a d2 3b c6 19 f9 01 94 5d ee cb 1c 13[INFO] path[000]: b9 7d cf 8d 00 b6 5f 63 b3 7c 60 e4 e3 be 56 17 (3)[INFO] loop[008]: ca 34 cb 8a 0b 8a 76 41 0f 59 e9 b2 8d 76 91 30[INFO] path[000]: 67 c6 5e d4 18 13 02 bc 4a 5d 60 a0 16 85 f4 ed (10)[INFO] path[001]: 78 19 af 09 0f d5 64 f4 39 b4 7a 0d 97 57 77 8c (2)[INFO] loop[009]: 2d 80 99 2c f1 61 b1 19 53 4d 0a 96 be be a8 1f[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (13)[INFO] loop[010]: d2 32 da 39 c8 7f 0d bb 13 c0 a7 12 7d 4b 0c ce[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (2)[INFO] loop[011]: 73 e3 be b7 33 30 58 5a 59 1b 2b c0 60 50 c6 36[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (14)[INFO] loop[012]: c2 88 83 00 68 dd 41 32 2c 0d 37 f6 d3 be fd 09[INFO] path[000]: 74 af 0f dc 3b 17 ff 67 03 72 d0 db fe b5 94 78 (2)

C-FLAT Log for PUSH action

Only the number of loop iterations is different per bolus

682 (0.1 ml), 1365 (0.2 ml)

Page 99: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Attacking the Syringe Pump

Constructed several exploits to validate the effectiveness of C-FLAT

Control-flow attack uses ROP to dispense liquid at unexpected time

→C-FLAT detects attack due to unexpected measurement

Non-control-data attack that dispenses more liquid than requested

→C-FLAT detects attack due to an unexpectedly high number of loop iterations

Page 100: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Discussion

C-FLAT attests control flow

Pure data attacks that don’t affect control flow are notcovered

Scalability depends on program size and complexity

We target typical (simple) embedded software, e.g., Syringe Pump that scales well for C-FLAT

Reducing context switch overhead

ARMv8 Cortex-A53 needs ~3700 cycles at 800MHz; TrustZone-M only requires a few cycles

Page 101: Lecture: Code-Reuse Attacks and Defenses · [Zovi, RSA Conference 2010] Stack pointer plays an important role It operates as an instruction pointer in ROP attacks Challenge In order

Conclusion

Code-reuse attacks are prevalent

Google, Microsoft, Intel take these attacks seriously

Many real-world exploits

Existing solutions can be bypassed

Control-flow integrity (CFI) and fine-grained randomization are promising defense techniques

Highly efficient hardware-assisted CFI enforcement

Fine-grained ASLR coupled with execute-only memory defends against JIT-ROP attacks