Slide 1

Slide 1 text

JULIA POTAPENKO SECURE AUTHENTICATION ARE YOU SURE YOU DO IT RIGHT?

Slide 2

Slide 2 text

JULIA POTAPENKO Security Software Engineer at Cossack Labs with background in iOS app development Mobile/Security Lead at WWCodeKyiv Chapter Leader of OWASP Zhytomyr @julepka

Slide 3

Slide 3 text

WE WILL TALK ABOUT ★ Security as a part of development process ★ Standards for secure authentication ★ Common auth mistakes in iOS apps

Slide 4

Slide 4 text

SDLC SOFTWARE DEVELOPMENT LIFE CYCLE Requirements definition Design Development Testing Deployment Maintenance You are here

Slide 5

Slide 5 text

SDLC SOFTWARE DEVELOPMENT LIFE CYCLE Requirements definition Design Development Testing Deployment Maintenance You are here MVP IN ONE MONTH WE HAVE NO TIME DOCS WILL WAIT WE ARE AGILE

Slide 6

Slide 6 text

SDLC SOFTWARE DEVELOPMENT LIFE CYCLE Requirements definition Design Development Testing Deployment Maintenance You are here S- SECURE Security training + security requirement + risk assessment + threat modeling + secure design review + secure coding + secure code review + security testing + pentest + responding to incidents

Slide 7

Slide 7 text

EXAMPLE. USER REGISTRATION 1. Enter phone number/email

Slide 8

Slide 8 text

EXAMPLE. USER REGISTRATION 1. Enter phone number/email 2. Enter OTP

Slide 9

Slide 9 text

EXAMPLE. USER REGISTRATION 1. Enter phone number/email 2. Enter OTP 3. Accept TC & PP

Slide 10

Slide 10 text

EXAMPLE. USER REGISTRATION 1. Enter phone number/email 2. Enter OTP 3. Accept TC & PP INVEST IN SECURITY AWARENESS

Slide 11

Slide 11 text

RISKS • Legal Responsibility • Reputation Risks • Competitors IT IS NOT ONLY ABOUT HACKERS http://www.enforcementtracker.com/

Slide 12

Slide 12 text

“THE PROBLEM IS NOT ON OUR SIDE”

Slide 13

Slide 13 text

STANDARDS Apple Platform Security Guide OWASP MASVS & MSTG OWASP SAMM MITRE CVE List NIST Standards OWASP Mobile Top 10

Slide 14

Slide 14 text

OWASP MASVS MASVS (Mobile Application Security Verification Standard) • ARCHITECTURE, DESIGN AND THREAT MODELING • DATA STORAGE AND PRIVACY • CRYPTOGRAPHY • AUTHENTICATION AND SESSION MANAGEMENT • NETWORK COMMUNICATION • ENVIRONMENTAL INTERACTION • CODE QUALITY AND BUILD SETTINGS • RESILIENCY AGAINST REVERSE ENGINEERING https://github.com/OWASP/owasp-masvs

Slide 15

Slide 15 text

MASVS V4 Authentication and Session Management

Slide 16

Slide 16 text

SECURE AUTHENTICATION – LEVEL 1 – BASICS • User authentication before accessing remote resources • Authentication is enforced by the remote endpoint • Secure session ID and access token • Access token should expire • Logout • Password policy • Throttling

Slide 17

Slide 17 text

JWT TOKEN EXAMPLE https://jwt.io/

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

LEVEL 2 DEFENCE-IN-DEPTH

Slide 20

Slide 20 text

OWASP MASVS 4.8 BIOMETRIC AUTHENTICATION, IF ANY, IS NOT EVENT-BOUND (I.E. USING AN API THAT SIMPLY RETURNS "TRUE" OR "FALSE"). INSTEAD, IT IS BASED ON UNLOCKING THE KEYCHAIN. LEVEL 2 BIOMETRICS UNLOCKING KEYCHAIN

Slide 21

Slide 21 text

