microarchitectural attacks and defenses in javascriptmicroarchitecture microarchitecture... is not...

215
Microarchitectural Attacks and Defenses in JavaScript Michael Schwarz, Daniel Gruss, Moritz Lipp 25.01.2018 www.iaik.tugraz.at 1 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Upload: others

Post on 23-Jul-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks and Defenses in JavaScript

Michael Schwarz, Daniel Gruss, Moritz Lipp

25.01.2018

www.iaik.tugraz.at

1 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 2: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitecture www.tugraz.at

Microarchitecture...

• is not defined on the architectural state

• should not be visible to software

• is hardware specific and not fully documented

• changes to some extend with new processor generations

2 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 3: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitecture www.tugraz.at

Microarchitecture...

• is not defined on the architectural state

• should not be visible to software

• is hardware specific and not fully documented

• changes to some extend with new processor generations

2 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 4: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitecture www.tugraz.at

Microarchitecture...

• is not defined on the architectural state

• should not be visible to software

• is hardware specific and not fully documented

• changes to some extend with new processor generations

2 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 5: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitecture www.tugraz.at

Microarchitecture...

• is not defined on the architectural state

• should not be visible to software

• is hardware specific and not fully documented

• changes to some extend with new processor generations

2 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 6: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks www.tugraz.at

Microarchitectural states can be used for attacks

• Cache state ⇒ data access

• DRAM buffers ⇒ data access

• Interrupts ⇒ keystrokes

• Branch predictors ⇒ program flow

• Timings ⇒ data values

3 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 7: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks www.tugraz.at

Microarchitectural states can be used for attacks

• Cache state ⇒ data access

• DRAM buffers ⇒ data access

• Interrupts ⇒ keystrokes

• Branch predictors ⇒ program flow

• Timings ⇒ data values

3 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 8: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks www.tugraz.at

Microarchitectural states can be used for attacks

• Cache state ⇒ data access

• DRAM buffers ⇒ data access

• Interrupts ⇒ keystrokes

• Branch predictors ⇒ program flow

• Timings ⇒ data values

3 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 9: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks www.tugraz.at

Microarchitectural states can be used for attacks

• Cache state ⇒ data access

• DRAM buffers ⇒ data access

• Interrupts ⇒ keystrokes

• Branch predictors ⇒ program flow

• Timings ⇒ data values

3 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 10: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Microarchitectural Attacks www.tugraz.at

Microarchitectural states can be used for attacks

• Cache state ⇒ data access

• DRAM buffers ⇒ data access

• Interrupts ⇒ keystrokes

• Branch predictors ⇒ program flow

• Timings ⇒ data values

3 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 11: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Side-Channel Attacks www.tugraz.at

Side-channel attacks exploit side effects of operations

• Microarchitectural attacks are usually side-channel attacks

• Sensors ⇒ user activity

• Timings ⇒ data values, activity

4 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 12: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Side-Channel Attacks www.tugraz.at

Side-channel attacks exploit side effects of operations

• Microarchitectural attacks are usually side-channel attacks

• Sensors ⇒ user activity

• Timings ⇒ data values, activity

4 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 13: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Side-Channel Attacks www.tugraz.at

Side-channel attacks exploit side effects of operations

• Microarchitectural attacks are usually side-channel attacks

• Sensors ⇒ user activity

• Timings ⇒ data values, activity

4 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 14: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

One Important Component www.tugraz.at

• A core component of many such attacks: Timers

• Side-channel attacks often require high-resolution timers

• Differences to measure are often in the range of nanoseconds or

microseconds

• Microarchitectural attacks usually require highest precision

5 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 15: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

One Important Component www.tugraz.at

• A core component of many such attacks: Timers

• Side-channel attacks often require high-resolution timers

• Differences to measure are often in the range of nanoseconds or

microseconds

• Microarchitectural attacks usually require highest precision

5 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 16: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

One Important Component www.tugraz.at

• A core component of many such attacks: Timers

• Side-channel attacks often require high-resolution timers

• Differences to measure are often in the range of nanoseconds or

microseconds

• Microarchitectural attacks usually require highest precision

5 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 17: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

One Important Component www.tugraz.at

• A core component of many such attacks: Timers

• Side-channel attacks often require high-resolution timers

• Differences to measure are often in the range of nanoseconds or

microseconds

• Microarchitectural attacks usually require highest precision

5 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 18: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attacks in JavaScript

Page 19: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Side-Channel Attack www.tugraz.at

First side-channel attack in JavaScript

• Stone et al. (2013): Pixel perfect timing attacks with HTML5

• Timing of various redraw events (e.g., visited state of links)

• SVG filter timing to extract individual pixels (already 2011)

• High-resolution timer was available in browser

6 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 20: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Side-Channel Attack www.tugraz.at

First side-channel attack in JavaScript

• Stone et al. (2013): Pixel perfect timing attacks with HTML5

• Timing of various redraw events (e.g., visited state of links)

• SVG filter timing to extract individual pixels (already 2011)

• High-resolution timer was available in browser

6 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 21: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Side-Channel Attack www.tugraz.at

First side-channel attack in JavaScript

• Stone et al. (2013): Pixel perfect timing attacks with HTML5

• Timing of various redraw events (e.g., visited state of links)

• SVG filter timing to extract individual pixels (already 2011)

• High-resolution timer was available in browser

6 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 22: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Side-Channel Attack www.tugraz.at

First side-channel attack in JavaScript

• Stone et al. (2013): Pixel perfect timing attacks with HTML5

