fantastic timers and where to find them: high-resolution ... · outline building acovert...

103
www.iaik.tugraz.at Fantastic Timers and Where to Find Them: High-Resolution Microarchitectural Attacks in JavaScript Michael Schwarz , Clémentine Maurice, Daniel Gruss, Stefan Mangard Graz University of Technology April — FC /

Upload: others

Post on 26-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Fantastic Timers and Where to Find Them:High-Resolution Microarchitectural Attacks in JavaScript

Michael Schwarz, Clémentine Maurice, Daniel Gruss, Stefan MangardGraz University of Technology

April 2017 — FC 2017

1 / 26

Page 2: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Outline

Building a covert channel from a virtual machine without networkaccess to the browser

Reviving cache attacks in the browser

No high-resolution timers in JavaScript

How can we build our own timers?

How to get a higher resolution than the native timers?

2 / 26

Page 3: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Covert channelWhat is a covert channel?

Two programs would like to communicate

but are not allowed to doso

either because there is no communication channel...

...or the channels are monitored and programs are stopped oncommunication attempts

Use side channels to communicate

3 / 26

Page 4: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Covert channelWhat is a covert channel?

Two programs would like to communicate but are not allowed to doso

either because there is no communication channel...

...or the channels are monitored and programs are stopped oncommunication attempts

Use side channels to communicate

3 / 26

Page 5: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Covert channelWhat is a covert channel?

Two programs would like to communicate but are not allowed to doso

either because there is no communication channel...

...or the channels are monitored and programs are stopped oncommunication attempts

Use side channels to communicate

3 / 26

Page 6: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Covert channelWhat is a covert channel?

Two programs would like to communicate but are not allowed to doso

either because there is no communication channel...

...or the channels are monitored and programs are stopped oncommunication attempts

Use side channels to communicate

3 / 26

Page 7: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Covert channelWhat is a covert channel?

Two programs would like to communicate but are not allowed to doso

either because there is no communication channel...

...or the channels are monitored and programs are stopped oncommunication attempts

Use side channels to communicate

3 / 26

Page 8: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

channel 0

channel 1

back of DIMM: rank 1

front of DIMM:rank 0

chip

4 / 26

Page 9: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

channel 0

channel 1

back of DIMM: rank 1

front of DIMM:rank 0

chip

4 / 26

Page 10: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

channel 0

channel 1

back of DIMM: rank 1

front of DIMM:rank 0

chip

4 / 26

Page 11: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

channel 0

channel 1

back of DIMM: rank 1

front of DIMM:rank 0

chip

4 / 26

Page 12: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

chipbank 0

row 0row 1row 2. . .

row 32767

row buffer

64k cells1 capacitor,

1 transitor each

5 / 26

Page 13: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM organization

chipbank 0

row 0row 1row 2. . .

row 32767

row buffer

64k cells1 capacitor,

1 transitor each

5 / 26

Page 14: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

The row buffer

DRAM internally is only capable of reading entire rows

Capacitors in cells discharge when reading them

Bits are buffered when reading them from the cells

Then, bits are written back to the cells again

→ Row buffer

6 / 26

Page 15: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

The row buffer

DRAM internally is only capable of reading entire rows

Capacitors in cells discharge when reading them

Bits are buffered when reading them from the cells

Then, bits are written back to the cells again

→ Row buffer

6 / 26

Page 16: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

The row buffer

DRAM internally is only capable of reading entire rows

Capacitors in cells discharge when reading them

Bits are buffered when reading them from the cells

Then, bits are written back to the cells again

→ Row buffer

6 / 26

Page 17: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Reading from DRAM

DRAM bank1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1

. . .1 1 1 1 1 1 1 1 1 1 1 1 1 1

row buffer

CPU readsrow 1, row

buffer empty!

7 / 26

Page 18: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Reading from DRAM

DRAM bank1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1

. . .1 1 1 1 1 1 1 1 1 1 1 1 1 1

row buffer

activate

row buffer

1 1 1 1 1 1 1 1 1 1 1 1 1 1

copy

7 / 26

Page 19: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Reading from DRAM

DRAM bank1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1

