Slide 1

Slide 1 text

OWASP MSTG WHEN AUTHENTICATION GOES WRONG JULIA POTAPENKO COCOAHEADS 10 MAY 2019

Slide 2

Slide 2 text

JULIA POTAPENKO ⭐ iOS Software Engineer ⭐ Mobile Lead at Women Who Code Kyiv ⭐ Org Team Member of OWASP Zhytomyr

Slide 3

Slide 3 text

TODAY WE WILL TALK ABOUT AUTHENTICATION WHAT SHOULD BE DONE OWASP MASVS WHAT CAN BE BROKEN OWASP MSTG

Slide 4

Slide 4 text

WHAT IS OWASP? An online community that produces freely-available articles, methodologies, documentation, tools, and technologies in the field of web application security.

Slide 5

Slide 5 text

WHAT IS OWASP? OWASP (Open Web Application Security Project) An online community that produces freely-available articles, methodologies, documentation, tools, and technologies in the field of web application security. wikipedia.org

Slide 6

Slide 6 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. USER REGISTRATION Enter phone number

Slide 7

Slide 7 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. USER REGISTRATION Enter phone number Enter OTP

Slide 8

Slide 8 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. USER REGISTRATION Enter phone number Enter OTP Accept TC & PP

Slide 9

Slide 9 text

WHAT IS OWASP MASVS? MASVS (Mobile Application Security Verification Standard) WHAT IS OWASP MSTG? MSTG (Mobile Security Testing Guide) https://github.com/OWASP/owasp-masvs https://github.com/OWASP/owasp-mstg

Slide 10

Slide 10 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

Slide 11

Slide 11 text

OWASP MSTG MSTG (Mobile Security Testing Guide) A COMPREHENSIVE MANUAL FOR MOBILE APP SECURITY TESTING AND REVERSE ENGINEERING. IT DESCRIBES TECHNICAL PROCESSES FOR VERIFYING THE CONTROLS LISTED IN THE OWASP MOBILE APPLICATION VERIFICATION STANDARD (MASVS).

Slide 12

Slide 12 text

MASVS LEVELS

Slide 13

Slide 13 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint.

Slide 14

Slide 14 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint. 4.2 If stateful session management is used, the remote endpoint uses randomly generated session identifiers to authenticate client requests without sending the user's credentials. 4.3 If stateless token-based authentication is used, the server provides a token that has been signed using a secure algorithm.

Slide 15

Slide 15 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint. 4.2 If stateful session management is used, the remote endpoint uses randomly generated session identifiers to authenticate client requests without sending the user's credentials. 4.3 If stateless token-based authentication is used, the server provides a token that has been signed using a secure algorithm. 4.4 The remote endpoint terminates the existing session when the user logs out.

Slide 16

Slide 16 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint. 4.2 If stateful session management is used, the remote endpoint uses randomly generated session identifiers to authenticate client requests without sending the user's credentials. 4.3 If stateless token-based authentication is used, the server provides a token that has been signed using a secure algorithm. 4.4 The remote endpoint terminates the existing session when the user logs out. 4.5 A password policy exists and is enforced at the remote endpoint.

Slide 17

Slide 17 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint. 4.2 If stateful session management is used, the remote endpoint uses randomly generated session identifiers to authenticate client requests without sending the user's credentials. 4.3 If stateless token-based authentication is used, the server provides a token that has been signed using a secure algorithm. 4.4 The remote endpoint terminates the existing session when the user logs out. 4.5 A password policy exists and is enforced at the remote endpoint. 4.6 The remote endpoint implements a mechanism to protect against the submission of credentials an excessive number of times.

Slide 18

Slide 18 text

MASVS. AUTHENTICATION. LEVEL 1. Description 4.1 If the app provides users access to a remote service, some form of authentication, such as username/password authentication, is performed at the remote endpoint. 4.2 If stateful session management is used, the remote endpoint uses randomly generated session identifiers to authenticate client requests without sending the user's credentials. 4.3 If stateless token-based authentication is used, the server provides a token that has been signed using a secure algorithm. 4.4 The remote endpoint terminates the existing session when the user logs out. 4.5 A password policy exists and is enforced at the remote endpoint. 4.6 The remote endpoint implements a mechanism to protect against the submission of credentials an excessive number of times. 4.7 Sessions are invalidated at the remote endpoint after a predefined period of inactivity and access tokens expire.

Slide 19

Slide 19 text

MASVS. AUTHENTICATION. LEVEL 2. Description 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.

Slide 20

Slide 20 text

MASVS. AUTHENTICATION. LEVEL 2. Description 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. 4.9 A second factor of authentication exists at the remote endpoint and the 2FA requirement is consistently enforced.

Slide 21

Slide 21 text

MASVS. AUTHENTICATION. LEVEL 2. Description 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. 4.9 A second factor of authentication exists at the remote endpoint and the 2FA requirement is consistently enforced. 4.10 Sensitive transactions require step-up authentication.

