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

Making Authentication More Secure

Julia Mezher
September 29, 2019

Making Authentication More Secure

Julia Mezher

September 29, 2019
Tweet

More Decks by Julia Mezher

Other Decks in Programming

Transcript

  1. JULIA POTAPENKO • Lead iOS Engineer at Stuzo • Security

    Engineer • Mobile Lead at WWCode Kyiv • Co-organizer of OWASP Zhytomyr • Speaker at OWASP, CocoaHeads, WWCode and WTM events
  2. WE WILL TALK ABOUT ★ What can go wrong before

    you start coding ★ Top common mistakes of iOS engineers ★ Frictionless local authentication
  3. SDLC SOFTWARE DEVELOPMENT LIFE CYCLE Requirements definition Design Development Testing

    Deployment Maintenance You are here S- SECURE Security training
  4. SDLC SOFTWARE DEVELOPMENT LIFE CYCLE Requirements definition Design Development Testing

    Deployment Maintenance You are here S- SECURE Security training + security requirement + risk assessment
  5. 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
  6. RISKS • Legal Responsibility • Reputation Risks • Operations Risks

    • Competitors IT IS NOT ONLY ABOUT MONEY AND HACKERS
  7. RISKS • Legal Responsibility • Reputation Risks • Operations Risks

    • Competitors IT IS NOT ONLY ABOUT MONEY AND HACKERS http://www.enforcementtracker.com/
  8. 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
  9. 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
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. 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.
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. DIGITAL SIGNATURE / TRANSACTION SIGNING • Key exchange • Client

    creates private, public key pair • Private key is stored in Secure Enclave • Public key is sent to the Server • When transaction is initialized on the client side • Client computes hash from transaction data • Client encrypts hash with its private key to compute signature • Client attaches signature to the transaction data and sends to the Server • Server side validation • Server receives signed transaction data from the Client • Server separates transaction data from the signature • Server decrypts signature with public key received from the Client to get hash value • Server computes transaction data hash and compares it to the decrypted hash
  23. 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.
  24. 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. Architecture matters
  25. 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 tampering M9 Reverse engineering M10 Extraneous functionality
  26. OWASP MOBILE TOP 10 ~ Biometrics 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 tampering M9 Reverse engineering M10 Extraneous functionality
  27. LOCAL AUTHENTICATION • Biometry is stored on device as mathematical

    representation • It is encrypted with a private key stored in Secure Enclave • Biometry data is used by Secure Enclave only • It can’t be accessed by OS or any application
  28. SECURE ENCLAVE CREATE AN EXTRA LAYER OF SECURITY FOR YOUR

    PRIVATE KEYS. • A part of A7 and newer chips • Secure Enclave Processor (SEP) is separate from Application Processor (AP) • SEP has its own OS
  29. KEYCHAIN • A database storing encrypted items • Good for

    storing passwords, tokens, not for files • Each item is protected by passcode/biometry and device secret • Keychain items are available when user authenticates to the device • To work with Keychain specify a particular policy and user message
  30. KEYCHAIN • A database storing encrypted items • Good for

    storing passwords, tokens, not for files • Each item is protected by passcode/biometry and device secret • Keychain items are available when user authenticates to the device • To work with Keychain specify a particular policy and user message WARNING
  31. LETS DESIGN A FRICTIONLESS AUTHENTICATION EXAMPLE As a user, when

    I’m about to pay for the product in the mobile app, I should be prompt to a step-up authentication and my transaction should be secured. REQUIREMENT
  32. LETS DESIGN A FRICTIONLESS AUTHENTICATION EXAMPLE • Step-up authentication. Validate

    user password before sending transaction data • User can enter password or use biometrics instead ▸ To use biometrics we need to store user password in a Keychain ▸ We store user password encrypted with a private key stored in Secure Enclave • Send password to the Backend to validate. If it is correct the Backend will send one-time transaction session token • Secure the transaction. Use session and digital signature • Use one-time session token in transaction request • Add digital signature to transaction data ▸ Use private key stored in Secure Enclave to generate a public key for the Backend and to sign the transactions DESIGN
  33. WHERE TO GO NEXT OWASP MSTG – Testing Local Authentication

    https://github.com/OWASP/owasp-mstg/blob/master/Document/0x06f-Testing-Local- Authentication.md iOS Security Guide https://www.apple.com/business/site/docs/iOS_Security_Guide.pdf 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