. . .1 1 1 1 1 1 1 1 1 1 1 1 1 1

row bufferrow buffer

1 1 1 1 1 1 1 1 1 1 1 1 1 1

return

7 / 26

Page 20: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Reading from DRAM

DRAM bank1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1

. . .1 1 1 1 1 1 1 1 1 1 1 1 1 1

row bufferrow buffer

1 1 1 1 1 1 1 1 1 1 1 1 1 1

CPU readsrow 1, row

buffer now full!1 1 1 1 1 1 1 1 1 1 1 1 1 1

7 / 26

Page 21: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Reading from DRAM

DRAM bank1 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 1 1 1

. . .1 1 1 1 1 1 1 1 1 1 1 1 1 1

row bufferrow buffer

1 1 1 1 1 1 1 1 1 1 1 1 1 1

return

Less work!Is it faster?

7 / 26

Page 22: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Timing difference

200 220 240 260 280 300020406080100

Clock cycles

Frequency Row hits

Row misses

Row hits (≈ 225 cycles) and row conflicts (≈ 247 cycles)8 / 26

Page 23: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Timers in JavaScript

We need a high-resolution timer to measure such small differences

Native: rdtsc - timestamp in CPU cycles

JavaScript: performance.now() has the highest resolution

performance.now()

[...] represent times as floating-point numbers with up to microsecondprecision.

— Mozilla Developer Network

9 / 26

Page 24: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Timers in JavaScript

We need a high-resolution timer to measure such small differences

Native: rdtsc - timestamp in CPU cycles

JavaScript: performance.now() has the highest resolution

performance.now()

[...] represent times as floating-point numbers with up to microsecondprecision.

— Mozilla Developer Network

9 / 26

Page 25: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Timers in JavaScript

We need a high-resolution timer to measure such small differences

Native: rdtsc - timestamp in CPU cycles

JavaScript: performance.now() has the highest resolution

performance.now()

[...] represent times as floating-point numbers with up to microsecondprecision.

— Mozilla Developer Network

9 / 26

Page 26: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Timers in JavaScript

We need a high-resolution timer to measure such small differences

Native: rdtsc - timestamp in CPU cycles

JavaScript: performance.now() has the highest resolution

performance.now()

[...] represent times as floating-point numbers with up to microsecondprecision.

— Mozilla Developer Network

9 / 26

Page 27: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

10 / 26

Page 28: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

1

10 / 26

Page 29: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

1

5

10 / 26

Page 30: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

1

5

5

10 / 26

Page 31: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

1

5

5

0 1 · 105

10 / 26

Page 32: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

...up to microsecond precision?

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

1

5

5

0 1 · 105

0 1 · 105

10 / 26

Page 33: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

We require a higher resolution

Current precision is not sufficient to measure cycle differences

We have two possibilities

Recover a higher resolution from the available timer

Build our own high-resolution timer

11 / 26

Page 34: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

We require a higher resolution

Current precision is not sufficient to measure cycle differences

We have two possibilities

Recover a higher resolution from the available timer

Build our own high-resolution timer

11 / 26

Page 35: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

We require a higher resolution

Current precision is not sufficient to measure cycle differences

We have two possibilities

Recover a higher resolution from the available timer

Build our own high-resolution timer

11 / 26

Page 36: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

We require a higher resolution

Current precision is not sufficient to measure cycle differences

We have two possibilities

Recover a higher resolution from the available timer

Build our own high-resolution timer

11 / 26

Page 37: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 38: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 39: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 40: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 41: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 42: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Clock interpolation

Measure how often we can increment a variable between two timerticks

Average number of increments is the interpolation step

To measure with high resolution:

Start measurement at clock edge

Increment a variable until next clock edge

Highly accurate: 500ns (Firefox/Chrome), 15µs (Tor)

12 / 26

Page 43: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

We can get a higher resolution for a classifier only

Often sufficient to see which of two functions takes longer

Edge thresholding: apply padding such that the slow function crossesone more clock edge than the fast function.

13 / 26

Page 44: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

We can get a higher resolution for a classifier only

Often sufficient to see which of two functions takes longer

