O N S UBNORMAL F LOATING P OINT AND A BNORMAL T IMING Marc Andrysco, - - PowerPoint PPT Presentation

o n s ubnormal f loating p oint and a bnormal t iming
SMART_READER_LITE
LIVE PREVIEW

O N S UBNORMAL F LOATING P OINT AND A BNORMAL T IMING Marc Andrysco, - - PowerPoint PPT Presentation

O N S UBNORMAL F LOATING P OINT AND A BNORMAL T IMING Marc Andrysco, David Kohlbrenner, Keaton Mowery, Ranjit Jhala, Sorin Lerner, and Hovav Shacham UC San Diego 2 3 L ETS RUN SOME CODE Subnormal Floating Normal Floating Point Point 4 L ETS


slide-1
SLIDE 1

ON SUBNORMAL FLOATING POINT AND ABNORMAL TIMING

Marc Andrysco, David Kohlbrenner, Keaton Mowery, Ranjit Jhala, Sorin Lerner, and Hovav Shacham UC San Diego

slide-2
SLIDE 2

2

slide-3
SLIDE 3

3

slide-4
SLIDE 4

LETS RUN SOME CODE

4

Normal Floating Point Subnormal Floating Point

slide-5
SLIDE 5

LETS RUN SOME CODE

5

Normal Floating Point Subnormal Floating Point

0.204s 4.332s

slide-6
SLIDE 6

20 TIMES SLOWER?

 Who knew?  Numerical analysts  CPU designers  Game engine authors

6

slide-7
SLIDE 7

20 TIMES SLOWER?

 Who knew?  Numerical analysts  CPU designers  Game engine authors  Who should know?  “What Every Computer Scientist Should Know About

Floating-Point Arithmetic” – Goldberg ’91

7

slide-8
SLIDE 8

20 TIMES SLOWER?

 Who knew?  Numerical analysts  CPU designers  Game engine authors  Who should know?  “What Every Computer Scientist Should Know About

Floating-Point Arithmetic” – Goldberg ’91

 Academic researchers claim to “effectively

close[s] all known remotely exploitable channels”

 Specifically referring to timing side channels!

8

slide-9
SLIDE 9

FLOATING POINT AND TIMING

9

slide-10
SLIDE 10

WHAT HAPPENED?

 IEEE 754 specifies subnormal floating point

values

10

slide-11
SLIDE 11

FLOATING POINT NORMAL AND SUBNORMAL

  Value = (−1)𝑡𝑗𝑕𝑜 ∗ 𝑡𝑗𝑕𝑜𝑗𝑔𝑗𝑑𝑏𝑜𝑒 ∗ 2(𝑓𝑦𝑞𝑝𝑜𝑓𝑜𝑢−𝑐𝑗𝑏𝑡)  The exponent is non-zero  Normal values have an implicit leading 1-bit on the

significand

 A subnormal value is a special encoding  The exponent is all zeroes  The significand has an implicit leading 0-bit

11

slide-12
SLIDE 12

SUBNORMAL DETAILS

 Subnormal ranges (double)  Minimum: ~4.9 × 10−324  Maximum: ~2.23 × 10−308  Planck length: 1.6 × 10−35 m  Why?  Extend the range of floating point  Graceful underflow

12

if(a != b) x = c / (a-b);

slide-13
SLIDE 13

WHAT HAPPENED?

 IEEE 754 specifies subnormal floating point

values

 FPUs are optimized for pure speed  Subnormals are not the common case  So let's pretend they don't matter!  Subnormals are a hardware slowpath  The Alpha trapped to kernel for subnormals!  Most GPUs don’t support them

13

slide-14
SLIDE 14

FLOATING POINT IS A SECURITY ISSUE

 Ilya Mironov on Laplacian noise generation  Lack of dependable results  gcc –O1 vs gcc –O3

14

slide-15
SLIDE 15

LEVERAGING SUBNORMAL

FLOATING POINT INTO ATTACKS

15

slide-16
SLIDE 16

FLOATING POINT AS A SIDE-CHANNEL

 Code that operates on secret and attacker values

can result in timing side channels

 From instruction traces  Or memory access patterns  Or IO usage  Etc.  We present the first instruction data based

timing side channel attack on a commodity desktop processor

 Proposed by Kocher 20 years ago!

16

slide-17
SLIDE 17

FLOATING POINT HARDWARE DATA

17

Core i7-3667U SSE and x87 Atom D2550 SSE and x87

slide-18
SLIDE 18

AMPLIFYING TIMING DIFFERENCES

 Even a 100 cycle difference is hard to spot  Especially with a loaded system

18

slide-19
SLIDE 19

AMPLIFYING TIMING DIFFERENCES

 Even a 100 cycle difference is hard to spot  Especially with a loaded system  We need an amplifier  Remember our sample code?  We need tight math loops

19

slide-20
SLIDE 20

DETOUR TIME!

Firefox SVG Filters and Previous Attacks

20

slide-21
SLIDE 21

FIREFOX SVG FILTERS

 Turn this

21

slide-22
SLIDE 22

FIREFOX SVG FILTERS

 Into this!

<svg><filter> <feGaussianBlur stdDeviation="3"/> </filter></svg>

22

slide-23
SLIDE 23