let reason = "Log in to your account" context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in if success { // Move to the main thread because a state update triggers UI changes. DispatchQueue.main.async { [unowned self] in self.state = .loggedin } } else { print(error?.localizedDescription ?? "Failed to authenticate") // Fall back to a asking for username and password. // ... } } https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id

Slide 22

Slide 22 text

let reason = "Log in to your account" context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason ) { success, error in if success { // Move to the main thread because a state update triggers UI changes. DispatchQueue.main.async { [unowned self] in self.state = .loggedin } } else { print(error?.localizedDescription ?? "Failed to authenticate") // Fall back to a asking for username and password. // ... } } https://developer.apple.com/documentation/localauthentication/logging_a_user_into_your_app_with_face_id_or_touch_id WARNING

Slide 23

Slide 23 text

WHAT THE CODE LOOKS LIKE IN DISASSEMBLER?

Slide 24

Slide 24 text

let access = SecAccessControlCreateWithFlags(nil, // Use the default allocator. kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, .userPresence, nil) // Ignore any error.

Slide 25

Slide 25 text

let access = SecAccessControlCreateWithFlags(nil, // Use the default allocator. kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, .userPresence, nil) // Ignore any error. .biometryCurrentSet

Slide 26

Slide 26 text

OWASP MASVS 4.9 A SECOND FACTOR OF AUTHENTICATION EXISTS AT THE REMOTE ENDPOINT AND THE 2FA REQUIREMENT IS CONSISTENTLY ENFORCED. LEVEL 2 2FA

Slide 27

Slide 27 text

2FA - TWO FACTOR AUTHENTICATION • Something you know (password, PIN, OTP) • Something you have (phone, SIM card, USB token) • Something you are, something physically unique for you (fingerprint) 2SV - TWO STEP VERIFICATION AUTH FACTORS

Slide 28

Slide 28 text

2SV FLOW

Slide 29

Slide 29 text

2SV FLOW

Slide 30

Slide 30 text

2FA - TWO FACTOR AUTHENTICATION • Something you know (password, PIN, OTP) • Something you have (phone, SIM card, USB token) • Something you are, something physically unique for you (fingerprint) 2SV - TWO STEP VERIFICATION AUTH FACTORS

Slide 31

Slide 31 text

https://www.mayurpahwa.com/2019/01/digital-signature.html

Slide 32

Slide 32 text

2FA - TWO FACTOR AUTHENTICATION • Something you know (password, PIN, OTP) • Something you have (phone, SIM card, USB token) • Something you are, something physically unique for you (fingerprint) 2SV - TWO STEP VERIFICATION AUTH FACTORS

Slide 33

Slide 33 text

OWASP MASVS 4.10 SENSITIVE TRANSACTIONS REQUIRE STEP-UP AUTHENTICATION. LEVEL 2 STEP-UP AUTH

Slide 34

Slide 34 text

OWASP MASVS 4.11 THE APP INFORMS THE USER OF ALL LOGIN ACTIVITIES WITH THEIR ACCOUNT. USERS ARE ABLE VIEW A LIST OF DEVICES USED TO ACCESS THE ACCOUNT, AND TO BLOCK SPECIFIC DEVICES. LEVEL 2 TRACK LOGIN ACTIVITY

Slide 35

Slide 35 text

FINAL THOUGHTS

Slide 36

Slide 36 text

WHERE TO GO NEXT OWASP MSTG – Testing Local Authentication https://github.com/OWASP/owasp-mstg/blob/master/Document/0x06f-Testing-Local-Authentication.md Apple Platform Security Guide https://support.apple.com/en-gb/guide/security/welcome/web WWDC 14 – Keychain and Authentication with Touch ID https://devstreaming-cdn.apple.com/videos/wwdc/ 2014/711xx6j5wzufu78/711/711_keychain_and_authentication_with_touch_id.pdf David Lindner – Don’t Touch Me That Way https://nvisium.com/blog/2016/06/22/dont-touch-me-that-way.html

Slide 37

Slide 37 text

THANK YOU! @julepka