Edge thresholding: apply padding such that the slow function crossesone more clock edge than the fast function.

13 / 26

Page 45: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

We can get a higher resolution for a classifier only

Often sufficient to see which of two functions takes longer

fslowffast

Edge thresholding: apply padding such that the slow function crossesone more clock edge than the fast function.

13 / 26

Page 46: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

We can get a higher resolution for a classifier only

Often sufficient to see which of two functions takes longer

fslowffast Padding

Padding

Edge thresholding: apply padding such that the slow function crossesone more clock edge than the fast function.

13 / 26

Page 47: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

unaligned aligned padded0

50

100

13 0

8287 100

180 0 0percentage

both correct fslow misclassified ffast misclassified

Yields nanosecond resolution

Firefox/Tor (2 ns), Edge (10 ns), Chrome (15 ns)

14 / 26

Page 48: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

unaligned aligned padded0

50

100

13 0

8287 100

180 0 0percentage

both correct fslow misclassified ffast misclassified

Yields nanosecond resolution

Firefox/Tor (2 ns), Edge (10 ns), Chrome (15 ns)

14 / 26

Page 49: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Recovering resolution - Edge thresholding

unaligned aligned padded0

50

100

13 0

8287 100

180 0 0percentage

both correct fslow misclassified ffast misclassified

Yields nanosecond resolution

Firefox/Tor (2 ns), Edge (10 ns), Chrome (15 ns)14 / 26

Page 50: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer

Goal: counter that does not block main thread

Baseline setTimeout: 4ms (except Edge: 2ms)

CSS animation: increase width of element as fast as possible

Width of element is timestamp

However, animation is limited to 60 fps→ 16ms

15 / 26

Page 51: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer

Goal: counter that does not block main thread

Baseline setTimeout: 4ms (except Edge: 2ms)

CSS animation: increase width of element as fast as possible

Width of element is timestamp

However, animation is limited to 60 fps→ 16ms

15 / 26

Page 52: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer

Goal: counter that does not block main thread

Baseline setTimeout: 4ms (except Edge: 2ms)

CSS animation: increase width of element as fast as possible

Width of element is timestamp

However, animation is limited to 60 fps→ 16ms

15 / 26

Page 53: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer

Goal: counter that does not block main thread

Baseline setTimeout: 4ms (except Edge: 2ms)

CSS animation: increase width of element as fast as possible

Width of element is timestamp

However, animation is limited to 60 fps→ 16ms

15 / 26

Page 54: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer

Goal: counter that does not block main thread

Baseline setTimeout: 4ms (except Edge: 2ms)

CSS animation: increase width of element as fast as possible

Width of element is timestamp

However, animation is limited to 60 fps→ 16ms

15 / 26

Page 55: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

JavaScript can spawn new threads called web worker

Web worker communicate using message passing

Let worker count and request timestamp in main thread

Multiple possibilities: postMessage, MessageChannel orBroadcastChannel

Yields microsecond resolution (even on Tor and Fuzzyfox)

16 / 26

Page 56: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

JavaScript can spawn new threads called web worker

Web worker communicate using message passing

Let worker count and request timestamp in main thread

Multiple possibilities: postMessage, MessageChannel orBroadcastChannel

Yields microsecond resolution (even on Tor and Fuzzyfox)

16 / 26

Page 57: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

JavaScript can spawn new threads called web worker

Web worker communicate using message passing

Let worker count and request timestamp in main thread

Multiple possibilities: postMessage, MessageChannel orBroadcastChannel

Yields microsecond resolution (even on Tor and Fuzzyfox)

16 / 26

Page 58: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

JavaScript can spawn new threads called web worker

Web worker communicate using message passing

Let worker count and request timestamp in main thread

Multiple possibilities: postMessage, MessageChannel orBroadcastChannel

Yields microsecond resolution (even on Tor and Fuzzyfox)

16 / 26

Page 59: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

JavaScript can spawn new threads called web worker

Web worker communicate using message passing

Let worker count and request timestamp in main thread

Multiple possibilities: postMessage, MessageChannel orBroadcastChannel

Yields microsecond resolution (even on Tor and Fuzzyfox)