• Timing of various redraw events (e.g., visited state of links)

• SVG filter timing to extract individual pixels (already 2011)

• High-resolution timer was available in browser

6 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 23: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Microarchitectural Attack www.tugraz.at

First microarchitectural attack in JavaScript

• Oren et al. (2015): The Spy in the Sandbox

• Timing of memory accesses

• Allows to determine whether data is cached or uncached

• Possibility to infer info about other programs from browser

7 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 24: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Microarchitectural Attack www.tugraz.at

First microarchitectural attack in JavaScript

• Oren et al. (2015): The Spy in the Sandbox

• Timing of memory accesses

• Allows to determine whether data is cached or uncached

• Possibility to infer info about other programs from browser

7 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 25: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Microarchitectural Attack www.tugraz.at

First microarchitectural attack in JavaScript

• Oren et al. (2015): The Spy in the Sandbox

• Timing of memory accesses

• Allows to determine whether data is cached or uncached

• Possibility to infer info about other programs from browser

7 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 26: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

First Microarchitectural Attack www.tugraz.at

First microarchitectural attack in JavaScript

• Oren et al. (2015): The Spy in the Sandbox

• Timing of memory accesses

• Allows to determine whether data is cached or uncached

• Possibility to infer info about other programs from browser

7 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 27: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

8 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 28: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Timers in JavaScript www.tugraz.at

• 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 microsecond precision.

— Mozilla Developer Network

9 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 29: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Timers in JavaScript www.tugraz.at

• 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 microsecond precision.

— Mozilla Developer Network

9 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 30: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Timers in JavaScript www.tugraz.at

• 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 microsecond precision.

— Mozilla Developer Network

9 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 31: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Timers in JavaScript www.tugraz.at

• 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 microsecond precision.

— Mozilla Developer Network

9 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 32: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

Firefox ≤ 36

Edge 38

W3C standard

Firefox ≥ 37/Chrome/Safari

Tor

Fuzzyfox

1 · 10−3

1

5

5

0

0

1 · 10−3

10 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 33: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 34: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 35: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 36: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 37: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

...up to microsecond precision? www.tugraz.at

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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 38: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

New timer

Page 39: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

We require a higher resolution www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 40: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

We require a higher resolution www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 41: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

We require a higher resolution www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 42: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

We require a higher resolution www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 43: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 44: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 45: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 46: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 47: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 48: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Clock interpolation www.tugraz.at

• Measure how often we can increment a variable between two timer

ticks

• 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: 500 ns (Firefox/Chrome), 15 µs (Tor)

12 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 49: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

• 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 crosses one more clock edge

than the fast function.

13 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 50: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

• 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 crosses one more clock edge

than the fast function.

13 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 51: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

• We can get a higher resolution for a classifier only

• Often sufficient to see which of two functions takes longer

fslow

ffast

• Edge thresholding: apply padding such that the slow function crosses one more clock edge

than the fast function.

13 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 52: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

• We can get a higher resolution for a classifier only

• Often sufficient to see which of two functions takes longer

fslow

ffast Padding

Padding

• Edge thresholding: apply padding such that the slow function crosses one more clock edge

than the fast function.

13 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 53: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

unaligned aligned padded

0

50

100

130

8287100

180 0 0

per

cen

tage

both correct fslow misclassified ffast misclassified

• Yields nanosecond resolution

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

14 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 54: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

unaligned aligned padded

0

50

100

130

8287100

180 0 0

per

cen

tage

both correct fslow misclassified ffast misclassified

• Yields nanosecond resolution

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

14 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 55: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Recovering resolution - Edge thresholding www.tugraz.at

unaligned aligned padded

0

50

100

130

8287100

180 0 0

per

cen

tage

both correct fslow misclassified ffast misclassified

• Yields nanosecond resolution

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

14 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 56: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer www.tugraz.at

• Goal: counter that does not block main thread

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

• CSS animation: increase width of element as fast as possible

• Width of element is timestamp

• However, animation is limited to 60 fps → 16 ms

15 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 57: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer www.tugraz.at

• Goal: counter that does not block main thread

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

• CSS animation: increase width of element as fast as possible

• Width of element is timestamp

• However, animation is limited to 60 fps → 16 ms

15 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 58: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer www.tugraz.at

• Goal: counter that does not block main thread

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

• CSS animation: increase width of element as fast as possible

• Width of element is timestamp

• However, animation is limited to 60 fps → 16 ms

15 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 59: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer www.tugraz.at

• Goal: counter that does not block main thread

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

• CSS animation: increase width of element as fast as possible

• Width of element is timestamp

• However, animation is limited to 60 fps → 16 ms

15 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 60: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer www.tugraz.at

• Goal: counter that does not block main thread

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

• CSS animation: increase width of element as fast as possible

• Width of element is timestamp

• However, animation is limited to 60 fps → 16 ms

15 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 61: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 or

BroadcastChannel

• Yields microsecond resolution (even on Tor and Fuzzyfox)

16 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 62: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 or

BroadcastChannel

• Yields microsecond resolution (even on Tor and Fuzzyfox)

16 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 63: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 or

BroadcastChannel

• Yields microsecond resolution (even on Tor and Fuzzyfox)

16 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 64: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 or

BroadcastChannel

• Yields microsecond resolution (even on Tor and Fuzzyfox)

16 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 65: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 or

BroadcastChannel

• Yields microsecond resolution (even on Tor and Fuzzyfox)

16 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 66: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 67: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 68: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 69: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 70: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 71: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Building a timer - Web worker www.tugraz.at

