Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page...

66
Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck 1 Nico Weichbrodt 2 udiger Kapitza 2 Frank Piessens 1 Raoul Strackx 1 1 imec-DistriNet, KU Leuven 2 IBR DS, TU Braunschweig August 18, 2017 Jo Van Bulck et al. Telling Your Secrets Without Page Faults 1 / 14

Transcript of Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page...

Page 1: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Telling Your Secrets Without Page Faults:

Stealthy Page Table-Based Attacks on Enclaved Execution

Jo Van Bulck 1 Nico Weichbrodt 2 Rudiger Kapitza 2

Frank Piessens 1 Raoul Strackx 1

1imec-DistriNet, KU Leuven 2IBR DS, TU Braunschweig

August 18, 2017

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 1 / 14

Page 2: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Introduction

Road Map

1 Introduction

2 Controlled-Channel Attacks and Defenses

3 Stealthy Page Table-Based Attacks

4 Conclusions

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 1 / 14

Page 4: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Introduction

Motivation: Application Attack Surface

Mem HDD

OS kernel

AppApp

Trusted Untrusted

CPU

AppApp

TPM

Hypervisor

Layered architecture → large trusted computing base

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 3 / 14

Page 5: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Introduction

Motivation: Application Attack Surface

Mem HDD

OS kernel

AppApp

Trusted Untrusted

CPU

AppApp

TPM

Hypervisor

Layered architecture → large trusted computing base

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 3 / 14

Page 6: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Introduction

Motivation: Application Attack Surface

Mem HDD

OS kernel

AppApp

Trusted Untrusted

CPU

AppApp

TPM

Hypervisor

SG

X e

ncla

ves

Intel SGX promise: hardware-level isolation and attestation

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 3 / 14

Page 7: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Introduction

Motivation: Application Attack Surface

Mem HDD

OS kernel

AppApp

Trusted Untrusted

CPU

AppApp

TPM

Hypervisor

SG

X e

ncla

ves

Untrusted OS → new class of powerful side-channels

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 3 / 14

Page 8: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Road Map

1 Introduction

2 Controlled-Channel Attacks and Defenses

3 Stealthy Page Table-Based Attacks

4 Conclusions

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 3 / 14

Page 9: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

The Virtual Memory Abstraction

VirtualAddress

Physical AddressMapping

PageTables

VirtualAddress Space

PhysicalAddress Space

Address Translation

Software DRAM

System bus

