Eliminating cache-based timing attacks with instruction-based - - PowerPoint PPT Presentation

eliminating cache based timing attacks with instruction
SMART_READER_LITE
LIVE PREVIEW

Eliminating cache-based timing attacks with instruction-based - - PowerPoint PPT Presentation

Eliminating cache-based timing attacks with instruction-based scheduling Deian Stefan , Pablo Buiras, Edward Z. Yang, Amit Levy, David Terei, Alejandro Russo, and David Mazires Motivation: IFC Web platforms Platforms allow 3rd-party developers


slide-1
SLIDE 1

Eliminating cache-based timing attacks with instruction-based scheduling

Deian Stefan, Pablo Buiras, Edward Z. Yang, Amit Levy, David Terei, Alejandro Russo, and David Mazières

slide-2
SLIDE 2

Platforms allow 3rd-party developers to build apps that use our personal data

➤ Extend the websites beyond original intent!

Motivation: IFC Web platforms

slide-3
SLIDE 3

Platforms allow 3rd-party developers to build apps that use our personal data

➤ Extend the websites beyond original intent!

Motivation: IFC Web platforms

^and sometimes leak

slide-4
SLIDE 4

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ...
slide-5
SLIDE 5

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ...

slide-6
SLIDE 6

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ...
slide-7
SLIDE 7

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ...
slide-8
SLIDE 8

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ... ✦ All your contacts
slide-9
SLIDE 9

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A ✦ All your contacts
slide-10
SLIDE 10

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A Name: Jullian Assange Nick: Big J Occupation: make U.S. gov unhappy ✦ All your contacts
slide-11
SLIDE 11

Motivation: IFC Web platforms

Challenge: can we ensure apps don’t leak data? Current approach: DAC

➤ Restrict what data app

can access Cannot guarantee what app does with data

address book

Platform

photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A Name: Jullian Assange Nick: Big J Occupation: make U.S. gov unhappy ✦ All your contacts
slide-12
SLIDE 12
slide-13
SLIDE 13

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ...
slide-14
SLIDE 14

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ... IFC: Can app read sensitive data from the database?
slide-15
SLIDE 15

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A IFC: Can app read sensitive data from the database?
slide-16
SLIDE 16

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A Name: Jullian Assange Nick: Big J Occupation: make U.S. gov unhappy IFC: Can app read sensitive data from the database?
slide-17
SLIDE 17

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A Name: Jullian Assange Nick: Big J Occupation: make U.S. gov unhappy IFC: Can app read sensitive data from the database? IFC: Can app write sensitive data to nsa.gov?
slide-18
SLIDE 18

Hails platform

Motivation: IFC Web platforms

Solution: Information flow control Web platform: Hails Hails IFC enforcement:

➤ Restrict what data app

can access with clearance

➤ Restrict who app can

communicate with depending on data it reads

address book photo editor ... Name: Joe Smith Nick: Small J Occupation: N/A Name: Jullian Assange Nick: Big J Occupation: make U.S. gov unhappy IFC: Can app read sensitive data from the database? IFC: Can app write sensitive data to nsa.gov?

slide-19
SLIDE 19

GHC Haskell Runtime LIO IFC system Hails framework

wiki.gitstar.com

≀ ≀≀ ≀

Hails Web-platform framework

  • Hails is built atop the LIO
➤ Concurrent, dynamic,

language-level IFC system

  • Hails apps are LIO programs
➤ Access database, filesystem,

network, etc. according to IFC

GHC Haskell Runtime LIO IFC system Hails framework

learnbyhacking.org

≀ ≀≀ ≀

GHC Haskell Runtime LIO IFC system Hails framework

www.gitstar.com

≀ ≀≀ ≀

slide-20
SLIDE 20
  • Malicious apps will try to leak data through any

means, including covert channels

➤ E.g., termination, internal timing, and external

timing channels

  • LIO addresses these channels at the language level

Challenge: covert channels

Theorem: Termination-sensitive non-interference

➤ Confidentiality and integrity of data is preserved

regardless of the timing/termination behavior of threads

slide-21
SLIDE 21
  • Malicious apps will try to leak data through any

means, including covert channels

➤ E.g., termination, internal timing, and external

timing channels

  • LIO addresses these channels at the language level

Challenge: covert channels

Theorem: Termination-sensitive non-interference

➤ Confidentiality and integrity of data is preserved

regardless of the timing/termination behavior of threads

slide-22
SLIDE 22

Reality check

  • Not modeling hardware features ➠ theorem
  • nly holds for ideal execution machine
  • Can usually exploit system by leveraging

features not captured by model

➤ E.g., finite memory, disk-head location, CPU-

bus, translation look-aside buffer, L1-L3 caches

Cache Rules Everything Around Me

Focus: hardware-level caches

slide-23
SLIDE 23 lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

for 1..3 do skip
  • utput
1: 2:
  • utput := A
  • utput := B

Cache

Cache-based attack

slide-24
SLIDE 24

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
1: 2:

Run 1

for 1..3 do skip
slide-25
SLIDE 25

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
1: 2:

Run 1

for 1..3 do skip
slide-26
SLIDE 26

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
  • utput := A
slide-27
SLIDE 27

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
  • utput := A
slide-28
SLIDE 28

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
  • utput := A
slide-29
SLIDE 29

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 1

for 1..3 do skip
  • utput := B
  • utput := A
slide-30
SLIDE 30

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-31
SLIDE 31

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B B 1: 2:

Run 2

for 1..3 do skip
  • utput := B
  • utput := A
slide-32
SLIDE 32

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A B 1: 2:

Run 2