• 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 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 72: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Timer evaluation www.tugraz.at

300 350 400 450 500 550 600 650 700 750

100

200

300

Access time [SharedArrayBuffer increments]

Nu

mb

erof

case

s

cache hit cache miss

18 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 73: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack Requirements

Page 74: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack requirements www.tugraz.at

• Timers were always the main focus

• Reducing timer resolution is not sufficient

• Timers can (always) be built

• Some attacks do not require timers at all

• Important to understand requirements before designing

countermeasures

19 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 75: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack requirements www.tugraz.at

• Timers were always the main focus

• Reducing timer resolution is not sufficient

• Timers can (always) be built

• Some attacks do not require timers at all

• Important to understand requirements before designing

countermeasures

19 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 76: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack requirements www.tugraz.at

• Timers were always the main focus

• Reducing timer resolution is not sufficient

• Timers can (always) be built

• Some attacks do not require timers at all

• Important to understand requirements before designing

countermeasures

19 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 77: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack requirements www.tugraz.at

• Timers were always the main focus

• Reducing timer resolution is not sufficient

• Timers can (always) be built

• Some attacks do not require timers at all

• Important to understand requirements before designing

countermeasures

19 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 78: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attack requirements www.tugraz.at

• Timers were always the main focus

• Reducing timer resolution is not sufficient

• Timers can (always) be built

• Some attacks do not require timers at all

• Important to understand requirements before designing

countermeasures

19 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 79: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci
Page 80: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Identify requirements www.tugraz.at

• Currently 11 microarchitectural and side-channel attacks in JavaScript

• Analyse requirements for every attack

• Results in 5 categories

• Memory addresses

• Accurate timing

• Multithreading

• Shared data

• Sensor API

• Every attack is in at least one category

20 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 81: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Identify requirements www.tugraz.at

• Currently 11 microarchitectural and side-channel attacks in JavaScript

• Analyse requirements for every attack

• Results in 5 categories

• Memory addresses

• Accurate timing

• Multithreading

• Shared data

• Sensor API

• Every attack is in at least one category

20 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 82: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Identify requirements www.tugraz.at

• Currently 11 microarchitectural and side-channel attacks in JavaScript

• Analyse requirements for every attack

• Results in 5 categories

• Memory addresses

• Accurate timing

• Multithreading

• Shared data

• Sensor API

• Every attack is in at least one category

20 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 83: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Identify requirements www.tugraz.at

• Currently 11 microarchitectural and side-channel attacks in JavaScript

• Analyse requirements for every attack

• Results in 5 categories

• Memory addresses

• Accurate timing

• Multithreading

• Shared data

• Sensor API

• Every attack is in at least one category

20 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 84: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Identify requirements www.tugraz.at

• Currently 11 microarchitectural and side-channel attacks in JavaScript

• Analyse requirements for every attack

• Results in 5 categories

• Memory addresses

• Accurate timing

• Multithreading

• Shared data

• Sensor API

• Every attack is in at least one category

20 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 85: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Attacks and Categories www.tugraz.at

Mem

oryaddresses

Accurate

timing

Multithreading

Shared

data

Sen

sorAPI

Rowhammer.js

Practical Memory Deduplication Attacks in Sandboxed Javascript

Fantastic Timers and Where to Find Them †

ASLR on the Line †

The spy in the sandbox

Loophole

Pixel perfect timing attacks with HTML5 †

The clock is still ticking

Practical Keystroke Timing Attacks in Sandboxed JavaScript †

TouchSignatures

Stealing sensitive browser data with the W3C Ambient Light Sensor API

† If accurate timing is not available, it can be approximated using a combination of multithreading and shared data.

21 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 86: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• Language does not provide addresses to programmer

• Closest to virtual address: array indices

• ArrayBuffer is page aligned, leaks 12 bits of address

• If 2 MB backing pages are used, 21 bits of address known

• If not page aligned: detect page faults through timing

22 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 87: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• Language does not provide addresses to programmer

• Closest to virtual address: array indices

• ArrayBuffer is page aligned, leaks 12 bits of address

• If 2 MB backing pages are used, 21 bits of address known

• If not page aligned: detect page faults through timing

22 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 88: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• Language does not provide addresses to programmer

• Closest to virtual address: array indices

• ArrayBuffer is page aligned, leaks 12 bits of address

• If 2 MB backing pages are used, 21 bits of address known

• If not page aligned: detect page faults through timing

22 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 89: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• Language does not provide addresses to programmer

• Closest to virtual address: array indices

• ArrayBuffer is page aligned, leaks 12 bits of address

• If 2 MB backing pages are used, 21 bits of address known

• If not page aligned: detect page faults through timing

22 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 90: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• Language does not provide addresses to programmer

• Closest to virtual address: array indices

• ArrayBuffer is page aligned, leaks 12 bits of address

• If 2 MB backing pages are used, 21 bits of address known

• If not page aligned: detect page faults through timing

22 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 91: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Nearly all attacks require accurate timing

• No absolute timestamps required, only time differences

• Required accuracy varies between milliseconds and nanoseconds

• Such timers can be built if not available (e.g., message passing)

• If attack is repeatable, less accurate timing can be sufficient

23 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 92: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Nearly all attacks require accurate timing

• No absolute timestamps required, only time differences

• Required accuracy varies between milliseconds and nanoseconds

• Such timers can be built if not available (e.g., message passing)

• If attack is repeatable, less accurate timing can be sufficient

