Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter:...

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

Transcript of Side-Channel Attacks (Brief Introduction) · Side-Channel Attacks (Brief Introduction) Presenter:...

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

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

Cache Architecture High Level

data

Cache

data

Main Memory

Cache

Set 1

Set 2

Set 64

CPU

Main Memory

address

4

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

Introduction to Cache Architecture

CPU

Main Memory

CPU

L1 Instruction Cache L1 Data Cache

L2 Cache

L3 Cache

6

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

Accessing Memory (Cache Hit)

CPU

Main Memory

Cache

Fast Access to Data

add

ress

data

8

Accessing Memory (Cache Miss)

CPU

Main Memory

add

ress

dataCache

address

datadata

Slow Access to Data

9

Cache Hit vs. Miss Time Difference

• ≈10 Million measurement

Cache Hit

Cache Miss

Clock Cycle

Number of Occurrence

10

Cache Attack Model

CPU

Main Memory

CPUCPU

Main Memory

CPU

11

: Attacker : Victim

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

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

13

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

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

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

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

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

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

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

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

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

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

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

24

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

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

26

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

27

Flush a Line From Cache

CPU

Main Memory

CPU

flush

28

Flush and Reload

1. Flush memory line

2. Wait a bit

3. Measure time to Reload line

4. Repeat

29

Reload a Line From Cache

CPU

Main Memory

CPU

reload

No Access by Victim

30

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

Reload a Line From Cache

CPU

Main Memory

CPU

reload

32

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

Some Cache Attack Technique

• Evict and Time

• Flush and Reload

• Prime and Probe

34

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

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

Fill a cache set (In this example 2 sets)

CPU

Main Memory

CPU

Fill a set

37

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

Victim Execution

CPU

Main Memory

CPU

Access some lines

39

: Attacker’s data

: Victim’s data

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

Probe

CPU

Main Memory

CPU

Probe a setProbe a set

41

: Attacker’s data

: Victim’s data

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

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

A Sample Measurement (Flush and Reload)

44

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

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

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

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

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

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

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]

52

[1-2] [1-3]

[1-4][1-1]

2

4

5

8

1517

19

20

22

23

24

2527

3

[1-5]

53

[1-2] [1-3]

[1-4][1-1]

2

5

8

1517

20

22

23

2527

3

[1-5]19

4

24

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

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

Side Channel Attacks Examples

• Timing Attacks• Cache Attack

• Power Analysis Attack

• Electromagnetic Emissions

• Acoustic Emission

• Fault Attacks

56

Thank You

57