for 1..3 do skip
  • utput := B
  • utput := A
slide-33
SLIDE 33

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A B 1: 2:

Run 2

for 1..3 do skip
  • utput := B
  • utput := A
Directly encodes / .
slide-34
SLIDE 34

Cache-based attack

  • Reintroduction of the internal timing attack
➤ Threads race to a common resource (output) ➤ Can be used to leak secrets internally to app
  • Trivial L1-cache attack leaks at 0.75 bits/s
➤ Applicable to Hails’ gitstar.com platform ➠ leak

list of collaborators on a private project in < 1 min

slide-35
SLIDE 35

Outline

  • Motivation: Need for Hails IFC Web platforms
  • Cache-based attack on IFC platforms
  • Existing countermeasures
  • New countermeasure: instruction-based scheduling
➤ Benefits and limitations
slide-36
SLIDE 36

Countermeasures

  • 1. Flush the cache on every context switch
➤ Every thread quantum starts with fresh cache ➤ Flushing the cache is prohibitively expensive

for Hails user-level threads

➤ Does not address resources such as CPU bus

contention

slide-37
SLIDE 37

Countermeasures

  • 2. Use CPU no-fill cache mode
➤ Scheduling secret threads bypasses cache,

cannot affect public threads

➤ Secret threads never use the cache ➤ Does not scale beyond 2 security levels ➤ Does not address resources such as the TLB and

CPU bus contention

slide-38
SLIDE 38

Countermeasures

  • 3. Partition the cache
➤ Threads at different security level effectively

have a private (part of the) cache

➤ Does not scale to platform with hundreds of

users that come and go (current OS limit: 16)

➤ Does not address resources such as the TLB and

CPU bus contention

slide-39
SLIDE 39

New countermeasure

Observation: The scheduling of a public thread can be affected by the timing behavior of a secret thread through the hardware cache Solution: Schedule context switches based on number of retired instructions! Instruction-based scheduling

slide-40
SLIDE 40 lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

for 1..3 do skip
  • utput
1: 2:
  • utput := A
  • utput := B

Cache

Cache-based attack

slide-41
SLIDE 41

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
1: 2:

Run 1

for 1..3 do skip
slide-42
SLIDE 42

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
1: 2:

Run 1

for 1..3 do skip
slide-43
SLIDE 43

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
1: 2:

Run 1

for 1..3 do skip
slide-44
SLIDE 44

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
slide-45
SLIDE 45

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
slide-46
SLIDE 46

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A 1: 2:

Run 1

for 1..3 do skip
slide-47
SLIDE 47

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 1

for 1..3 do skip
  • utput := B
slide-48
SLIDE 48

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-49
SLIDE 49

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-50
SLIDE 50

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)

Thread A Thread B

Cache

  • utput
A B 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-51
SLIDE 51

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-52
SLIDE 52

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-53
SLIDE 53

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A 1: 2:

Run 2

for 1..3 do skip
  • utput := A
slide-54
SLIDE 54

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A B 1: 2:

Run 2

for 1..3 do skip
  • utput := B
  • utput := A
slide-55
SLIDE 55

Cache-based attack

lowArray := fillArray( ) if friend == “Julian Assange” highArray := fillArray( ) readArray(lowArray)
  • utput := A

Thread A Thread B

Cache

  • utput
A B A B 1: 2:

Run 2

for 1..3 do skip
  • utput := B
No longer encodes / .
  • utput := A
slide-56
SLIDE 56

Take away

  • Secret threads can affect the duration of

instructions in public threads

➤ Context switching according to amount of

elapsed time ➠ can introduce public races!

  • Secret threads cannot affect the number of (or

which) instructions a public thread retires

➤ Context switching according to number of

instructions retired ➠ no race!

slide-57
SLIDE 57

Implementation

Strawman: Instruction≣language-level atom

➤ Simple to prototype, no runtime modification ➤ Incurs at least 10x slowdown + termination attack

Approach: Measure number of retired instructions

➤ Use hardware performance units (PMUs),

readily available on modern Intel and AMD CPUs

slide-58
SLIDE 58

Implementation

Replaced GHC’s time-based scheduler

➤ Signal from PMU is used to context switch

thread (unless the thread is not in a safe point)

➤ To ensure safe points are reached often,

we added safe-points on every function entry

➤ Reset counters when thread yields to do IO
slide-59
SLIDE 59

Performance impact

Disclaimer: Need code that is used in the find an instruction budget that leads to context switches at roughly 10ms intervals

scs hidden cacheprof fulsom compress2 compress anna hpg infer maillist gamteb parser fem rsa bspt gg reptile fluid symalg Normal scheduler Instruction−based scheduler 0.0 0.1 0.2 0.3 0.4 0.5 0.6 Run time in seconds 0.2 0.3 0.4
slide-60
SLIDE 60

Performance impact

Disclaimer: Need code that is used in the find an instruction budget that leads to context switches at roughly 10ms intervals

scs hidden cacheprof fulsom compress2 compress anna hpg infer maillist gamteb parser fem rsa bspt gg reptile fluid symalg Normal scheduler Instruction−based scheduler 0.0 0.1 0.2 0.3 0.4 0.5 0.6 Run time in seconds 0.2 0.3 0.4

< 1% slowdown

slide-61
SLIDE 61

Conclusions

➤ Eliminates hardware-based internal timing attacks ➤ L1-L3 caches, TLB, CPU bus contention, etc. ➤ Scales to arbitrary number of security levels ➤ Almost no impact on performance ➤ Does not directly scale to multiple CPU cores ➤ Not a big concern in network-balanced web apps

Instruction-based scheduling