iOS security essentials

18
iOS Security Essentials Krutin Karia Developer/Ethical Hacker

description

iOS Developers need a kickstart on best practices for secure coding. Not many tools available for static analysis.. this might be a good start. I presented this as part of iOS developer meetup at Bangalore in Sep 2014

Transcript of iOS security essentials

Page 1: iOS security essentials

iOS Security Essentials Krutin Karia

Developer/Ethical Hacker

Page 2: iOS security essentials

Mobile Threats

Page 3: iOS security essentials
Page 4: iOS security essentials

iOS hacked?

Page 5: iOS security essentials

iOS Sandboxing

Page 6: iOS security essentials

iOS Top Risks

!   Local Data Storage

!   Data Leakage

!   Authorization & Authentication

!   Crypto (Broken)

!   Injections (SQL, XSS)

!   Transport Layer Protection

Page 7: iOS security essentials

Insecure Data Storage

!   /tmp, /var/tmp, /Library/Caches

! NSUserDefaults, Plist

! CoreData, Plain text files, xml, json

!   SQLite

USE Keychain for sensitive data & use standard Crypto

Page 8: iOS security essentials

Data Leakage

! Backgrounding !   /Users/Applications/{UDID}/Library/Caches/Sanpshots/

!   URL Schemes

!   Application Cache

!   Browser Cache

!   Application Logs

!   App Strings

try this:: otool –arch armv7 –v –s __TEXT myapp

Page 9: iOS security essentials

Data Leakage

!   use applicationDidEnterBackground to obscure snapshots

!   Careful with use of URLSchemes, NSFile, writeToFile, NSLog

!   Do not store sensitive information in code, do not hardcode access tokens (Like AWS secret keys, API auth tokens)

Page 10: iOS security essentials

Authorization & Authentication

!   Check api manual for best use cases

!   Avoid local authentication

!   Do not cache credentials

!   If you gotta wanna must do it, Crypto

!   No Authorization using openUrl, handleOpenURL

Page 11: iOS security essentials

Crypto

!   Never ever write your own Crypto

!   Base64, MD5, and even SHA1 belong to dinosaur family

!   Use Apple provided Standard Libraries

Page 12: iOS security essentials

Injections (SQL, XSS)

!   sanitize, scrutinize, encode, validate inputs

!   Not just on App, on the server side as well

!   Use prepared SQL statements

Page 13: iOS security essentials

Transport Layer protection

! setAllowsAnyHTTPSCertificate

!   NSURL, writeToUrl, NSURLConnection, CFStream, NSStreamin

!   Do not redirect to http using didFailWithError

Fail safe on SSL error – Implement the connection: didFailWithError: delegate

Page 14: iOS security essentials

Xcode and Static Analysis

Page 15: iOS security essentials

Xcode and Static Analysis

Page 16: iOS security essentials

Custom Static Analysis

!   Clang Static Analyzer

! https://github.com/facebook/facebook-clang-plugins

! http://clang-analyzer.llvm.org/xcode.html

!   I am writing a few plugins will share on github soon

Page 17: iOS security essentials

Bible

! https://developer.apple.com/library/ios/documentation/Security/Conceptual/SecureCodingGuide/SecurityDevelopmentChecklists/SecurityDevelopmentChecklists.html

Page 18: iOS security essentials

Questions?

Krutin Karia

Intuit

[email protected]

References::

iOS hackers handbook, OWASP Mobile Top 10, Apple Docs