FIREFOX SVG FILTERS

 CSS defined filters  <div>  <iframe>  Really any element  Run various functions  convolve  blur  skew  gradient  clipping  Stackable!

23

slide-24
SLIDE 24

FIREFOX SVG FILTER TIMING ATTACK

24

 See Paul Stone’s “Pixel Perfect Timing Attacks

with HTML 5”

slide-25
SLIDE 25

FIREFOX SVG FILTER TIMING ATTACK

25

 See Paul Stone’s “Pixel Perfect Timing Attacks

with HTML 5”

slide-26
SLIDE 26

FIREFOX SVG FILTER TIMING ATTACK

26

 See Paul Stone’s “Pixel Perfect Timing Attacks

with HTML 5”

slide-27
SLIDE 27

FIREFOX SVG FILTER TIMING ATTACK

27

 See Paul Stone’s “Pixel Perfect Timing Attacks

with HTML 5”

slide-28
SLIDE 28

PAUL STONE’S SVG TIMING SIDE CHANNEL

 Relied on a fast path optimization in the

femorphology SVG filter

 In cases of a solid color image, filter ran much faster  Fix was to write constant time code!  Took ~2 years to land, and 150+ comment bug thread  “the problem boils down to: how to implement constant-time

min(a, b) and max(a, b) in C++?” – Bugzilla thread

28

slide-29
SLIDE 29

BACK TO THE PRESENT

29

slide-30
SLIDE 30

NEW FIREFOX SVG FILTER ATTACK

 Firefox SVG Filters are still ‘vulnerable’ pending

a timing difference

 We have a new timing side-channel source

30

slide-31
SLIDE 31

NEW FIREFOX SVG FILTER ATTACK

 Firefox SVG Filters are still ‘vulnerable’ pending

a timing difference

 We have a new timing side-channel source  SVG Filters run floating point math!

31

slide-32
SLIDE 32

NEW FIREFOX SVG FILTER ATTACK

 Firefox SVG Filters are still ‘vulnerable’ pending

a timing difference

 We have a new timing side-channel source  SVG Filters run floating point math!  We need an amplifier

32

slide-33
SLIDE 33

NEW FIREFOX SVG FILTER ATTACK

 We need an amplifier

33

slide-34
SLIDE 34

FIREFOX SVG FILTERS AND SUBNORMALS

34

slide-35
SLIDE 35

FIREFOX SVG FILTERS AND SUBNORMALS

35

1 × 𝑡 0 × 𝑡

slide-36
SLIDE 36

FIREFOX SVG FILTERS AND SUBNORMALS

36

𝑡 + 𝑡 0+0

slide-37
SLIDE 37

FIREFOX SVG FILTER TIMING ATTACK

37

slide-38
SLIDE 38

FIREFOX SVG FILTERS ATTACK IMPACT

 Firefox does not consider running SVG filters

  • ver foreign pixels a violation of SOP

 We disagree  Cross Origin Resource Sharing (CORS) is the obvious

solution

38

slide-39
SLIDE 39

READING PIXELS

 From other origins  Reconstruct characters (OCR)  Extract usernames, login status, user information,

etc

 Blocked with frame options or CSP  From our origin  History sniffing

39

slide-40
SLIDE 40

AVOIDING FLOATING POINT PROBLEMS

40

slide-41
SLIDE 41

RECOMMENDATIONS

 Don’t use floating point in security critical code  Unpredictable results  Large timing variations  Highly processor and build dependent  Use Fixed Point if you need non-integer math

41

slide-42
SLIDE 42

LIBFTFP – FIXED TIME FIXED POINT

 C library implementing most math operations  Add, divide, etc  Transcendentals  Exponents, logs, etc  Variable Width  Constant time! (Probably!)

42

slide-43
SLIDE 43

BUILDING LIBFTFP

 Techniques  No data dependent jumps (&&, if, etc.)  No known variable time instructions (div, idiv, etc.)  No look-up tables (due to caching)  We cannot be 100% sure of the constant-ness of our

code

 Intel doesn’t release any information about instruction

data dependency

 We cannot exhaustively test processors and instruction

arguments

 Writing constant time code is a battle against all

future processors and compilers

 LibFTFP uses approximations

43

slide-44
SLIDE 44

LIBFTFP STATISTICS

 Comparing to hardware

slightly unfair

 Comparing to infinite

precision software (MPFR) also slightly unfair

44

github.com/kmowery/libfixedtimefixedpoint

slide-45
SLIDE 45

TAKEAWAYS

 Security critical code should omit floating

point or be extremely careful

 Writing provably constant time code is

impossible

 Intel? Some help here?  Browsers should require CORS/CSP for

computing over all foreign data

 Like pixels

45

slide-46
SLIDE 46

FUTURE WORK

 Firefox attack works on FF 23-27  Attack stopped working when filters changed to GPU  GPU floating point implementations  “On NVIDIA GPUs starting with the Fermi architecture […]

multi-instruction sequences such as square root and […] reciprocal square root, must do extra work and take a slower path for denormal values “

 Other math operation data side channels  imul, div/idiv cycle counts are data dependent  What can we break with that?

46

slide-47
SLIDE 47

QUESTIONS?

dkohlbre@cs.ucsd.edu LibFTFP: github.com/kmowery/libfixedtimefixedpoint

47