1 of 83

Cache Side Channel Attacks

ECS 153

2 of 83

Information leakage

Alice wants to tell Bob which food truck to meet her at. They have shared a One Time Pad before hand.

Choices: Shah, Red, Buckhorn

3 of 83

Information leakage

Alice wants to tell Bob which food truck to meet her at. They have shared a One Time Pad before hand.

Choices: Shah, Red, Buckhorn

As Mallory, you see the following message: DD 30 A6 6F

What can you deduct from this?

4 of 83

Information leakage

Shah -> 45 4F AB 79

Red -> A9 65 CB

Buckhorn -> EB 61 8A CF 9B A2 B7 9D

5 of 83

Information leakage

Shah -> 45 4F AB 79

Red -> A9 65 CB

Buckhorn -> EB 61 8A CF 9B A2 B7 9D

They’re going to Shah’s, because it’s a 4-byte message!

6 of 83

Information leakage

Shah -> 45 4F AB 79

Red -> A9 65 CB

Buckhorn -> EB 61 8A CF 9B A2 B7 9D

They’re going to Shah’s, because it’s a 4-byte message!

The message content itself is secure, but it can still leak information.

7 of 83

What’s a side channel?

Anything that’s not information you get directly

8 of 83

What’s a side channel?

Anything that’s not information you get directly

Message length?

9 of 83

What’s a side channel?

Anything that’s not information you get directly

Message length?

Timing information?

10 of 83

What’s a side channel?

Anything that’s not information you get directly

Message length?

Timing information?

11 of 83

What’s a side channel?

Anything that’s not information you get directly

Message length?

Timing information?

Power consumption?

12 of 83

What’s a side channel?

Anything that’s not information you get directly

Message length?

Timing information?

Power consumption?

13 of 83

Van Eck Phreaking

14 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

15 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

16 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

17 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

Thinking……

18 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

Thinking……

0xdeadbeef

19 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

Thinking……

0xdeadbeef

Thanks. I’ll remember that.

20 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

Thinking……

0xdeadbeef

Thanks. I’ll remember that.

Can I haz 0x64fac?

21 of 83

Cache refresher

Cache

Mem

CPU

T

i

m

e

Can I haz 0x64fac?

I don’t have it.

Hey memory, what is it?

Thinking……

0xdeadbeef

Thanks. I’ll remember that.

Can I haz 0x64fac?

It’s 0xdeadbeef.

22 of 83

Cache terminology

  • Cache line
    • One chunk of memory that’s stored in the cache
    • Intel has 64-byte lines
  • Cache set:
    • Each memory address has a corresponding set that it should be put into
    • Only have to look in one set to know if a cache line is there
    • Each set can contain multiple lines
    • 2048 sets per core in Intel L3 cache, each set can store 12 cache lines
  • Cache hit/miss
  • Eviction
    • Getting rid of a cache line to make room for another

23 of 83

Cache terminology

Cache

Mem

CPU

24 of 83

Cache terminology

Cache

Mem

CPU

Hey! Give me the value at

0xABCDEF12~0xABCDEF15

25 of 83

Cache terminology

Cache

Mem

CPU

The address 0xABCDEF12 maps to cache set #1234

26 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

27 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

Miss!

28 of 83

Cache terminology

Cache

Mem

CPU

Hey memory! Give me 0xABCDEF00~0xABCDEF40

29 of 83

Cache terminology

Cache

Mem

CPU

Hey memory! Give me 0xABCDEF00~0xABCDEF40

Cache Line:

The cache stores one line (64 bytes) at a time

30 of 83

Cache terminology

Cache

Mem

CPU

