Top Banner
Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1
57

Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Jul 08, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Side-Channel Attacks(Brief Introduction)

Presenter: Aria Shahverdi

9/31/2019

Cache

1

Page 2: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

How do we load data from Main Memory?

CPU

Main Memory

address

data

2

Page 3: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Memory Locality

• Future memory accesses are near past memory accesses

• Memories take advantages of two locality• Temporal Locality: near in time

• We will often access the same data again very soon

• Spatial Locality: near in space/distance• Our next access is often very close to our last access (or recent accesses)

for(i = 0; i < 20; i++)

a[i] = a[i]*2;

a[0]

a[1]

a[2]

…3

Page 4: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Architecture High Level

data

Cache

data

Main Memory

Cache

Set 1

Set 2

Set 64

CPU

Main Memory

address

4

Page 5: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Set Associative Cache Architecture

line1 line2 line3 line4 line5 line6 line7 line8

line1 line2 line3 line4 line5 line6 line7 line8

line1 line2 line3 line4 line5 line6 line7 line8

line1 line2 line3 line4 line5 line6 line7 line8

Set 1

Set 2

Set 64

Main Memory

Cache

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 1

Line 2

Set

1

Set 1

Set 2

Set 3

Set 64

8-way set associative Cache

Set

2

5

Page 6: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Introduction to Cache Architecture

CPU

Main Memory

CPU

L1 Instruction Cache L1 Data Cache

L2 Cache

L3 Cache

6

Page 7: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Architecture (Summary)

• Unit of Memory in cache is a line

• A cache consists of multiple sets which stores fixed number of lines

• The number of lines in a set is called associativity• L1 is 8-way, L2 is 4-way, L3 is 12-way

• Last Level Cache (LLC) is inclusive• LLC contains copies of all of the data in the lower cache level

• Evicting data from LLC remove that data from all other cache levels

7

Page 8: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Accessing Memory (Cache Hit)

CPU

Main Memory

Cache

Fast Access to Data

add

ress

data

8

Page 9: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Accessing Memory (Cache Miss)

CPU

Main Memory

add

ress

dataCache

address

datadata

Slow Access to Data

9

Page 10: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Hit vs. Miss Time Difference

• ≈10 Million measurement

Cache Hit

Cache Miss

Clock Cycle

Number of Occurrence

10

Page 11: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Attack Model

CPU

Main Memory

CPUCPU

Main Memory

CPU

11

: Attacker : Victim

Page 12: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe Set 1

Set 2

Set 3

Line

1

Line

2

Line

8

12

Page 13: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

13

Page 14: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

14

Page 15: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

15

Page 16: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

16

Page 17: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

How do we fill a cache set?

• By Accessing some of the memory locations the corresponding locations in the cache is going to be filled.

• Main Challenge: which lines to access?

17

Main MemoryCache

Page 18: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

18

Page 19: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

It took almost the same amount time

19

Page 20: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

20

Page 21: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

21

Page 22: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

22

Page 23: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Evict and Time

1. Trigger encryption

2. Selectively manipulate the state of the cache (e.g. evict a full cache set)

3. Trigger encryption

4. Measure how long it took

5. Deduce what cache sets it accessed

6. Repeat step 1-4 to gain information on all the set the encryption accessed

Set 2 was accessed!!

23

Page 24: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

24

Page 25: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

• Exploits cache behavior to leak information on victim access to shared memory.• Shared libraries

• Memory de-duplication

• Spy monitors victim’s access to shared code• Spy can determine what victim does

• Spy can infer the data the victim operates on

25

Page 26: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

26

Page 27: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

27

Page 28: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush a Line From Cache

CPU

Main Memory

CPU

flush

28

Page 29: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

29

Page 30: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Reload a Line From Cache

CPU

Main Memory

CPU

reload

No Access by Victim

30

Page 31: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

Slow means no access by victim

31

Page 32: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Reload a Line From Cache

CPU

Main Memory

CPU

reload

32

Page 33: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

Fast means that victim accessed

33

Page 34: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

34

Page 35: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Prime and Probe

1. Attacker fills a set with its own data by accessing some locations in memory

2. Victim Executes and evicts some of the cache lines

3. Attacker accesses those cache line and measure time

35

Page 36: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Prime and Probe

1. Attacker fills a set with its own data by accessing some locations in memory

2. Victim Executes and evicts some of the cache lines

3. Attacker accesses those cache line and measure time

36

Page 37: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Fill a cache set (In this example 2 sets)

CPU

Main Memory

CPU

Fill a set

37

Page 38: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Prime and Probe

1. Attacker fills a set with its own data by accessing some locations in memory

2. Victim Executes and evicts some of the cache lines

3. Attacker accesses those cache line and measure time

38

Page 39: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Victim Execution

CPU

Main Memory

CPU

Access some lines