23 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 93: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Nearly all attacks require accurate timing

• No absolute timestamps required, only time differences

• Required accuracy varies between milliseconds and nanoseconds

• Such timers can be built if not available (e.g., message passing)

• If attack is repeatable, less accurate timing can be sufficient

23 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 94: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Nearly all attacks require accurate timing

• No absolute timestamps required, only time differences

• Required accuracy varies between milliseconds and nanoseconds

• Such timers can be built if not available (e.g., message passing)

• If attack is repeatable, less accurate timing can be sufficient

23 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 95: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Nearly all attacks require accurate timing

• No absolute timestamps required, only time differences

• Required accuracy varies between milliseconds and nanoseconds

• Such timers can be built if not available (e.g., message passing)

• If attack is repeatable, less accurate timing can be sufficient

23 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 96: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• JavaScript introduced multi threading with web workers

• Enables new side-channel attacks

• Dispatch latency of event queue allows to infer activity of other tabs

• Endless loop in worker allows to detect hardware interrupts

24 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 97: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• JavaScript introduced multi threading with web workers

• Enables new side-channel attacks

• Dispatch latency of event queue allows to infer activity of other tabs

• Endless loop in worker allows to detect hardware interrupts

24 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 98: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• JavaScript introduced multi threading with web workers

• Enables new side-channel attacks

• Dispatch latency of event queue allows to infer activity of other tabs

• Endless loop in worker allows to detect hardware interrupts

24 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 99: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• JavaScript introduced multi threading with web workers

• Enables new side-channel attacks

• Dispatch latency of event queue allows to infer activity of other tabs

• Endless loop in worker allows to detect hardware interrupts

24 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 100: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Usually no shared data between threads due to synchronization issues

• Exception: SharedArrayBuffer

• Only useful in combination with web workers

• Allows to build timers with extremely high resolution (up to 1 ns)

• Not enabled by default

25 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 101: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Usually no shared data between threads due to synchronization issues

• Exception: SharedArrayBuffer

• Only useful in combination with web workers

• Allows to build timers with extremely high resolution (up to 1 ns)

• Not enabled by default

25 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 102: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Usually no shared data between threads due to synchronization issues

• Exception: SharedArrayBuffer

• Only useful in combination with web workers

• Allows to build timers with extremely high resolution (up to 1 ns)

• Not enabled by default

25 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 103: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Usually no shared data between threads due to synchronization issues

• Exception: SharedArrayBuffer

• Only useful in combination with web workers

• Allows to build timers with extremely high resolution (up to 1 ns)

• Not enabled by default

25 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 104: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Usually no shared data between threads due to synchronization issues

• Exception: SharedArrayBuffer

• Only useful in combination with web workers

• Allows to build timers with extremely high resolution (up to 1 ns)

• Not enabled by default

25 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 105: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Some side-channel attacks only require access to sensors

• Several sensors are available in JavaScript

• Some require user consent, e.g., microphone

• Other can be used without user consent, e.g., ambient light

• There are attacks with these sensors

26 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 106: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Some side-channel attacks only require access to sensors

• Several sensors are available in JavaScript

• Some require user consent, e.g., microphone

• Other can be used without user consent, e.g., ambient light

• There are attacks with these sensors

26 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 107: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Some side-channel attacks only require access to sensors

• Several sensors are available in JavaScript

• Some require user consent, e.g., microphone

• Other can be used without user consent, e.g., ambient light

• There are attacks with these sensors

26 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 108: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Some side-channel attacks only require access to sensors

• Several sensors are available in JavaScript

• Some require user consent, e.g., microphone

• Other can be used without user consent, e.g., ambient light

• There are attacks with these sensors

26 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 109: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Some side-channel attacks only require access to sensors

• Several sensors are available in JavaScript

• Some require user consent, e.g., microphone

• Other can be used without user consent, e.g., ambient light

• There are attacks with these sensors

26 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 110: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Defenses

Page 111: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Countermeasures www.tugraz.at

• Countermeasures have to address all categories

• Should not be visible to the programmer

• Implementation is on the “microarchitectural” level of JavaScript

• If no category is usable for attacks anymore, future attacks are hard

27 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 112: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Countermeasures www.tugraz.at

• Countermeasures have to address all categories

• Should not be visible to the programmer

• Implementation is on the “microarchitectural” level of JavaScript

• If no category is usable for attacks anymore, future attacks are hard

27 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 113: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Countermeasures www.tugraz.at

• Countermeasures have to address all categories

• Should not be visible to the programmer

• Implementation is on the “microarchitectural” level of JavaScript

• If no category is usable for attacks anymore, future attacks are hard

27 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 114: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Countermeasures www.tugraz.at

• Countermeasures have to address all categories

• Should not be visible to the programmer

• Implementation is on the “microarchitectural” level of JavaScript

• If no category is usable for attacks anymore, future attacks are hard

27 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 115: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#1: Buffer ASLR

• Ensure arrays are not page aligned

• Attacker cannot assume that least significant 12 bits are ‘0’

• Only works for the first page

• Consecutive page borders can be detected through page faults

28 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 116: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#1: Buffer ASLR

• Ensure arrays are not page aligned

• Attacker cannot assume that least significant 12 bits are ‘0’

• Only works for the first page

• Consecutive page borders can be detected through page faults

28 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 117: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#1: Buffer ASLR

• Ensure arrays are not page aligned

• Attacker cannot assume that least significant 12 bits are ‘0’

• Only works for the first page

• Consecutive page borders can be detected through page faults