ABCDEF00: af5c 79dc 0d28 e5bf 5b95 81e0 1048 ac0e .\y..(..[....H..

ABCDEF10: 3fb3 99fa d05f 3522 8251 ef37 742a 915a ?...._5".Q.7t*.Z

ABCDEF20: 9975 29d1 3424 2a90 2688 8327 1532 6d4e .u).4$*.&..'.2mN

ABCDEF30: d936 fa3b 4912 39b1 fe93 db1e 8436 eeda .6.;I.9......6..

31 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

32 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

Evict!

33 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

34 of 83

Cache terminology

Cache

Mem

CPU

0xABCDEF12 contains:

99 FA D0 5F

35 of 83

Cache terminology

Cache

Mem

CPU

Hey! Give me the value at

0xABCDEF34~0xABCDEF37

36 of 83

Cache terminology

Cache

Mem

CPU

The address 0xABCDEF34 maps to cache set #1234

37 of 83

Cache terminology

Cache

Mem

CPU

Set #1233

Set #1234

Set #1235

Hit!

38 of 83

Cache terminology

Cache

Mem

CPU

0xABCDEF34 contains:

49 12 39 B1

39 of 83

Cache side channel attacks

The cache sits between the CPU and memory. If something is already in the cache, the next read from it will be faster

We can set the cache up a certain way, wait until the victim does something, and see how things change!

Used in all kinds of exploits, like spectre/meltdown

40 of 83

An example

41 of 83

An example

42 of 83

An example

Flush an address from cache

Record current time

secretfunction()

Record current time

Log difference

43 of 83

An example

44 of 83

An example

45 of 83

An example

Log start time: 1000

46 of 83

An example

Log start time: 1000

Cache hit!

47 of 83

An example

Log start time: 1000

Cache hit!

Log end time: 1200

Difference: 200

48 of 83

An example

49 of 83

An example

50 of 83

An example

Log start time: 2000

51 of 83

An example

Log start time: 2000

Cache miss!

52 of 83

An example

Log start time: 2000

Cache miss!

53 of 83

An example

Log start time: 2000

Cache miss!

Log end time: 2500

Difference: 500

54 of 83

An example

55 of 83

An example

Source code: https://bit.ly/2Xc73bh

56 of 83

Types of cache timing side channels

  • Evict+Time
  • Prime+Probe
  • Flush+Reload

  • All different sides of the same coin
    • Make the cache look a certain way, see how it changes things
    • If anyone has a three-sided coin or dice please let me know

57 of 83

Evict+Time

  • Process

58 of 83

Evict+Time

  • Process
    • Run victim code, time

59 of 83

Evict+Time

  • Process
    • Run victim code, time
    • Evict a cache set

60 of 83

Evict+Time

  • Process
    • Run victim code, time
    • Evict a cache set
    • Run victim code again, time

61 of 83

Evict+Time

  • Process
    • Run victim code, time
    • Evict a cache set
    • Run victim code again, time
  • If the second run takes longer, it used the cache set
  • Advantages?

62 of 83

Evict+Time

  • Process
    • Run victim code, time
    • Evict a cache set
    • Run victim code again, time
  • If the second run takes longer, it used the cache set
  • Advantages?
    • Fairly consistent (compared to other methods)
  • Disadvantages?

63 of 83

Evict+Time

  • Process
    • Run victim code, time
    • Evict a cache set
    • Run victim code again, time
  • If the second run takes longer, it used the cache set
  • Advantages?
    • Fairly consistent (compared to other methods)
  • Disadvantages?
    • Need to call victim code reliably

64 of 83

Prime+Probe

  • Process

65 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data

66 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time

67 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time

68 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time

69 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time
  • If your probe takes longer, the victim code has put something in the cache set
  • Advantages?

70 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time
  • If your probe takes longer, the victim code has put something in the cache set
  • Advantages?
    • Can run concurrently with victim, better time resolution
  • Disadvantages?

71 of 83

Prime+Probe

  • Process
    • Prime the cache sets to contain only attacker data
    • Probe the attacker data occasionally, record the time
  • If your probe takes longer, the victim code has put something in the cache set
  • Advantages?
    • Can run concurrently with victim, better time resolution
  • Disadvantages?
    • Noise

72 of 83

Flush+Reload

  • Process

73 of 83

Flush+Reload

  • Process
    • Flush one cache line using CLFLUSH

74 of 83

Flush+Reload

  • Process
    • Flush one cache line using CLFLUSH
    • Reload the data in the cache line, time

75 of 83

Flush+Reload

  • Process
    • Flush one cache line using CLFLUSH
    • Reload the data in the cache line, time
  • If the time takes to reload is short, the victim has used that cache line/memory location
  • Advantages?

76 of 83

Flush+Reload

  • Process
    • Flush one cache line using CLFLUSH
    • Reload the data in the cache line, time
  • If the time takes to reload is short, the victim has used that cache line/memory location
  • Advantages?
    • Good resolution (down to cache line)
  • Disadvantages?

77 of 83

Flush+Reload

  • Process
    • Flush one cache line using CLFLUSH
    • Reload the data in the cache line, time
  • If the time takes to reload is short, the victim has used that cache line/memory location
  • Advantages?
    • Good resolution (down to cache line)
  • Disadvantages?
    • Need shared memory

78 of 83

Mitigations

How can we defend against side channel attacks in general?

79 of 83

Mitigations

How can we defend against side channel attacks in general?

Leak less information

80 of 83

Mitigations

How can we defend against side channel attacks in general?

Leak less information

81 of 83

Mitigations

How can we defend against side channel attacks in general?

Leak less information

Obfuscate side channel

82 of 83

Mitigations

How can we defend against side channel attacks in general?

Leak less information

Obfuscate side channel

83 of 83

That’s it!

Questions?

PS: Good luck on your project presentations!

Hopefully you won’t be as much of a mess as I am today! [x