39

: Attacker’s data

: Victim’s data

Page 40: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Prime and Probe

1. Attacker fills a set with its own data by accessing some locations in memory

2. Victim Executes and evicts some of the cache lines

3. Attacker accesses those cache line and measure time

40

Page 41: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Probe

CPU

Main Memory

CPU

Probe a setProbe a set

41

: Attacker’s data

: Victim’s data

Page 42: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Prime and Probe

1. Attacker fills a set with its own data by accessing some locations in memory

2. Victim Executes and evicts some of the cache lines

3. Attacker accesses those cache line and measure time

Fast Access: Not accessed by the victim

Slow Access: Accessed by the victim

42

Page 43: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

How To Recover Secret Key?

• How do we compute 𝑏𝑒𝑚𝑜𝑑 𝑛?• Assume 𝑒 is secret information we

want to recover.

• Bit = 0 : Square

• Bit = 1 : Square + Multiply

The Sequence of operation will reveal the secret information.

SM

1

S S SM SM S S

0 0 1 1 0 0

43

Page 44: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

A Sample Measurement (Flush and Reload)

44

Page 45: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Attack on Database

45

SELECT *FROM tableWHERE column BETWEEN value1 AND value2;

• User execute queries in the form of range queries• Asks for entries with column value between value1 and value 2

• Attacker sees the volume of the responses

Page 46: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Attack on Database

46

SELECT * FROM table WHERE Grade BETWEEN 1 AND 1

A

Students Grade

A 1

B 2

C 2

D 2

E 3

F 3

G 3

H 4

I 4

SELECT * FROM table WHERE Grade BETWEEN 1 AND 2

B C DA

SELECT * FROM table WHERE Grade BETWEEN 3 AND 4

F G HE I

Page 47: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Attack on Database

47

SELECT * FROM table WHERE Grade BETWEEN 1 AND 1

Students Grade

A 1

B 2

C 2

D 2

E 3

F 3

G 3

H 4

I 4

SELECT * FROM table WHERE Grade BETWEEN 1 AND 2

SELECT * FROM table WHERE Grade BETWEEN 3 AND 4

Page 48: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Cache Attack on Database

48

SELECT * FROM table WHERE Grade BETWEEN 1 AND 1

Students Grade

A 1

B 2

C 2

D 2

E 3

F 3

G 3

H 4

I 4

SELECT * FROM table WHERE Grade BETWEEN 1 AND 2

SELECT * FROM table WHERE Grade BETWEEN 3 AND 4

Page 49: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Attacker View From Cache

49

0 500 1000 1500 2000 2500 3000 3500 4000

Sample

0

100

200

300

400

500

600

700

800

900

1000

Re

loa

d T

ime

Cache Activity During Range Query Execution

no activity

range query execution

• Counts how many time the server execute the line which correspond to returning an entry

• From that, the attacker figures outapproximately the value of each volume

Page 50: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Noisy Volume Recovered

50

0 100 200 300 400 500 600 700 800 900 1000

Volume

0

50

100

150

200

250

300

350

400

450

500

Nu

mb

er

of

Occu

ran

ce

Volume Recovered by Cache Attack

Peaks represent the Volumes

Page 51: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

How to reconstruct the database?

• [1-2] = [1-1] + [2-2]

• [1-3] = [1-2] + [3-3] = [1-1] + [2-3]

• [1-4] = [1-1] + [2-4] = ….

51

10

2 8[1-2] [1-3]

[1-4][1-1]

Observed Volumes

[2-3]

[2-4]

[3-4]

Page 52: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

52

[1-2] [1-3]

[1-4][1-1]

2

4

5

8

1517

19

20

22

23

24

2527

3

[1-5]

Page 53: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

53

[1-2] [1-3]

[1-4][1-1]

2

5

8

1517

20

22

23

2527

3

[1-5]19

4

24

Page 54: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

54

[1-2]4

[1-3]19

[1-4]24

[1-1]2

2

5

8

1517

20

22

23

2527

3

[1-5]27

19

4

24

[1-1] = 2[2-2] = [1-2] – [1-1] = 2[3-3] = [1-3] – [1-2] = 15[4-4] = [1-4] – [1-3] = 5[5-5] = [1-5] – [1-4] - 3

Page 55: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

What about the case for measurements from cache• It is harder because the measurement from cache are noisy

• Some of the volumes might be missing• Some of the connections ins graph is missing

• There might be some extra volumes in the graph• There are extra nodes in the graph which should not be there

• We still can recover the database in some of the cases

55

Page 56: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Side Channel Attacks Examples

• Timing Attacks• Cache Attack

• Power Analysis Attack

• Electromagnetic Emissions

• Acoustic Emission

• Fault Attacks

56

Page 57: Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter: Aria Shahverdi 9/31/2019 Cache 1

Thank You

57