Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2FA, WTF? (FullStackCon 2015)

8ec1383b240b5ba15ffb9743fceb3c0e?s=47 Phil Nash
October 26, 2015

2FA, WTF? (FullStackCon 2015)

Everyone is hacking everything. Everything is vulnerable. Your site, your users, even you. Are you worried about this? You should be! Don't worry, Phil is not trying to scare you (that much). You have plenty of safeguards against attempts on your applications' user data. We all (hopefully) recognise Two Factor Auth as one of those safeguards, but what actually goes on under the hood of 2FA?

You will discover how to generate one-time passwords and implement 2FA in your applications, and hear the only real-life compelling use case for QR codes. Together, we'll make the web a more secure place.

8ec1383b240b5ba15ffb9743fceb3c0e?s=128

Phil Nash

October 26, 2015
Tweet

Transcript

  1. 2 F A , W T F ? FullStackCon 2015

  2. H A C K E R S

  3. A R E

  4. E V E R Y W H E R E

  5. None
  6. None
  7. None
  8. Phil Nash @philnash h p:/ /philna.sh philnash@twilio.com

  9. 2 F A , W T F ?

  10. T W O F A C T O R A

    U T H E N T I C A T I O N
  11. Two Factor Authen ca on 2FA is a security process

    in which a user provides two different forms of iden fica on in order to authen cate themself with a system. The two forms must come from different categories. Normally something you know and something you have.
  12. W H Y ?

  13. M A T H O N A N

  14. Mat Honan's Hackers' Timeline 1.  Found Gmail address on his

    personal site 2.  Entered address in Gmail and found his @me.com back up email 3.  Called Amazon to add a credit card to file 4.  Called Amazon again to reset password and got access 5.  4:33pm: called Apple to reset password 6.  4:50pm: reset AppleID password and gained access to email
  15. Mat Honan's Hackers' Timeline 7.  4:52pm: reset Gmail account password

    8.  5:01pm: wiped iPhone 9.  5:02pm: reset Twi er password 10.  5:05pm: wiped MacBook and deleted Google account 11.  5:12pm: posted to Twi er taking credit for the hack
  16. @ M A T

  17. W H Y ?

  18. None
  19. A S H L E Y M A D I

    S O N
  20. Ashley Madison Top 10 Passwords 1.  123456 2.  12345 3.

     password 4.  DEFAULT 5.  123456789 6.  qwerty 7.  12345678 8.  abc123 9.  NSFW 10.  1234567
  21. Ashley Madison Top 10 Passwords 1.  123456 ‐ 120,511 users

    2.  12345 ‐ 48,452 users 3.  password ‐ 39,448 users 4.  DEFAULT ‐ 34,275 users 5.  123456789 ‐ 26,620 users 6.  qwerty ‐ 20,778 users 7.  12345678 ‐ 14,172 users 8.  abc123 ‐ 10,869 users 9.  NSFW ‐ 10,683 users 10.  1234567 ‐ 9,468 users Source: h p:/ /qz.com/501073/the‐top‐100‐passwords‐on‐ashley‐madison/
  22. None
  23. H O W ?

  24. User Registra on Flow 1.  Visit registra on page 2.

     Sign up with username and password 3.  User is logged in
  25. User Log In Flow 1.  Visit login page 2.  Enter

    username and password 3.  System verifies details 4.  User is logged in
  26. S M S

  27. User Registra on Flow 1.  Visit registra on page 2.

     Sign up with username, password and phone nunber 3.  User is logged in
  28. User Log In Flow 1.  Visit login page 2.  Enter

    username and password 3.  System verifies details 4.  Verifica on code sent to user by SMS 5.  User enters verifica on code 6.  System verifies code 7.  User is logged in
  29. P R O S / C O N S

  30. S O F T T O K E N

  31. User Registra on Flow 1.  Visit registra on page 2.

     Sign up with username, password 3.  Generate a secret for the user 4.  Share the secret somehow 5.  User is logged in
  32. User Log In Flow 1.  Visit login page 2.  Enter

    username and password 3.  System verifies details 4.  User opens auth app 5.  User finds app verifica on code and enters on site 6.  System verifies code 7.  User is logged in
  33. S E C R E T S

  34. H O T P / T O T P

  35. HOTP H O T P ( K , C )

    = T r u n c a t e ( H M A C ( K , C ) ) & 0 x 7 F F F F F F F H O T P - V a l u e = H O T P ( K , C ) m o d 1 0 d
  36. h o t p = f u n c t

    i o n ( k e y , c o u n t e r ) { / / C r e a t e t h e b y t e a r r a y v a r b = n e w B u f f e r ( i n t T o B y t e s ( c o u n t e r ) ) ; v a r h m a c = c r y p t o . c r e a t e H m a c ( ' s h a 1 ' , n e w B u f f e r ( k e y ) ) ; / / U p d a t e t h e H M A C w i t h t h e b y t e a r r a y v a r d i g e s t = h m a c . u p d a t e ( b ) . d i g e s t ( ' h e x ' ) ;
  37. / / G e t b y t e a

    r r a y v a r h = h e x T o B y t e s ( d i g e s t ) ; / / T r u n c a t e v a r o f f s e t = h [ 1 9 ] & 0 x f ; v a r v = ( h [ o f f s e t ] & 0 x 7 f ) < < 2 4 | ( h [ o f f s e t + 1 ] & 0 x f f ) < < 1 6 | ( h [ o f f s e t + 2 ] & 0 x f f ) < < 8 | ( h [ o f f s e t + 3 ] & 0 x f f ) ;
  38. v = ( v % 1 0 0 0 0

    0 0 ) + ' ' ; r e t u r n A r r a y ( 7 - v . l e n g t h ) . j o i n ( ' 0 ' ) + v ; } ; h ps:/ /github.com/guyht/notp
  39. T O T P

  40. D E M O

  41. S H A R I N G S E C

    R E T S
  42. QR code otpauth:/ /TYPE/LABEL?PARAMETERS otpauth:/ /totp/Example:philnash@twilio.com?secret=JBSWY3DPEHPK3PXP&issuer=Example

  43. None
  44. P R O S / C O N S

  45. C A N I T B E B E T

    T E R ?
  46. F R I E N D S D O N

    ' T L E T F R I E N D S W R I T E T H E I R O W N A U T H E N T I C A T I O N F R A M E W O R K S
  47. F R I E N D S D O N

    ' T L E T F R I E N D S W R I T E T H E I R O W N T W O F A C T O R A U T H E N T I C A T I O N F R A M E W O R K S
  48. None
  49. User Registra on Flow 1.  Visit registra on page 2.

     Sign up with username, password and phone nunber 3.  System registers User with Authy 4.  User is logged in
  50. User Log In Flow 1.  Visit login page 2.  Enter

    username and password 3.  System verifies details 4.  Authy prompts user 5.  User finds app verifica on code and enters on site 6.  System verifies code with Authy 7.  User is logged in
  51. D E M O

  52. T H E F U T U R E

  53. None
  54. P R O S / C O N S

  55. S U M M A R Y

  56. U S E R S A R E B A

    D W I T H P A S S W O R D S
  57. O T H E R W E B S I

    T E S A R E B A D W I T H P A S S W O R D S
  58. 2 F A C A N B E P U

    S H , T O K E N O R S M S
  59. 2 F A I S F O R Y O

    U R U S E R S
  60. None
  61. T H A N K S !

  62. None
  63. Help me! On a scale of 0 to 10, how

    likely is it that you would recommend this talk to a friend or colleague? 0203 322 5761
  64. Thanks! @philnash h p:/ /philna.sh philnash@twilio.com On a scale of

    0 to 10, how likely is it that you would recommend this talk to a friend or colleague? 0203 322 5761