Costan et al. “Intel SGX explained”, IACR 2016 [CD16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 4 / 14

Page 10: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

How Enclave Accesses are Enforced

Note: Untrusted OS controls virtual-to-physical mapping

Costan et al. “Intel SGX explained”, IACR 2016 [CD16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 5 / 14

Page 11: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

How Enclave Accesses are Enforced

Note: Untrusted OS controls virtual-to-physical mapping

Costan et al. “Intel SGX explained”, IACR 2016 [CD16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 5 / 14

Page 12: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

How Enclave Accesses are Enforced

Note: Additional checks after address translation

Pagewalk?

Enclavemode?

padrs inPRM?

Allow

Page fault vadrs inenclave?

Abort page

padrs inEPC?

EPCMchecks?

ok no

yes

no

yesfail

no

yes

failyes ok

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 5 / 14

Page 13: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

How Enclave Accesses are Enforced

Note: Additional checks after address translation

Pagewalk?

Enclavemode?

padrs inPRM?

Allow

Page fault vadrs inenclave?

Abort page

padrs inEPC?

EPCMchecks?

ok no

yes

no

yesfail

no

yes

failyes ok

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 5 / 14

Page 14: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Page Faults as a Side-Channel

Xu et al.: “Controlled-channel attacks: Deterministic side channels for untrusted operating systems”, Oakland 2015 [XCP15]

⇒ Page fault traces leak private control flow/data accesses

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 6 / 14

Page 15: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Page Faults as a Side-Channel

Xu et al.: “Controlled-channel attacks: Deterministic side channels for untrusted operating systems”, Oakland 2015 [XCP15]

⇒ Low-noise, single-run exploitation of legacy applications

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 6 / 14

Page 16: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Current Solutions: Hiding Enclave Page Faults

Pagewalk?

Enclavemode?

padrs inPRM?

Allow

Page fault vadrs inenclave?

Abort page

padrs inEPC?

EPCMchecks?

ok no

yes

no

yesfail

no

yes

failyes ok

Shih et al. “T-SGX: Eradicating controlled-channel attacks against enclave programs”, NDSS 2017 [SLKP17]

Shinde et al. “Preventing page faults from telling your secrets”, AsiaCCS 2016 [SCNS16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 7 / 14

Page 17: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Current Solutions: Hiding Enclave Page Faults

Pagewalk?

Enclavemode?

padrs inPRM?

Allow

Page fault vadrs inenclave?

Abort page

padrs inEPC?

EPCMchecks?

ok no

yes

no

yesfail

no

yes

failyes ok

Shih et al. “T-SGX: Eradicating controlled-channel attacks against enclave programs”, NDSS 2017 [SLKP17]

Shinde et al. “Preventing page faults from telling your secrets”, AsiaCCS 2016 [SCNS16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 7 / 14

Page 18: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Current Solutions: Hiding Enclave Page Faults

Pagewalk?

Enclavemode?

padrs inPRM?

Allow

Page fault vadrs inenclave?

Abort page

padrs inEPC?

EPCMchecks?

ok no

yes

no

yesfail

no

yes

failyes ok

Defenses do not hold when attacker learns page accesses without triggering faults!

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 7 / 14

Page 19: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Controlled-Channel Attacks and Defenses

Current Solutions: Hiding Enclave Page Faults

Directory Ptr

PTE

Linear Address

Page Table

PDPTE

CR3

39 38

Pointer Table

99

40

129

40

4-KByte Page

Offset

Physical Addr

PDE with PS=0

Table

011122021

Directory

30 29

Page-Directory-

Page-Directory

PML4

47

9

PML4E

40

40

40

Defenses do not hold when attacker learns page accesses without triggering faults!

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 7 / 14

Page 20: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Road Map

1 Introduction

2 Controlled-Channel Attacks and Defenses

3 Stealthy Page Table-Based Attacks

4 Conclusions

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 7 / 14

Page 21: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 22: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 23: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

CLEAR

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 24: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

EENTER

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 25: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

Page Table

Walk

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 26: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

ACCESSED ?

Page Table

Walk

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 27: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

Pag

e T

ab

le

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 28: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE bCach

e

FLUSH

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 29: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

EENTER

Cach

e

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 30: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE bCach

e

Page Table

Walk

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 31: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

SGX Side-Channel Leakage: Page Table Entries

1 Attack vector: PTE status flags:

A(ccessed) bitD(irty) bit

Also updated in enclave mode!

2 Attack vector: Unprotected page table memory:

Cached as regular dataAccessed during address translation

Flush+Reload cache timing attack!

void inc_secret( void ){ if (secret) *a += 1; else *b += 1;}

PTE a

PTE b

RELOAD

Cach

e

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 8 / 14

Page 32: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

SECRET = 01010

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 33: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

ACCESSED ?

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 34: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

ACCESSED ?

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 35: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

ACCESSED ?

IRQ/AEX

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 36: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

ACCESSED ?

IRQ/AEX

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 37: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

#PF-Less Challenges: Monitoring Repeated Accesses

1 Challenge: No #PF on memory access

Monitor PTEs from concurrent spy thread

2 Challenge: Translation Lookaside Buffer (TLB)

Directed Inter-Processor Interrupt

3 Challenge: Temporal resolution (IPI latency)

Precise Flush+Flush technique

void inc_secret( void ){ for (i=0; i < len; i++) { if (secret[i]) *a += 1; else *b += 1; }}

PTE a

PTE b

Pag

e T

ab

le

FLUSH

IRQ/AEX

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 9 / 14

Page 38: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

PTE Flush+Flush: A High-Resolution, Low-Latency Channel

Resolution Challenge

∃ access detection latency ↔ #PF-attacks

Interrupt granularity:

/ A/D monitoring: ∼ 430 nop / ∼ 175 add

/ Flush+Reload: might miss victim access (TLB!)

, Flush+Flush: interrupt within trigger instruction (> 99.8%)

(a) Victim PTE access maccess

(b) Flush+Reload hit

(c) Flush+Reload miss reload

(d) Flush+Flush hit flush

time

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 10 / 14

Page 39: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

PTE Flush+Flush: A High-Resolution, Low-Latency Channel

Resolution Challenge

∃ access detection latency ↔ #PF-attacks

Interrupt granularity:

/ A/D monitoring: ∼ 430 nop / ∼ 175 add

/ Flush+Reload: might miss victim access (TLB!)

, Flush+Flush: interrupt within trigger instruction (> 99.8%)

(a) Victim PTE access maccess

(b) Flush+Reload hit

(c) Flush+Reload miss reload

(d) Flush+Flush hit flush

time

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 10 / 14

Page 40: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

PTE Flush+Flush: A High-Resolution, Low-Latency Channel

Resolution Challenge

∃ access detection latency ↔ #PF-attacks

Interrupt granularity:

/ A/D monitoring: ∼ 430 nop / ∼ 175 add

/ Flush+Reload: might miss victim access (TLB!)

, Flush+Flush: interrupt within trigger instruction (> 99.8%)

(a) Victim PTE access maccess

(b) Flush+Reload hit

(c) Flush+Reload miss reload

(d) Flush+Flush hit flush

time

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 10 / 14

Page 41: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

PTE Flush+Flush: A High-Resolution, Low-Latency Channel

Resolution Challenge

∃ access detection latency ↔ #PF-attacks

Interrupt granularity:

/ A/D monitoring: ∼ 430 nop / ∼ 175 add

/ Flush+Reload: might miss victim access (TLB!)

, Flush+Flush: clflush completes earlier for uncached data

Gruss et al. “Flush+Flush: a fast and stealthy cache attack”, DIMVA 2016 [GMWM16]

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 10 / 14

Page 42: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

PTE Flush+Flush: A High-Resolution, Low-Latency Channel

Resolution Challenge

∃ access detection latency ↔ #PF-attacks

Interrupt granularity:

/ A/D monitoring: ∼ 430 nop / ∼ 175 add

/ Flush+Reload: might miss victim access (TLB!)

, Flush+Flush: interrupt within trigger instruction (> 99.8%)

(a) Victim PTE access maccess

(b) Flush+Reload hit

(c) Flush+Reload miss reload

(d) Flush+Flush hit flush

time

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 10 / 14

Page 43: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 11 / 14

Page 44: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 11 / 14

Page 45: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA

EdDSA secret scalar notstored in "secure memory" !

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 11 / 14

Page 46: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA

Secret-dependent control flow

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 11 / 14

Page 47: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: A/D Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

22 Code pagesper iteration

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 12 / 14

Page 48: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: A/D Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

ACCESSED ?

Memory layout

Monitortrigger page

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 12 / 14

Page 49: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: A/D Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

INTERRUPT

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 12 / 14

Page 50: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: A/D Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

ACCESSED ?

ACCESSED ?

Record page set0011

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 12 / 14

Page 51: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: A/D Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

RESUME

Full 512-bit key recovery, single run

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 12 / 14

Page 52: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

22 Code pagesper iteration

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 53: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

gcry_free

...

mpi_test_bit

mpi_ec_add_p

mpi_ec_mul_p

0x0F000

0xC0000

0xC1000

mpi_add

0xC9000

0xCA000

...

...

...

Only 11 distinctPTE cache lines

Memory layout

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 54: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

errno_loc...

errno_plt

mpi_test_bit

mpi_ec_mul_p

_gpgrt_lock

...

...

...

Memory layout

int_free

gpgrt_lock

do_malloc...

...

...

FLUSH

Monitor isolatedtrigger page

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 55: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

errno_loc...

errno_plt

mpi_test_bit

mpi_ec_mul_p

_gpgrt_lock

...

...

...

Memory layout

int_free

gpgrt_lock

do_malloc...

...

...

INTERRUPT

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 56: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

errno_loc...

errno_plt

mpi_test_bit

mpi_ec_mul_p

_gpgrt_lock

...

...

...

Memory layout

int_free

gpgrt_lock

do_malloc...

...

...

RELOAD

Record biggerpage set

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 57: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Stealthy Page Table-Based Attacks

Attacking Libgcrypt EdDSA: Cache-Only Channel

errno_loc...

errno_plt

mpi_test_bit

mpi_ec_mul_p

_gpgrt_lock

...

...

...

Memory layout

int_free

gpgrt_lock

do_malloc...

...

...

Regex pattern match -> 485/512-bit recovery, single-run

RELOAD

Record biggerpage set

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 58: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Conclusions

Road Map

1 Introduction

2 Controlled-Channel Attacks and Defenses

3 Stealthy Page Table-Based Attacks

4 Conclusions

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 13 / 14

Page 59: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Conclusions

Conclusion

Take-Away Message

Enclave memory accesses can be learned without triggering page faults.

⇒ Do not focus on attack side-effects (faults, frequent enclave preemptions)

⇒ Address root causes of information leakage:

Unprotected page table memory (Sanctum [CLD16])

Secret-dependent control flow/data access (Libgcrypt patch)

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 14 / 14

Page 60: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Conclusions

Conclusion

Take-Away Message

Enclave memory accesses can be learned without triggering page faults.

⇒ Do not focus on attack side-effects (faults, frequent enclave preemptions)

⇒ Address root causes of information leakage:

Unprotected page table memory (Sanctum [CLD16])

Secret-dependent control flow/data access (Libgcrypt patch)

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 14 / 14

Page 61: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Conclusions

Conclusion

Take-Away Message

Enclave memory accesses can be learned without triggering page faults.

⇒ Do not focus on attack side-effects (faults, frequent enclave preemptions)

⇒ Address root causes of information leakage:

Unprotected page table memory (Sanctum [CLD16])

Secret-dependent control flow/data access (Libgcrypt patch)

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 14 / 14

Page 62: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Conclusions

Thank you! Questions?https://github.com/jovanbulck/sgx-pte

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 14 / 14

Page 63: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Appendix

References I

V. Costan and S. Devadas.

Intel SGX explained.Technical report, Computer Science and Artificial Intelligence Laboratory MIT, 2016.https://eprint.iacr.org/2016/086.pdf.

V. Costan, I. Lebedev, and S. Devadas.

Sanctum: Minimal hardware extensions for strong software isolation.In 25th USENIX Security Symposium, pp. 857–874. USENIX Association, 2016.

D. Gruss, C. Maurice, K. Wagner, and S. Mangard.

Flush+flush: A fast and stealthy cache attack.In Detection of Intrusions and Malware, and Vulnerability Assessment (DIMVA), 2016.

S. Shinde, Z. L. Chua, V. Narayanan, and P. Saxena.

Preventing page faults from telling your secrets.In Proceedings of the 11th ACM on Asia Conference on Computer and Communications Security (ASIA CCS), pp. 317–328. ACM, 2016.

M.-W. Shih, S. Lee, T. Kim, and M. Peinado.

T-SGX: Eradicating Controlled-Channel Attacks Against Enclave Programs.In 24th Annual Network and Distributed System Security Symposium (NDSS), 2017.

C.-C. Tsai, D. E. Porter, and M. Vij.

Graphene-SGX: A practical library OS for unmodified applications on SGX.In 2017 USENIX Annual Technical Conference (USENIX ATC). USENIX Association, 2017.

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 15 / 14

Page 64: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Appendix

References II

Y. Xu, W. Cui, and M. Peinado.

Controlled-channel attacks: Deterministic side channels for untrusted operating systems.In 2015 IEEE Symposium on Security and Privacy, pp. 640–656. IEEE, 2015.

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 16 / 14

Page 65: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Appendix

IPI Latency Microbenchmarks

Table: IPI latency in terms of the number of instructions executed by the victim after accessing the trigger page.

Accessed Flush+Flush

Experiment Mean σ Mean σ Zero %

nop 431.70 34.11 0.65 17.65 99.84add register 176.30 14.60 0.15 6.18 99.94add memory 32.45 2.79 0.06 1.92 99.88nop nocache 0.02 0.39 – – –

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 17 / 14

Page 66: Telling Your Secrets Without Page Faults...Telling Your Secrets Without Page Faults: Stealthy Page Table-Based Attacks on Enclaved Execution Jo Van Bulck1 Nico Weichbrodt2 Rudiger

Appendix

Putting it All Together: Inferring Page Access Patterns

Re-usable attack framework: Graphene-SGX [TPV17]

Explicitly monitor trigger page(s)

Capture max info in page sets ↔ #PF-sequences

Offline analysis: extract access patterns

⇒ overcome measurement noise/ latency/ granularity

App Binarylibc

Graphene TRTS

Enclave

Graphene URTSApp

spy

PTE Set

DriverPage Table

Kernel

Hardware

1 5

2

3

8

4

7

IPI E6

Jo Van Bulck et al. Telling Your Secrets Without Page Faults 18 / 14