28 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 118: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#1: Buffer ASLR

• Ensure arrays are not page aligned

• Attacker cannot assume that least significant 12 bits are ‘0’

• Only works for the first page

• Consecutive page borders can be detected through page faults

28 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 119: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#1: Buffer ASLR

• Ensure arrays are not page aligned

• Attacker cannot assume that least significant 12 bits are ‘0’

• Only works for the first page

• Consecutive page borders can be detected through page faults

28 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 120: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#2: Preloading

• Instead of lazy initialization for arrays, ensure that they are always

memory backed

• Attacker cannot detect page borders through page faults anymore

• Does not work if swapping or page deduplication is enabled

• Has to be combined with Buffer ASLR

29 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 121: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#2: Preloading

• Instead of lazy initialization for arrays, ensure that they are always

memory backed

• Attacker cannot detect page borders through page faults anymore

• Does not work if swapping or page deduplication is enabled

• Has to be combined with Buffer ASLR

29 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 122: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#2: Preloading

• Instead of lazy initialization for arrays, ensure that they are always

memory backed

• Attacker cannot detect page borders through page faults anymore

• Does not work if swapping or page deduplication is enabled

• Has to be combined with Buffer ASLR

29 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 123: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#2: Preloading

• Instead of lazy initialization for arrays, ensure that they are always

memory backed

• Attacker cannot detect page borders through page faults anymore

• Does not work if swapping or page deduplication is enabled

• Has to be combined with Buffer ASLR

29 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 124: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#3: Non-determinism

• For every array access, add another random access

• Makes page border detection infeasible without requiring significantly

more memory

• Attacker always times two accesses

• Distinguishing cached from non-cached addresses is hard

30 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 125: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#3: Non-determinism

• For every array access, add another random access

• Makes page border detection infeasible without requiring significantly

more memory

• Attacker always times two accesses

• Distinguishing cached from non-cached addresses is hard

30 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 126: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#3: Non-determinism

• For every array access, add another random access

• Makes page border detection infeasible without requiring significantly

more memory

• Attacker always times two accesses

• Distinguishing cached from non-cached addresses is hard

30 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 127: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#3: Non-determinism

• For every array access, add another random access

• Makes page border detection infeasible without requiring significantly

more memory

• Attacker always times two accesses

• Distinguishing cached from non-cached addresses is hard

30 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 128: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#4: Array Index Randomization

• Ensures arrays are not linear

• Use a random linear function to map array index to underlying buffer

• Index x maps to f (x) = ax + b mod n, where n is array length and a

and b are randomly chosen

• Has to be combined with Buffer ASLR and either Preloading or

Non-determinism

31 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 129: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#4: Array Index Randomization

• Ensures arrays are not linear

• Use a random linear function to map array index to underlying buffer

• Index x maps to f (x) = ax + b mod n, where n is array length and a

and b are randomly chosen

• Has to be combined with Buffer ASLR and either Preloading or

Non-determinism

31 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 130: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#4: Array Index Randomization

• Ensures arrays are not linear

• Use a random linear function to map array index to underlying buffer

• Index x maps to f (x) = ax + b mod n, where n is array length and a

and b are randomly chosen

• Has to be combined with Buffer ASLR and either Preloading or

Non-determinism

31 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 131: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

#4: Array Index Randomization

• Ensures arrays are not linear

• Use a random linear function to map array index to underlying buffer

• Index x maps to f (x) = ax + b mod n, where n is array length and a

and b are randomly chosen

• Has to be combined with Buffer ASLR and either Preloading or

Non-determinism

31 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 132: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• The four defenses prevent attackers from getting virtual and physical

addresses

• Prevents many microarchitectural attacks

• Have to be combined for maximum security

• Side effect: make exploits harder where addresses are required

32 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 133: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• The four defenses prevent attackers from getting virtual and physical

addresses

• Prevents many microarchitectural attacks

• Have to be combined for maximum security

• Side effect: make exploits harder where addresses are required

32 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 134: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• The four defenses prevent attackers from getting virtual and physical

addresses

• Prevents many microarchitectural attacks

• Have to be combined for maximum security

• Side effect: make exploits harder where addresses are required

32 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 135: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Memory Addresses www.tugraz.at

• The four defenses prevent attackers from getting virtual and physical

addresses

• Prevents many microarchitectural attacks

• Have to be combined for maximum security

• Side effect: make exploits harder where addresses are required

32 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 136: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Reducing the resolution of performance.now() is a first step

• Only rounding the timestamps is not sufficient

• Fuzzy time (Vattikonda et al.) adds random jitter

• Timestamps are still monotonic, but clock edges are randomized

33 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 137: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Reducing the resolution of performance.now() is a first step

• Only rounding the timestamps is not sufficient

• Fuzzy time (Vattikonda et al.) adds random jitter

• Timestamps are still monotonic, but clock edges are randomized

33 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 138: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Reducing the resolution of performance.now() is a first step

• Only rounding the timestamps is not sufficient

• Fuzzy time (Vattikonda et al.) adds random jitter

• Timestamps are still monotonic, but clock edges are randomized

33 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 139: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Accurate Timing www.tugraz.at

• Reducing the resolution of performance.now() is a first step

• Only rounding the timestamps is not sufficient

• Fuzzy time (Vattikonda et al.) adds random jitter

• Timestamps are still monotonic, but clock edges are randomized

33 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 140: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• Only real solution is to prevent multithreading

• We used a polyfill to not completely break websites

• Some attacks can be prevented by adding random delays to

postMessage