16 / 26

Page 60: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 61: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 62: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 63: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 64: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 65: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Building a timer - Web worker

Experimental feature to share data: SharedArrayBuffer

Web worker can simultaneously read/write data

No message passing overhead

One dedicated worker for incrementing the shared variable

Firefox/Fuzzyfox: 2 ns, Chrome: 15 ns

Sufficient for microarchitectural attacks

17 / 26

Page 66: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Measuring cache timing

300 350 400 450 500 550 600 650 700 750

100

200

300

Access time [SharedArrayBuffer increments]

Numberofcases

cache hit cache miss

18 / 26

Page 67: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM covert channel

Sender and receiver agree on a bank (can be hardcoded)

Both (native) sender inside VM and JavaScript on host select adifferent row inside this bank

JavaScript measures access time for this row

Sender can transmit 0 by doing nothing and 1 by causing row conflict

If measured timing was “fast” sender transmitted 0.

19 / 26

Page 68: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM covert channel

Sender and receiver agree on a bank (can be hardcoded)

Both (native) sender inside VM and JavaScript on host select adifferent row inside this bank

JavaScript measures access time for this row

Sender can transmit 0 by doing nothing and 1 by causing row conflict

If measured timing was “fast” sender transmitted 0.

19 / 26

Page 69: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM covert channel

Sender and receiver agree on a bank (can be hardcoded)

Both (native) sender inside VM and JavaScript on host select adifferent row inside this bank

JavaScript measures access time for this row

Sender can transmit 0 by doing nothing and 1 by causing row conflict

If measured timing was “fast” sender transmitted 0.

19 / 26

Page 70: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM covert channel

Sender and receiver agree on a bank (can be hardcoded)

Both (native) sender inside VM and JavaScript on host select adifferent row inside this bank

JavaScript measures access time for this row

Sender can transmit 0 by doing nothing and 1 by causing row conflict

If measured timing was “fast” sender transmitted 0.

19 / 26

Page 71: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

DRAM covert channel

Sender and receiver agree on a bank (can be hardcoded)

Both (native) sender inside VM and JavaScript on host select adifferent row inside this bank

JavaScript measures access time for this row

Sender can transmit 0 by doing nothing and 1 by causing row conflict

If measured timing was “fast” sender transmitted 0.

19 / 26

Page 72: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

Sender andreceiver decideon one bank

0 0 0 0 0 0 0 0 0 0 0 0

20 / 26

Page 73: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

activate 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0

Receiver mea-sures ac-cess time toits address

0 0 0 0 0 0 0 0 0 0 0 0

copy

20 / 26

Page 74: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

return

20 / 26

Page 75: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0

Repeated accessalways has lowaccess times

0 0 0 0 0 0 0 0 0 0 0 0

return

20 / 26

Page 76: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

return

20 / 26

Page 77: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 00 0 0 0 0 0

copy

activateSender accessesits address

20 / 26

Page 78: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 0

return

0 0 0 0 0 0 0 0 0 0 0 0

Sender accessesits address

20 / 26

Page 79: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

activate 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

copy

On next accessof receiver, thereis a row miss

20 / 26

Page 80: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Transmitting data

DRAM bank0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0

. . .0 0 0 0 0 0 0 0 0 0 0 0

row buffer

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

return

Receiver hashigh access time

20 / 26

Page 81: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Measurement

0 50 100 150 200 250 300 350230

235

240

245

250

255cycle

s

1/100 seconds

Multiple measurements per bit to have a reliable detection

21 / 26

Page 82: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Measurement

00 50 100 150 200 250 300 350230

235

240

245

250

255cycle

s

1/100 seconds

Multiple measurements per bit to have a reliable detection

21 / 26

Page 83: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Sending packets0 1 2 3 4 5 6 7 8 9 10

10 Data EDCSeq

Communication is based on packets

Packet starts with a 2-bit preamble

Data integrity is checked by an error-detection code (EDC)

Sequence bit indicates whether it is a re-transmission or a newpacket

22 / 26

Page 84: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Sending packets0 1 2 3 4 5 6 7 8 9 10