Slide 22

Slide 22 text

MASVS. AUTHENTICATION. LEVEL 2. Description 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. 4.9 A second factor of authentication exists at the remote endpoint and the 2FA requirement is consistently enforced. 4.10 Sensitive transactions require step-up authentication. 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.

Slide 23

Slide 23 text

OWASP MSTG AUTHENTICATION • Basic: • Something the user knows: 
 password, PIN, pattern, etc. • Something the user has: 
 SIM-card, OTP (one time password) generator, hardware token, etc. • A biometric property: 
 fingerprint, retina, voice, etc. • 2FA (2-Factor Authentication): • OTP by SMS or phone call • Hardware or software token • Push notifications in combination with PKI (public key infrastructure) and local authentication • Supplementary Authentication: • Geolocation • IP address • Time of the day • Device ID

Slide 24

Slide 24 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter phone number

Slide 25

Slide 25 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter phone number Enter OTP

Slide 26

Slide 26 text

WHEN AUTHENTICATION GOES WRONG EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter phone number Enter OTP Use biometrics

Slide 27

Slide 27 text

OWASP MSTG OTP BY SMS CONCERNS • Wireless Interception • SIM SWAP Attack • Verification Code Forwarding Attack
 
 https://github.com/OWASP/owasp-mstg/blob/master/Document/0x04e-Testing-Authentication-and- Session-Management.md

Slide 28

Slide 28 text

WHEN AUTHENTICATION GOES RIGHT EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter username and password ✅

Slide 29

Slide 29 text

WHEN AUTHENTICATION GOES RIGHT EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter username and password Enter card expiration date ✅

Slide 30

Slide 30 text

WHEN AUTHENTICATION GOES RIGHT EXAMPLE. BANKING APP. FIRST TIME LOGIN Enter username and password Use biometrics Enter card expiration date ✅

Slide 31

Slide 31 text

OWASP MSTG TRANSACTION SIGNING

Slide 32

Slide 32 text

OWASP MSTG TRANSACTION SIGNING • Client generates public and private keys on user registration, registers public key with backend, saves private key to Keychain.

Slide 33

Slide 33 text

OWASP MSTG TRANSACTION SIGNING • Client generates public and private keys on user registration, registers public key with backend, saves private key to Keychain. • Backend sends transaction data to the client to be authorized.

Slide 34

Slide 34 text

OWASP MSTG TRANSACTION SIGNING • Client generates public and private keys on user registration, registers public key with backend, saves private key to Keychain. • Backend sends transaction data to the client to be authorized. • Client unlocks Keychain, gets private key, signs the transaction and sends it back to backend.

Slide 35

Slide 35 text

OWASP MSTG TRANSACTION SIGNING • Client generates public and private keys on user registration, registers public key with backend, saves private key to Keychain. • Backend sends transaction data to the client to be authorized. • Client unlocks Keychain, gets private key, signs the transaction and sends it back to backend. • Backend verifies it with public key.

Slide 36

Slide 36 text

OWASP MSTG THINGS TO CHECK • Check if with Backend • Login throttling • Session management • Access and refresh token • JWT • Login activity and blocking • Check it on Client • Secure token storage • Access and refresh tokens handling • Proper error handling

Slide 37

Slide 37 text

LOCAL AUTHENTICATION. TOUCH/FACE ID Local authentication should always be enforced at a remote endpoint or based on cryptographic primitive. Attackers can easily bypass local authentication if no data returns from the authentication process.

Slide 38

Slide 38 text

LOCAL AUTHENTICATION. TOUCH/FACE ID Local authentication should always be enforced at a remote endpoint or based on cryptographic primitive. Attackers can easily bypass local authentication if no data returns from the authentication process. https://youtu.be/XhXIHVGCFFM David Linder 
 Don’t Touch Me That Way • Don’t • Rely on bool output • Forget to configure Touch ID • Do • Use Touch ID to get data from Keychain • Combine it with user password TOUCH ID EXAMPLE

Slide 39

Slide 39 text

OWASP MOBILE TOP 10 M1. Improper platform usage M2. Insecure data storage M3. Insecure communication M4. Insecure authentication M5. Insufficient cryptography M6. Insecure authorization M7. Client code quality M8. Code tempering M9. Reverse engineering M10. Extraneous functionality https://www.owasp.org/index.php/Mobile_Top_10_2016-Top_10 ➡

Slide 40

Slide 40 text

OWASP MOBILE TOP 10 M1. Improper platform usage M2. Insecure data storage M3. Insecure communication M4. Insecure authentication M5. Insufficient cryptography M6. Insecure authorization M7. Client code quality M8. Code tempering M9. Reverse engineering M10. Extraneous functionality https://www.owasp.org/index.php/Mobile_Top_10_2016-Top_10 ➡

Slide 41

Slide 41 text

THANK YOU! ULTIMATELY, THE REVERSE ENGINEER ALWAYS WINS AND REMEMBER