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

In the Brain of Scott Alexander-Bown

In the Brain of Scott Alexander-Bown

Presentation as part of the Skills Matter: In the brain of sessions - more info and video here https://skillsmatter.com/meetups/6193-android-app-hardening
Feedback here: http://bit.ly/inthebrainscott

All works are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Scott Alexander-Bown

March 19, 2014
Tweet

More Decks by Scott Alexander-Bown

Other Decks in Technology

Transcript

  1. Me: Scott Alexander-Bown •  Senior Developer at •  Consultancy &

    training for Independently Mobile limited •  Co-author Android Security Cookbook •  Co-founder SWmobile meetup group ◦  meetup.com/swmobile
  2. Hardening your Android App •  Reverse engineering 101 •  Storing

    data (encryption) •  Network •  Apk ◦  Tamper detection ◦  Obfuscation
  3. It’s on YOU!!! •  Android is No.1 •  Your role

    = Protect data •  It’s your reputation
  4. •  Why? ◦  Easy / fun ◦  Lots of tools

    ◦  Replace Ads ◦  Trojanise app ◦  Software Piracy •  Tools ◦  Apktool - http://bit.ly/apktool ◦  Dex2jar- http://bit.ly/dex2jar ◦  Apk to Java - http://bit.ly/apk2java Reverse engineering 101
  5. Apktool: Let’s hack my app •  Measure your social influence

    with +1’s +Likes +retweet+mentions +recommendations +magic =Klout score
  6. Santoku Linux •  Pre-installed: ◦  platform SDKs ◦  decompilation tools

    ◦  hacking tools •  Get it here: santoku-linux.com
  7. Spongy Castle •  Bundle your own crypto libraries •  SpongyCastle

    adds support: o  AES-GCM o  Elliptic Curve Cryptography (ECC)
  8. Encryption: quick wins •  SQLCipher o  256-bit AES Encrypt SQLite

    database •  Secure-Preferences o  ‘obscure’ your app’s shared preferences •  IOCipher o  Virtual encrypted disk •  Conceal o  Easy to use APIs for fast encryption and authentication of data
  9. Not storing the key •  Password Based Encryption (PBE) o 

    Generate a key from user pin/password o  KDF - more iterations the better o  Add app time out to clear from memory •  The KeyStore provider (Android 4.3+) o  Secured via device pin/pass code o  Hardware backed (on some devices)
  10. Hardening SSL •  Use secure SSL/TLS protocols •  i.e. SSL

    v3, TLS v1.1/1.2 •  Use secure ciphers (128 bit or higher) •  Validate the certificates •  NetCipher o  Whole chain validation o  Orbot: Proxy with Tor
  11. Self signed SSL •  Download certificate (openssl) •  Embed in

    app (/res/raw) •  Load into Keystore •  Custom TrustManager (Keystore based) •  Init the SSL context with our TrustManager •  Make SSL connection •  https://developer.android.com/training/ articles/security-ssl.html
  12. SSL Pinning •  2 types ◦  Certificate pinning ◦  public

    key pinning •  How to pin ◦  Get pin and hash it ◦  Embed in app ◦  Make SSL connection ◦  Get cert chain ◦  Verify pins match
  13. Tamper Protection •  Installer app •  Emulator check ◦  System

    properties •  Debuggable check ◦  Package manager •  Root check ◦  Root apps/utils ◦  System properties ◦  RW system
  14. Signing certificate check •  Get SHA1 of signing cert keytool

    -list -v -keystore debug.ketstore •  Embed in app •  Get at signature at runtime from the Package Manager •  Compare
  15. •  Code Obfuscator •  Older than Android! •  Part of

    the SDK •  it’s FREE!) •  How to enable? ProGuard
  16. ProGuard tips •  -keep class com.myapp.notworking.** { *; } • 

    Only applied on release builds ◦  Test early! •  Save your mapping.txt •  Some crashlytics services support ReTrace ◦  Crashlytics ◦  Critterism ◦  Bugsense (paid) ◦  HockeyApp (paid)
  17. DexGuard •  Proguard’s bad ass brother •  www.saikoa.com/dexguard •  Not

    free but 1 licence == ∞ apps •  Personal Highlights ◦  One line tamper check ◦  ᅥ$ᳰ.smali, Œ$ᳰ.smali ◦  API hiding with String encryption == tough
  18. Infrastructure and deployment •  Access to the code •  Google

    Play dev account ◦  Enable 2 factor auth ◦  Grant developer access •  Keystore/signing key ◦  min use -keysize 2048
  19. More info… •  42+ Secure mobile development best practices o 

    http://bit.ly/viafor42 •  OWASP Mobile security recommendations o  http://bit.ly/owaspmobile •  Android security cookbook o  http://bit.ly/MscEFu o  BOGOF ebooks at packtpub.com
  20. Reference Slide: Dev libs •  Spongycastle - https://github.com/rtyley/spongycastle •  SQLCipher

    - http://sqlcipher.net/sqlcipher-for-android •  Secure-Preferences - http://github.com/scottyab/secure-preferences •  IOCipher - http://guardianproject.info/code/iocipher •  Conceal - http://facebook.github.io/conceal •  NetCipher - https://github.com/guardianproject/NetCipher
  21. Reference Slide: Moro Info •  Android security cookbook ISBN:1782167161 o 

    http://bit.ly/MscEFu •  42+ Secure mobile development best practices http://bit.ly/viafor42 •  OWASP Mobile security recommendations o  http://bit.ly/owaspmobile •  Mobile app security certification ◦  http://bit.ly/androidcert