10 Data EDCSeq

Communication is based on packets

Packet starts with a 2-bit preamble

Data integrity is checked by an error-detection code (EDC)

Sequence bit indicates whether it is a re-transmission or a newpacket

22 / 26

Page 85: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Sending packets0 1 2 3 4 5 6 7 8 9 10

10 Data EDCSeq

Communication is based on packets

Packet starts with a 2-bit preamble

Data integrity is checked by an error-detection code (EDC)

Sequence bit indicates whether it is a re-transmission or a newpacket

22 / 26

Page 86: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Sending packets0 1 2 3 4 5 6 7 8 9 10

10 Data EDCSeq

Communication is based on packets

Packet starts with a 2-bit preamble

Data integrity is checked by an error-detection code (EDC)

Sequence bit indicates whether it is a re-transmission or a newpacket

22 / 26

Page 87: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 88: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 89: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 90: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 91: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 92: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Results

Transmission of approximately 11 bits/s

Can be improved using

Fewer re-transmits

Error correction

Multithreading→ multiple banks in parallel

What is possible in native code? 596 kbit/s cross CPU and crossVM

23 / 26

Page 93: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Responsible disclosure

We contacted Google, Mozilla, Microsoft and the Tor project

Microsoft→ no response

Google→ several developers are assigned to the bug report

Mozilla→ Discussing about clock randomization and not shippingSharedArrayBuffer

Tor→ Working on fuzzy time

24 / 26

Page 94: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Responsible disclosure

We contacted Google, Mozilla, Microsoft and the Tor project

Microsoft→ no response

Google→ several developers are assigned to the bug report

Mozilla→ Discussing about clock randomization and not shippingSharedArrayBuffer

Tor→ Working on fuzzy time

24 / 26

Page 95: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Responsible disclosure

We contacted Google, Mozilla, Microsoft and the Tor project

Microsoft→ no response

Google→ several developers are assigned to the bug report

Mozilla→ Discussing about clock randomization and not shippingSharedArrayBuffer

Tor→ Working on fuzzy time

24 / 26

Page 96: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Responsible disclosure

We contacted Google, Mozilla, Microsoft and the Tor project

Microsoft→ no response

Google→ several developers are assigned to the bug report

Mozilla→ Discussing about clock randomization and not shippingSharedArrayBuffer

Tor→ Working on fuzzy time

24 / 26

Page 97: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Responsible disclosure

We contacted Google, Mozilla, Microsoft and the Tor project

Microsoft→ no response

Google→ several developers are assigned to the bug report

Mozilla→ Discussing about clock randomization and not shippingSharedArrayBuffer

Tor→ Working on fuzzy time

24 / 26

Page 98: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Conclusion

Just rounding timers is not a solution

Multithreading allows to build new timers

Shared data comes with great risks

It allows to build timers with nanosecond resolution

Microarchitectural attacks in the browser are possible again

25 / 26

Page 99: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Conclusion

Just rounding timers is not a solution

Multithreading allows to build new timers

Shared data comes with great risks

It allows to build timers with nanosecond resolution

Microarchitectural attacks in the browser are possible again

25 / 26

Page 100: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Conclusion

Just rounding timers is not a solution

Multithreading allows to build new timers

Shared data comes with great risks

It allows to build timers with nanosecond resolution

Microarchitectural attacks in the browser are possible again

25 / 26

Page 101: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Conclusion

Just rounding timers is not a solution

Multithreading allows to build new timers

Shared data comes with great risks

It allows to build timers with nanosecond resolution

Microarchitectural attacks in the browser are possible again

25 / 26

Page 102: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Conclusion

Just rounding timers is not a solution

Multithreading allows to build new timers

Shared data comes with great risks

It allows to build timers with nanosecond resolution

Microarchitectural attacks in the browser are possible again

25 / 26

Page 103: Fantastic Timers and Where to Find Them: High-Resolution ... · Outline Building acovert channelfrom a virtual machine without network access to the browser Revivingcache attacksin

www.iaik.tugraz.at

Michael Schwarz, Clémentine Maurice, Daniel Gruss, Stefan Mangard

26 / 26