• Prevents certain timing primitives and attacks on the event-queue

latency

34 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 141: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• Only real solution is to prevent multithreading

• We used a polyfill to not completely break websites

• Some attacks can be prevented by adding random delays to

postMessage

• Prevents certain timing primitives and attacks on the event-queue

latency

34 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 142: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• Only real solution is to prevent multithreading

• We used a polyfill to not completely break websites

• Some attacks can be prevented by adding random delays to

postMessage

• Prevents certain timing primitives and attacks on the event-queue

latency

34 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 143: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Multithreading www.tugraz.at

• Only real solution is to prevent multithreading

• We used a polyfill to not completely break websites

• Some attacks can be prevented by adding random delays to

postMessage

• Prevents certain timing primitives and attacks on the event-queue

latency

34 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 144: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Best countermeasures: do not allow shared data

• Many attacks are impossible without SharedArrayBuffer

• Alternative: delay access to buffer

• Still faster than message passing

• Degrades resolution of timing primitive to microseconds

35 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 145: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Best countermeasures: do not allow shared data

• Many attacks are impossible without SharedArrayBuffer

• Alternative: delay access to buffer

• Still faster than message passing

• Degrades resolution of timing primitive to microseconds

35 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 146: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Best countermeasures: do not allow shared data

• Many attacks are impossible without SharedArrayBuffer

• Alternative: delay access to buffer

• Still faster than message passing

• Degrades resolution of timing primitive to microseconds

35 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 147: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Best countermeasures: do not allow shared data

• Many attacks are impossible without SharedArrayBuffer

• Alternative: delay access to buffer

• Still faster than message passing

• Degrades resolution of timing primitive to microseconds

35 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 148: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Shared Data www.tugraz.at

• Best countermeasures: do not allow shared data

• Many attacks are impossible without SharedArrayBuffer

• Alternative: delay access to buffer

• Still faster than message passing

• Degrades resolution of timing primitive to microseconds

35 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 149: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Reduce resolution and update frequency of sensors

• Sensor APIs should always ask user for permission

• Every sensor is usable for attacks, even ambient light sensor

• To not break existing applications, sensors return constant value

36 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 150: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Reduce resolution and update frequency of sensors

• Sensor APIs should always ask user for permission

• Every sensor is usable for attacks, even ambient light sensor

• To not break existing applications, sensors return constant value

36 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 151: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Reduce resolution and update frequency of sensors

• Sensor APIs should always ask user for permission

• Every sensor is usable for attacks, even ambient light sensor

• To not break existing applications, sensors return constant value

36 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 152: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Sensor API www.tugraz.at

• Reduce resolution and update frequency of sensors

• Sensor APIs should always ask user for permission

• Every sensor is usable for attacks, even ambient light sensor

• To not break existing applications, sensors return constant value

36 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 153: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Implementation

Page 154: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 155: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 156: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 157: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 158: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 159: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Designing the Countermeasure www.tugraz.at

• Best solution is to implement defenses in the browser core

• Maintaining a browser fork is hard work

• We want a generic solution for multiple browsers

• Parsing JavaScript is hard

• Implementation in JavaScript → Virtual machine layering

• Proof-of-concept is implemented as browser extension

37 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 160: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

User Experience www.tugraz.at

• Some defenses might impair user experience, e.g., disable

multithreading

• The user can choose one of several pre-defined protection levels

• Protection levels apply different combinations of defenses

• Each defense can either be disabled, enabled, or require user

permission

38 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 161: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

User Experience www.tugraz.at

• Some defenses might impair user experience, e.g., disable

multithreading

• The user can choose one of several pre-defined protection levels

• Protection levels apply different combinations of defenses

• Each defense can either be disabled, enabled, or require user

permission

38 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 162: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

User Experience www.tugraz.at

• Some defenses might impair user experience, e.g., disable

multithreading

• The user can choose one of several pre-defined protection levels

• Protection levels apply different combinations of defenses

• Each defense can either be disabled, enabled, or require user

permission

38 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 163: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

User Experience www.tugraz.at

• Some defenses might impair user experience, e.g., disable

multithreading

• The user can choose one of several pre-defined protection levels

• Protection levels apply different combinations of defenses

• Each defense can either be disabled, enabled, or require user

permission

38 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 164: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering www.tugraz.at

• Functions and properties are replaced by wrappers

Script

Wrapper

Extension ContextPage Context

Call

Ret

urn

Call

Allowed?

Original Function

Yes

No

Default value

Filtered value

39 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 165: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering www.tugraz.at

• Functions can be re-defined in JavaScript

var o r i g i n a l r e f e r e n c e = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = funct ion ( ) { return 0 ; } ;

// call the new function (via function name)

a l e r t ( window . p e r f o r m a n c e . now ( ) ) ; // == alert(0)

// call the original function (only via reference)

a l e r t ( o r i g i n a l r e f e r e n c e . c a l l ( window . p e r f o r m a n c e ) ) ;

• Properties can be replaced by accessor properties

40 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 166: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering www.tugraz.at

• Functions can be re-defined in JavaScript

var o r i g i n a l r e f e r e n c e = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = funct ion ( ) { return 0 ; } ;

// call the new function (via function name)

a l e r t ( window . p e r f o r m a n c e . now ( ) ) ; // == alert(0)

// call the original function (only via reference)

a l e r t ( o r i g i n a l r e f e r e n c e . c a l l ( window . p e r f o r m a n c e ) ) ;

• Properties can be replaced by accessor properties

40 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 167: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering www.tugraz.at

