Top Banner
Building Secure Mobile Apps Sergey Gorbaty @ser_gor Martin Vigo @martin_vigo
46

Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Jul 09, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Building Secure Mobile Apps Sergey Gorbaty

@ser_gor Martin Vigo

@martin_vigo

Page 2: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Martin Vigo Product Security Engineer

Page 3: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Sergey Gorbaty Senior Product Security Engineer

Page 4: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Outline

¡ Attacks on Mobile Apps

¡ Developing Secure Mobile Apps

¡ What Frameworks Help You With

¡ Demos

Page 5: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Attacks on Mobile Apps

Page 6: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Mobile App Threats ¡ Native Mobile App Threats

¡ File system, DB Storage, Logs

¡ Network Communication

¡ Clipboard

¡ Backups

¡ RPC, URL scheme handlers

¡ Web App Threats ¡ Input validation

¡ Session management

¡ Web app logic flaws

¡ Web vulnerabilities

¡ XSS, CSRF

¡ Injections

¡  SQL, header

Page 7: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Outline

¡ Attacks on Mobile Apps

¡ Developing Secure Mobile Apps

¡ What Frameworks Help You With

¡ Demos

Page 8: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Developing Secure Mobile Apps

¡ iOS/OS X ‘Secure Coding Guide’ ¡ Comprehensive, 120 pages long ¡ Covers topics from buffer overflows to web vulnerabilities ¡ https://developer.apple.com/library/iOs/documentation/ Security/Conceptual/SecureCodingGuide/SecureCodingGuide.pdf

¡ Android.com ‘Security Tips’ ¡ 6 articles on

¡ Storing data ¡ Using permissions ¡ Using networking ¡ Using RPC ¡ Webview security

¡ http://developer.android.com/training/articles/security-tips.html

Page 9: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

File System

Page 10: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Excessive Logging

¡ Explicit logging ¡ Debugging

¡ Feedback

¡ Analytics

¡ Automatic logging ¡ Generic information

¡ Exceptions

Page 11: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Excessive Logging - TODO

¡ Do not log credentials including username, password, and OAuth tokens

¡ Do not log emails, names, titles, company information

¡ Do not log hardware ids including IMEI, UDID

¡  Prefer to log internal opaque IDs if possible

¡ Disable logging before shipping

Page 12: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Hardcoded Secrets

¡ Encryption keys

¡ PINs

¡ Settings

¡ Credentials

Page 13: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Hardcoded Secrets - TODO

¡ Don’t hardcode ANY secrets

¡ Query secrets only when necessary ¡ Don’t keep them in memory longer than needed.

¡ Do not assign secrets to global variables

¡ Disable autocorrect on sensitive fields

Page 14: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Insecure storage

¡ Explicit storage ¡ Data

¡ Preferences

¡ Logs

¡ Crash Reports

¡ Automatic storage ¡ Temp Files

¡ Cache

Page 15: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Insecure storage - TODO

¡ Use secure storage for secrets ¡ Keychain

¡ AccountManager

¡ Verify that no sensitive data is stored without your knowledge

¡ Control App flow and encrypt data when device is in background or locked

Page 16: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Automatic Caching

¡ Databases

¡ Preference files

¡ Plists

¡ Logs

¡ Requests and responses

Page 17: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Automatic Caching - TODO

¡ Double check what is being cached ¡ File system explorers

¡ Database managers

¡  Prevent network requests caching ¡  ‘Cache-control: no-cache, no-store’

¡  Disable web view disk caching

¡  Use in-memory caching only

¡ Destroy Cache data on logout

Page 18: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Encryption

¡ Do we need encryption?

¡ Types of Crypto

¡ Personal implementation

¡ Performance

Page 19: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Encryption - TODO

¡  Encrypt customer data stored on the device and removable media ¡  Use AES 128 bit or stronger ¡  Never use ECB mode

¡ Use Key Derivation for encryption key ¡ PBKDF2 (10000 rounds, SHA 256 or higher) ¡  bcrypt ¡  scrypt

¡ Passcode Protection ¡ Store it hashed ¡  Use SHA-256 + secure random generated salt ¡  Store salted hashes of passcode in secure storage

¡  Use PIN for additional entropy

Page 20: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Network Communication

Page 21: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Protocols

¡ Use of encryption layer?