• Functions can be re-defined in JavaScript

var o r i g i n a l r e f e r e n c e = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = funct ion ( ) { return 0 ; } ;

// call the new function (via function name)

a l e r t ( window . p e r f o r m a n c e . now ( ) ) ; // == alert(0)

// call the original function (only via reference)

a l e r t ( o r i g i n a l r e f e r e n c e . c a l l ( window . p e r f o r m a n c e ) ) ;

• Properties can be replaced by accessor properties

40 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 168: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering www.tugraz.at

• Functions can be re-defined in JavaScript

var o r i g i n a l r e f e r e n c e = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = funct ion ( ) { return 0 ; } ;

// call the new function (via function name)

a l e r t ( window . p e r f o r m a n c e . now ( ) ) ; // == alert(0)

// call the original function (only via reference)

a l e r t ( o r i g i n a l r e f e r e n c e . c a l l ( window . p e r f o r m a n c e ) ) ;

• Properties can be replaced by accessor properties

40 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 169: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering for Objects www.tugraz.at

• Objects are proxied

Script

Methods

Object

Methods

Filter

new Object

Proxy(Object)

• All properties and functions are handled by the original object

• Functions and properties can be overwritten in the proxy object

41 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 170: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering for Objects www.tugraz.at

• Objects are proxied

Script

Methods

Object

Methods

Filter

new Object

Proxy(Object)

• All properties and functions are handled by the original object

• Functions and properties can be overwritten in the proxy object

41 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 171: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Virtual Machine Layering for Objects www.tugraz.at

• Objects are proxied

Script

Methods

Object

Methods

Filter

new Object

Proxy(Object)

• All properties and functions are handled by the original object

• Functions and properties can be overwritten in the proxy object

41 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 172: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Self Protection www.tugraz.at

• Attacker tries to circumvent JavaScript Zero

• Self protection is necessary if implemented in JavaScript

• Use closures to hide all references to original functions

( funct ion ( ) {// original is only accessible in this scope

var o r i g i n a l = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = . . .

} ) ( ) ;

• Prevent objects from being modified: Object.freeze

42 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 173: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Self Protection www.tugraz.at

• Attacker tries to circumvent JavaScript Zero

• Self protection is necessary if implemented in JavaScript

• Use closures to hide all references to original functions

( funct ion ( ) {// original is only accessible in this scope

var o r i g i n a l = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = . . .

} ) ( ) ;

• Prevent objects from being modified: Object.freeze

42 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 174: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Self Protection www.tugraz.at

• Attacker tries to circumvent JavaScript Zero

• Self protection is necessary if implemented in JavaScript

• Use closures to hide all references to original functions

( funct ion ( ) {// original is only accessible in this scope

var o r i g i n a l = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = . . .

} ) ( ) ;

• Prevent objects from being modified: Object.freeze

42 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 175: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Self Protection www.tugraz.at

• Attacker tries to circumvent JavaScript Zero

• Self protection is necessary if implemented in JavaScript

• Use closures to hide all references to original functions

( funct ion ( ) {// original is only accessible in this scope

var o r i g i n a l = window . p e r f o r m a n c e . now ;

window . p e r f o r m a n c e . now = . . .

} ) ( ) ;

• Prevent objects from being modified: Object.freeze

42 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 176: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Evaluation

Page 177: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection www.tugraz.at

• Border of pages leak 12 or 21 bits (depending on page size)

• Create huge array

• Iterate over array, measure access time

• Page border raise pagefault, taking significantly longer to access

43 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 178: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection www.tugraz.at

• Border of pages leak 12 or 21 bits (depending on page size)

• Create huge array

• Iterate over array, measure access time

• Page border raise pagefault, taking significantly longer to access

43 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 179: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection www.tugraz.at

• Border of pages leak 12 or 21 bits (depending on page size)

• Create huge array

• Iterate over array, measure access time

• Page border raise pagefault, taking significantly longer to access

43 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 180: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection www.tugraz.at

• Border of pages leak 12 or 21 bits (depending on page size)

• Create huge array

• Iterate over array, measure access time

• Page border raise pagefault, taking significantly longer to access

43 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 181: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection www.tugraz.at

0 0.2 0.4 0.6 0.8 1 1.2

·104

0

0.5

1·105

Array offset [KB]

Acc

ess

tim

e

[cyc

les]

44 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 182: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Page Border Detection with Random Access www.tugraz.at

0 1,000 2,000 3,000 4,000 5,0000

0.5

1·105

Array offset [KB]

Acc

ess

tim

e

[cyc

les]

45 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 183: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 184: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 185: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 186: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 187: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 188: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

• Find addresses (= array indices) that fall into same cache set

• Physical address defines in which cache set the data is cached

• Enough addresses in one set evicts the set (Prime)

• Iterate again over addresses (Probe)

• If it is fast, they are still cached

• If it is slow, someone used this cache set and evicted our addresses

46 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 189: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe www.tugraz.at

47 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 190: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Prime+Probe with Random Access www.tugraz.at

48 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 191: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection www.tugraz.at

• Multithreading allows to detect interrupts

• Endless loop which counts number of increments in time window

• Different number of increments indicate interrupt

• Fuzzy time prevents deterministic equally-sized time window

49 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 192: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection www.tugraz.at

• Multithreading allows to detect interrupts

• Endless loop which counts number of increments in time window

• Different number of increments indicate interrupt

• Fuzzy time prevents deterministic equally-sized time window

49 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 193: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection www.tugraz.at