¡ All endpoints covered/secure?

¡ Cyphers supported

¡ Default cyphers

¡ Caching

Page 22: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Protocols- TODO

¡ Do not implement SSL/TLS trust validation bypasses

¡  Use SSL3/TLS1.x

¡  Disable caching containing sensitive data

Page 23: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Certificates

¡ Self-signed

¡ Invalid

¡ Certificate validations

¡ Bypass

Page 24: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Certificates - TODO

¡ Don’t allow self-signed certificates

¡ Validate all certificates

¡ Never bypass Certificate Authority root of trust

Page 25: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Session management

¡ Logout

¡ Expiration

¡ Data destruction

Page 26: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Session management - TODO

¡  Implement inactivity timeouts to prompt user to re-login after prolonged inactivity

¡ Implement business logic for logout ¡ Delete all associated data

¡ Expire the session on client AND server side

¡ Protect your Cookies

Page 27: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Clipboard

Page 28: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Clipboard

¡ What data can make it to the clipboard?

¡ Who can access the it?

¡ Is there any security layer?

Page 29: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Clipboard - TODO

¡ Clipboard is not a secure method of information exchange

¡ Clipboard can be accessed by any application ¡  At any point in time

¡  Without user prompt

¡ Limit the data available to Clipboard ¡ Don’t allow sensitive data

Page 30: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Backups

Page 31: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Backups

¡ What data is backed up

¡ Encryption

¡ Access limitations

Page 32: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Backups - TODO

¡ Filter what data can be backed up ¡ NSURLIsExcludedFromBackupKey

¡ android:allowBackup

¡ Backups are not a secure storage

¡ Create backups and explore them for sensitive data

Page 33: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Screenshots

Page 34: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Screenshots

¡ What can be captured

¡ Automatic screenshots

¡ Any way to set limitations?

Page 35: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Screenshots- TODO

¡  Prevent users from taking screenshots of sensitive data ¡  getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE);

¡  Prevent automatic caching in iOS ¡  willEnterBackground API

¡  Use splash screen

Page 36: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Outline

¡ Attacks on Mobile Apps

¡ Developing Secure Mobile Apps

¡ What Frameworks Help You With

¡ Demos

Page 37: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Mobile Frameworks The breakdown

¡ All focus on rapid development using HTML

¡ Most provide easy ways of creating secure TLS connections

¡ Fair amount provide authentication support

¡ Few provide secure credential storage

¡ Very few provide secure data storage

Page 38: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Hybrid Apps

¡ Can access device internals through plugins ¡  Camera, photos

¡  Accelerometer, GPS, Compass, Gyroscope

¡  Keychain

¡  SD card

¡  Etc.

Page 39: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Frameworks Security

Page 40: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

WebView

¡ Additional Threats

¡ JavaScript support

¡ Framework specific security requirements

Page 41: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

WebView - TODO

¡  Third party scripts shouldn’t be trusted

¡  Iframe sandboxing ¡  Don’t include script in the context of application

¡ Whitelist specific domains and paths ¡  Avoid wildcard (*) whitelist

¡ Minimize the number of exposed plugins

Page 42: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Outline

¡ Attacks on Mobile Apps

¡ Developing Secure Mobile Apps

¡ What Frameworks Help You With

¡ Demos

Page 43: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Demo Looking at files inside Apple Sandbox - iExplorer

Page 44: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Demo XSS with BEEF on Hybrid mobile app

Page 45: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

Protecting Mobile Apps What to focus on

¡  Follow best development practices ¡  Brush up on OWASP top 10 mobile threats

¡  Review official vendor recommendations

¡  Follow recommendations for storing secrets and data

¡  Exercise minimal logging

¡  Using TLS

¡  Use security frameworks, don’t roll your own crypto

¡  Use free security assessment tools ¡  HTTP traffic examination: Burp Suite, Fiddler, Charles Proxy

¡  App sandbox examination: iExplorer, drozer, Android debugging bridge

¡  Source code review: Findbugs, Brakeman, Scanjs

Page 46: Building Secure Mobile Apps - Martin VigoProtecting Mobile Apps What to focus on ! Follow best development practices ! Brush up on OWASP top 10 mobile threats ! Review official vendor

THANK YOU!

Sergey Gorbaty @ser_gor

Martin Vigo @martin_vigo