• Multithreading allows to detect interrupts

• Endless loop which counts number of increments in time window

• Different number of increments indicate interrupt

• Fuzzy time prevents deterministic equally-sized time window

49 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 194: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection www.tugraz.at

• Multithreading allows to detect interrupts

• Endless loop which counts number of increments in time window

• Different number of increments indicate interrupt

• Fuzzy time prevents deterministic equally-sized time window

49 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 195: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection www.tugraz.at

0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11,7001,7501,8001,850

tap tap tap tap

Runtime [s]

Delta

[counter]

50 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 196: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Interrupt Detection with Fuzzy Time www.tugraz.at

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7600

700

800

900

tap tap tap tap

Runtime [s]

Delta

[counter]

51 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 197: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying www.tugraz.at

• Messages between web workers are handled in the event queue

• User activity is also handled in the event queue

• Posting many messages allows to measure latency

• Latency indicates user input

52 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 198: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying www.tugraz.at

• Messages between web workers are handled in the event queue

• User activity is also handled in the event queue

• Posting many messages allows to measure latency

• Latency indicates user input

52 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 199: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying www.tugraz.at

• Messages between web workers are handled in the event queue

• User activity is also handled in the event queue

• Posting many messages allows to measure latency

• Latency indicates user input

52 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 200: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying www.tugraz.at

• Messages between web workers are handled in the event queue

• User activity is also handled in the event queue

• Posting many messages allows to measure latency

• Latency indicates user input

52 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 201: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying www.tugraz.at

2,560 2,570 2,580 2,590 2,600 2,610 2,620 2,630 2,6400

0.51

1.52

Runtime [ms]

Delta

[ms]

53 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 202: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Event Queue Spying with Message Delay www.tugraz.at

2,860 2,870 2,880 2,890 2,900 2,910 2,920 2,930 2,9400123

Runtime [ms]

Delta

[ms]

54 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 203: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer Timing Primitive www.tugraz.at

• SharedArrayBuffer allows to build a timing primitive with the

highest resolution

• One web worker continuously increments variable in the shared array

• Other worker uses this as a timestamp

• Adding random delay to access degrades resolution

55 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 204: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer Timing Primitive www.tugraz.at

• SharedArrayBuffer allows to build a timing primitive with the

highest resolution

• One web worker continuously increments variable in the shared array

• Other worker uses this as a timestamp

• Adding random delay to access degrades resolution

55 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 205: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer Timing Primitive www.tugraz.at

• SharedArrayBuffer allows to build a timing primitive with the

highest resolution

• One web worker continuously increments variable in the shared array

• Other worker uses this as a timestamp

• Adding random delay to access degrades resolution

55 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 206: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer Timing Primitive www.tugraz.at

• SharedArrayBuffer allows to build a timing primitive with the

highest resolution

• One web worker continuously increments variable in the shared array

• Other worker uses this as a timestamp

• Adding random delay to access degrades resolution

55 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 207: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer www.tugraz.at

56 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 208: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

SharedArrayBuffer with Random Delay www.tugraz.at

57 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 209: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Defense

Prevents Rowham- Page Dedu- DRAM Covert Anti- Cache Keystroke Browser

mer.js plication Channel ASLR Eviction Timing

Buffer ASLR

Array preloading

Non-deterministic array

Array index randomization

Low-resolution timestamp

Fuzzy time * * * *

WebWorker polyfill

Message delay

Slow SharedArrayBuffer

No SharedArrayBuffer * * * *

Summary

Symbols indicate whether a policy fully prevents an attack, ( ), partly prevents and attack by

making it more difficult ( ), or does not prevent an attack ( ).

A star (*) indicates that all policies marked with a star must be combined to prevent an attack.

58 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 210: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

User Experience www.tugraz.at

59 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 211: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Conclusion www.tugraz.at

• Just rounding timers is not sufficient

• Multithreading and shared data allow to build new timers

• Microarchitectural attacks in the browser are possible at the moment

• Efficient countermeasures can be implemented in browsers

• More microarchitectural attacks in JavaScript will appear

60 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 212: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Conclusion www.tugraz.at

• Just rounding timers is not sufficient

• Multithreading and shared data allow to build new timers

• Microarchitectural attacks in the browser are possible at the moment

• Efficient countermeasures can be implemented in browsers

• More microarchitectural attacks in JavaScript will appear

60 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 213: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Conclusion www.tugraz.at

• Just rounding timers is not sufficient

• Multithreading and shared data allow to build new timers

• Microarchitectural attacks in the browser are possible at the moment

• Efficient countermeasures can be implemented in browsers

• More microarchitectural attacks in JavaScript will appear

60 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 214: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Conclusion www.tugraz.at

• Just rounding timers is not sufficient

• Multithreading and shared data allow to build new timers

• Microarchitectural attacks in the browser are possible at the moment

• Efficient countermeasures can be implemented in browsers

• More microarchitectural attacks in JavaScript will appear

60 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at

Page 215: Microarchitectural Attacks and Defenses in JavaScriptMicroarchitecture Microarchitecture... is not de ned on the architectural state should not be visible to software is hardware speci

Conclusion www.tugraz.at

• Just rounding timers is not sufficient

• Multithreading and shared data allow to build new timers

• Microarchitectural attacks in the browser are possible at the moment

• Efficient countermeasures can be implemented in browsers

• More microarchitectural attacks in JavaScript will appear

60 Michael Schwarz, Daniel Gruss, Moritz Lipp — www.iaik.tugraz.at