Yow connected developing secure i os applications

Developing Secure 
iOS Applications 
YOW! Connected 2014 
Michael Gianarakis
About me 
! 
! 
! 
@mgianarakis 
Practice Manager at Securus Global 
Application security for most of the last decade 
Good guy that thinks like a bad guy
This presentation 
• Aims to give a good overview of how to design 
secure iOS applications 
• Focuses on the key security issues commonly 
found in iOS applications 
• Not a guide to hacking iOS applications
Topics 
• Overview of the iOS attack surface 
• Common iOS security issues 
• Secure iOS application design principles 
• Secure development approaches for key security 
iOS issues
iOS Application 
Attack Surface
Other 
Apps 
Your App 
3rd Party 
Services 
Network 
iOS 
Device 
Your 
Backend 
IPC, 
iOS 8 
Extensions 
WiFi, LTE
Other 
Apps 
Your App 
3rd Party 
Services 
Network 
iOS 
Device 
Your 
Backend 
Malicious apps 
Jailbroken or 
compromised 
device 
Man in the 
middle attacks 
Server 
compromise 
and 
web attacks
Understanding the risk 
profile of your app 
• Important first step that is often overlooked. 
• Drives the security design of your application 
• Key considerations: 
• What information is in the app and how sensitive/valuable is it? 
• Who are the likely threat actors? How capable are they? 
• What are the likely attack scenarios for each threat actor? 
• What is your tolerance for risk? 
• Regulatory requirements?
Common iOS 
Application Security 
Issues
Common Issues 
• Based on working with a range of companies and a variety of 
applications including: 
• Mobile banking and trading apps 
• Board paper apps 
• Internal business apps 
• Retail apps 
• Social networking apps 
• Games
Common Issues 
• Binary and Runtime Security Issues 
• Transport Layer Security Issues 
• Data Security Issues
Get these right and you are well 
and truly ahead of the pack
Secure iOS Design 
Principles
Don’t trust the client or 
the runtime environment
Users will connect to 
untrusted networks
Don’t store anything 
sensitive on the device
Binary and Runtime 
Security
Binary and Runtime 
Security 
• As a reflective language, Objective-C can observe 
and modify it’s own behaviour at runtime. 
• Can be great from a development perspective 
• Not so much from a security perspective
Binary and Runtime 
Security 
• The ability to create and call ad hoc classes and methods on the fly 
allows attackers to manipulate and abuse the runtime of the application: 
• Bypass security locks 
• Break logic checks 
• Escalate privilege 
• Steal information from memory. 
• Implementing runtime security checks significantly increases the 
security of your application 
• You should always assume that your application will run on a 
compromised device
Aside - Compromised 
Devices
Myths surrounding 
jailbreaking 
• Generally speaking, iOS is one of the most secure 
operating systems available 
• One of the defining security features of iOS is the 
chain of trust. Every bit of code is signed and 
approved by Apple. 
• Break that trust and all bets are off
Myths surrounding 
jailbreaking 
• Some of the security issues discussed in this 
presentation will require a compromised device 
• This is usually the cause of a lot of 
misunderstanding when it comes to assessing the 
impact of these issue
Myth 1 - Public jailbreaks 
are the only jailbreaks 
• I often hear “but there is no jailbreak for version 
x.x.x so we are safe” 
• FACT: Public jailbreaks for every version of iOS 
released so far 
• FACT: Not all users update to the latest firmware 
• FACT: iOS vulnerabilities are extremely valuable, 
there are many more exploits than just those that 
people give out for free on the internet
Myth 2 - Jailbreaks require 
physical access to the device 
• I often hear “well someone would need to steal the device to compromise 
it” 
• FACT: Not all exploits require physical access. 
• jailbreakme.com TIF image processing vulnerability and PDF 
processing vulnerability required only a user visit a web page in Safari 
• Remote code execution via SMS found by Charlie Miller (https:// 
www.blackhat.com/presentations/bh-usa-09/MILLER/BHUSA09- 
Miller-FuzzingPhone-PAPER.pdf) 
• Nitro JIT vulnerability to download and execute unsigned code via 
POC app that was approved also found by Charlie Miller (http:// 
reverse.put.as/wp-content/uploads/2011/06/ 
syscan11_breaking_ios_code_signing.pdf)
Myth 3 - Jailbreaks are 
always obvious to the user 
• It is a commonly held misconception that if Cydia 
is not on the device then it is not jailbroken. 
• Cydia is an app that is commonly installed with 
public jailbreaks but is certainly not a prerequisite 
or in any way required for a jailbreak. 
• In fact, any kind of targeted exploit is unlikely to 
install Cydia in the first place.
Myth 4 - Jailbreaking is 
Apple’s problem 
• FACT: The security of your app, your data and your 
users is your responsibility. 
• FACT: The security risk to your organisation is your 
responsibility. You will be the one that suffers the 
impact if your app is compromised and you should 
be actively managing that risk. 
• FACT: Apple won’t secure your app for you.
Myth 5 - You can completely 
protect against jailbreaking 
• FACT: Unfortunately you will never be able to 
completely secure an application. 
• The idea is to raise the bar for the security of your 
app so that it becomes too difficult or costly to 
attack.
</aside>
Debug Check 
• A simple and effective method of securing the 
runtime is to implement anti-debugging control. 
• There may be reasons to allow an application to 
run on a jailbroken device but there are no 
legitimate reasons for debugging a production 
application
Debug Check 
• Debugging protection can be implemented using the following 
techniques: 
• Periodically monitoring the process state flag to determine if 
application process is being debugged and then terminating 
the process. 
• Using the ptrace request PT_DENY_ATTACH two prevent 
future tracing of the process. This can be done with the 
following function call from within the application: 
• ptrace(31,0,0,0) 
• These techniques should be used in conjunction with each other to 
provide a more robust anti-debugging control.
Jailbreak Detection 
• There are multiple ways to implement jailbreak 
detection but the two most common methods are: 
• File system check 
• Sandbox integrity check 
!
Jailbreak Detection 
• File system checks test for the presence of files that are typically 
found on jailbroken devices. 
• Some examples of files to look for: 
• /Library/MobileSubstrate/MobileSubstrate.dylib 
• /var/cache/apt 
• /var/lib/apt 
• /bin/bash and /bin/sh 
• /usr/sbin/sshd and /etc/ssh/sshd_config
Jailbreak Detection 
• When implementing a file system check you 
should ensure you check for multiple files using 
different methods such as fileExistsAtPath 
and isReadableFileAtPath 
! 
!
Jailbreak Detection 
• A sandbox integrity check tests that the integrity of 
Apple’s sandbox is intact on the device, and that the 
application is running inside it. 
• A sandbox integrity check works by attempting to 
perform an operation that would not typically 
succeed on a device that has not been jailbroken. 
• A common test is to attempt to use the fork function 
to spawn a new child process which will succeed if 
the sandbox has been compromised or if the 
application is running outside of the sandbox
Jailbreak Detection 
• Check out the IMAS project’s Security Check 
module https://github.com/project-imas/ 
security-check 
! 
! 
!
Inline Functions 
• Any sensitive functions such as the security 
checks should be compiled as inline functions 
• Inlining functions complicates attacks that involve 
editing memory and patching the application by 
forcing an attacker to find and patch all 
occurrences of the code. 
• Specify a function as inline using the 
__attribute__((always_inline)) compiler 
directive.
Inline Functions 
• This directive may not always be honoured however. To 
minimise the chance that this will happen configure the 
following: 
• Set the -finline-limit compiler flag high enough to 
allow for inlining of your code (e.g. 5000) 
• Set the optimisation level at least -O1 
• Don’t use -unit-at-a-time (note this is automatically 
set at -O3 and above 
• Don’t use -keep-inline-functions if your functions 
are static
Address Space Validation 
• Any time malicious code is injected into your 
application it must be loaded into an address 
space 
• Validating the address space adds complexity to 
attacks as it forces an attacker to inject the 
malicious code into the existing address space 
with the valid code or attacking dynamic linker
Address Space Validation 
• The dladdr function in the dynamic linker library 
returns information about the address space a 
particular function belongs to. 
• Passing it the function pointer of a class’s method 
implementation can determine whether it came 
from your app, Apple’s frameworks, or an 
unknown/malicious source
Avoid Simple Logic 
• Simple logic checks for security functions and 
business logic are susceptible to to manipulation. 
• Examples include: 
• - (BOOL) isLoggedIn 
• BOOL isJailbroken = YES 
• - (void) setDebugFlag
Avoid Simple Logic
Securing Memory 
• Instance variables stored within Objective-C objects 
can be easily mapped inside the Objective-C runtime. 
• Never store anything in memory until the user has 
authenticated and data has been decrypted. 
• Manually allocate memory for sensitive data rather 
than storing the data (or pointers to this data) inside 
Objective-C instance variables. 
• Wipe sensitive data from memory when it’s not 
needed.
Securing Memory
Transport Layer 
Security
Transport Layer Security 
• Users will connect their devices to untrusted 
networks 
• If your app handles sensitive data you should be 
encrypting all traffic between the app and the 
back end.
Protocol Version 
• If using NSURLSession you can specify the 
minimum supported TLS protocol version by 
setting the TLSMinimumSupportedProtocol 
property in the NSURLSessionConfiguration 
! 
!
Cipher Suites 
• You should disable support for low and medium strength 
cipher suites on the server 
• Medium: 
! 
! 
• Low: 
!
Certificate Validation 
! 
• Always perform certificate validation checks 
• When using Apple frameworks iOS will accept a 
certificate if it’s signed by a CA in the trust store 
• Certificate validation checks will often be overridden 
in development to avoid issues with self-signed certs. 
• Typically this is encapsulated in a variable somewhere 
or in some other simple logic that can be subverted.
Certificate Validation
Certificate Validation 
! 
• To avoid having to do this, use valid certs in 
development (e.g. free certs) 
• If you do need to disable validation, ensure that the 
production builds essentially “hard code” validation. 
• Consider certificate pinning.
Certificate Pinning 
• Mobile apps are great candidates for certificate 
pinning as they only need to communicate with a 
small, clearly defined set of servers 
• Certificate pinning improves security by removing 
the need to trust the certificate authorities. 
• iSEC partners have a great library for 
implementing certificate pinning https:// 
github.com/iSECPartners/ssl-conservatory
Data Security
Two types of data security 
issues…. 
• Sensitive data stored on the device by the 
application that was not secured appropriately by 
the developer 
• Unintended data leakage via system functionality 
!
Insecure Data Storage 
• It’s common to find sensitive data stored 
insecurely on the device. 
• As a general rule sensitive information should not 
be stored on the device at all. 
• Really consider the need to store sensitive 
information on the device. Generally it is 
functionally and technically possible to not store 
the data at all.
Property List Files 
• Don’t store sensitive information using 
NSUserDefaults. Plist files are unencrypted and 
can easily be retrieved from the device and backups 
! 
! 
!
SQLite Databases 
• Avoid storing sensitive information in SQLite 
databases if at all possible. 
• If you need to store sensitive information encrypt 
the database using SQLCipher https://github.com/ 
sqlcipher/sqlcipher 
• If you are using Core Data the Encrypted Core Data 
module of the IMAS project leverages SQLCipher 
to encrypt all data that is persisted https:// 
github.com/project-imas/encrypted-core-data/
Data Protection APIs 
• If you need to write files with sensitive information to 
the device (not credentials) at a minimum write files 
with an appropriate data protection attribute 
• If you don’t need to access the file in the 
background use NSFileProtectionComplete 
(for NSFileManager) or 
NSDataWritingFileComplete (for NSData). 
• With this attribute set the file is encrypted on the file 
system and inaccessible when the device is locked.
Data Protection APIs 
• If you need to access the file in the background use 
NSFileProtectionCompleteUnlessOpen for 
(NSFileManager) or 
NSDataWritingFileProtectionCompleteUnlessOp 
en (for NSData) 
• With this attribute set the file is encrypted on the file 
system and inaccessible while closed. 
• When a device is unlocked an app can maintain an open 
handle to the file even after it is subsequently locked, 
however during this time the file will not be encrypted.
Unintended Data 
Leakage 
• Sensitive data captured and stored automatically 
by the operating system. 
• Oftentimes developers are unaware that the OS is 
storing this information.
Background Screenshot 
Cache 
• Every time an application suspends into the 
background, a snapshot is taken to facilitate the 
launch animation. 
• Stored unencrypted in the app container. 
• This allows attackers to view the last thing a user 
was looking at when the application was 
backgrounded.
Background Screenshot 
Cache
Background Screenshot 
Cache 
• Place content clearing code in the state transition 
methods applicationDidEnterBackground and 
applicationWillResignActive 
• The simplest way to clear the screen contents is to 
set the key window’s hidden property to YES. 
! 
!
Background Screenshot 
Cache 
• Be careful, if there are any other views behind the 
current view, these may become visible when the key 
window is hidden. 
• Other methods: 
• Manually clearing sensitive info from the current 
view 
• Placing the launch image in the foreground 
• Note: ingoreSnapshotOnNextApplicationLaunch 
will not prevent the screenshot from being taken
URL Caching 
• iOS automatically caches requests and responses 
for protocols that support caching (e.g. HTTP/ 
HTTPS) and stores them unencrypted in a SQLite 
database in the app container. 
• Make sure to configure the server to send the 
appropriate cache control headers: 
!
URL Caching 
• Can also control caching in the client. 
• For NSURLConnection implement the 
connection:willCacheResponse: delegate method 
! 
! 
• For NSURLSession set the URLCache property to 
NULL
Logging 
• Less of an issue since iOS 7 
• Pre-iOS 7 any app was able to view the device 
console and thus any sensitive data that was 
logged. 
• Still a good idea to make sure nothing sensitive is 
logged.
Logging 
• If you must log sensitive information in 
development for debugging purposes special 
care should be taken to ensure that this code is 
not pushed to production. 
• One way to do this is to redefine NSLog with a pre-processor 
macro such as #define NSLog(…)
Pasteboard 
• When the Cut or Copy buttons are tapped, a 
cached copy of the data stored on the device’s 
clipboard -/private/var/mobile/Library/ 
Caches/com.apple.UIKit.pboard/ 
pasteboard. 
• If the application handles sensitive data that may 
be copied to the pasteboard consider disabling 
Copy/Paste functionality for sensitive text fields 
(note this is done by default for password fields)
Pasteboard 
• To disable pasteboard operations for sensitive 
fields subclass UITextView and override the 
canPerformAction:withSender: method to 
return NO for actions that you don’t want to allow 
or just disable the menu completely 
! 
!
Autocorrect Cache 
• iOS keeps a binary keyboard cache containing ordered 
phrases of text entered by the user – /private/var/ 
mobile/Library/Keyboard/dynamic-text.dat 
• To avoid writing data to this cache you should turn 
autocorrect off in text fields whose input should remain 
private. 
• To turn autocorrect off, the developer should set 
textField.autocorrectionType to 
UITextAutocorrectionTypeNo for all sensitive text 
fields
Autocorrect Cache
Cryptography 
• Getting cryptography right in mobile apps is 
difficult. 
• The primary challenge is key management. 
• Most apps fall prey to storing the key with the lock. 
• Need to use a key derivation function.
Key Management 
• Don’t hard code an encryption key in the binary as it 
can easily be retrieved running strings on the binary. 
• Storing an encryption key in the Keychain is not 
secure on compromised devices. 
• On a compromised device encryption keys can also 
be retrieved from memory. You should manually 
allocate memory for encryption keys rather than 
storing them in Objective-C instance variables. 
• Wipe keys from memory when not needed.
Key Management 
• Use a key derivation function to derive a key to 
use to encrypt the master key. 
• Should be based on a secret input such as the 
user’s password. 
• Don’t just use a cryptographic hash of the key. 
• Use a sensible salt such as the 
identifierForVendor
Insecure Algorithms 
• MD5, SHA1, RC4, MD4 algorithms are weak and 
should not be used. 
! 
! 
!
Custom Encryption 
Algorithms 
• Don’t do it. 
! 
! 
!
www.securusglobal.com 
! 
@mgianarakis 
eightbit.io
1 of 77

Recommended

OWASP Melbourne - Introduction to iOS Application Penetration Testing by
OWASP Melbourne - Introduction to iOS Application Penetration TestingOWASP Melbourne - Introduction to iOS Application Penetration Testing
OWASP Melbourne - Introduction to iOS Application Penetration Testingeightbit
8.4K views121 slides
How to Reduce the Attack Surface Created by Your Cyber-Tools by
How to Reduce the Attack Surface Created by Your Cyber-ToolsHow to Reduce the Attack Surface Created by Your Cyber-Tools
How to Reduce the Attack Surface Created by Your Cyber-ToolsEnterprise Management Associates
918 views38 slides
Understanding Your Attack Surface and Detecting & Mitigating External Threats by
Understanding Your Attack Surface and Detecting & Mitigating External ThreatsUnderstanding Your Attack Surface and Detecting & Mitigating External Threats
Understanding Your Attack Surface and Detecting & Mitigating External ThreatsUlf Mattsson
994 views29 slides
Application Threat Modeling by
Application Threat ModelingApplication Threat Modeling
Application Threat ModelingMarco Morana
14.2K views36 slides
2021/0/15 - Solarwinds supply chain attack: why we should take it sereously by
2021/0/15 - Solarwinds supply chain attack: why we should take it sereously2021/0/15 - Solarwinds supply chain attack: why we should take it sereously
2021/0/15 - Solarwinds supply chain attack: why we should take it sereouslySirris
568 views25 slides
Application Security Architecture and Threat Modelling by
Application Security Architecture and Threat ModellingApplication Security Architecture and Threat Modelling
Application Security Architecture and Threat ModellingPriyanka Aash
4.2K views50 slides

More Related Content

What's hot

cyber-security-reference-architecture by
cyber-security-reference-architecturecyber-security-reference-architecture
cyber-security-reference-architectureBirendra Negi ☁️
743 views20 slides
Secure coding presentation Oct 3 2020 by
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020Moataz Kamel
342 views37 slides
Threat Modelling by
Threat ModellingThreat Modelling
Threat Modellingn|u - The Open Security Community
10.6K views30 slides
Penetration testing by
Penetration testingPenetration testing
Penetration testingAmmar WK
2.6K views35 slides
Penetration Testing SAP Systems by
Penetration Testing SAP SystemsPenetration Testing SAP Systems
Penetration Testing SAP SystemsOnapsis Inc.
4.5K views38 slides
Android Security & Penetration Testing by
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration TestingSubho Halder
8.1K views40 slides

What's hot(20)

Secure coding presentation Oct 3 2020 by Moataz Kamel
Secure coding presentation Oct 3 2020Secure coding presentation Oct 3 2020
Secure coding presentation Oct 3 2020
Moataz Kamel342 views
Penetration testing by Ammar WK
Penetration testingPenetration testing
Penetration testing
Ammar WK2.6K views
Penetration Testing SAP Systems by Onapsis Inc.
Penetration Testing SAP SystemsPenetration Testing SAP Systems
Penetration Testing SAP Systems
Onapsis Inc. 4.5K views
Android Security & Penetration Testing by Subho Halder
Android Security & Penetration TestingAndroid Security & Penetration Testing
Android Security & Penetration Testing
Subho Halder8.1K views
Secure SDLC Framework by Rishi Kant
Secure SDLC FrameworkSecure SDLC Framework
Secure SDLC Framework
Rishi Kant1.4K views
Understanding Cyber Kill Chain and OODA loop by David Sweigert
Understanding Cyber Kill Chain and OODA loopUnderstanding Cyber Kill Chain and OODA loop
Understanding Cyber Kill Chain and OODA loop
David Sweigert3.5K views
Building a Cyber Threat Intelligence Knowledge Management System (Paris Augus... by Vaticle
Building a Cyber Threat Intelligence Knowledge Management System (Paris Augus...Building a Cyber Threat Intelligence Knowledge Management System (Paris Augus...
Building a Cyber Threat Intelligence Knowledge Management System (Paris Augus...
Vaticle6K views
Continuous Application Security at Scale with IAST and RASP -- Transforming D... by Jeff Williams
Continuous Application Security at Scale with IAST and RASP -- Transforming D...Continuous Application Security at Scale with IAST and RASP -- Transforming D...
Continuous Application Security at Scale with IAST and RASP -- Transforming D...
Jeff Williams2.4K views
AppSec DC 2019 ASVS 4.0 Final.pptx by Josh Grossman
AppSec DC 2019 ASVS 4.0 Final.pptxAppSec DC 2019 ASVS 4.0 Final.pptx
AppSec DC 2019 ASVS 4.0 Final.pptx
Josh Grossman42 views
Security Training: #3 Threat Modelling - Practices and Tools by Yulian Slobodyan
Security Training: #3 Threat Modelling - Practices and ToolsSecurity Training: #3 Threat Modelling - Practices and Tools
Security Training: #3 Threat Modelling - Practices and Tools
Yulian Slobodyan14.1K views
Cybersecurity trends - What to expect in 2023 by PECB
Cybersecurity trends - What to expect in 2023Cybersecurity trends - What to expect in 2023
Cybersecurity trends - What to expect in 2023
PECB 2.7K views
OWASP based Threat Modeling Framework by Chaitanya Bhatt
OWASP based Threat Modeling FrameworkOWASP based Threat Modeling Framework
OWASP based Threat Modeling Framework
Chaitanya Bhatt305 views
OWASP AppSecCali 2015 - Marshalling Pickles by Christopher Frohoff
OWASP AppSecCali 2015 - Marshalling PicklesOWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling Pickles
Christopher Frohoff132.8K views
Addressing the cyber kill chain by Symantec Brasil
Addressing the cyber kill chainAddressing the cyber kill chain
Addressing the cyber kill chain
Symantec Brasil3.7K views
MITRE ATT&CKcon 2.0: State of the ATT&CK; Blake Strom, MITRE by MITRE - ATT&CKcon
MITRE ATT&CKcon 2.0: State of the ATT&CK; Blake Strom, MITREMITRE ATT&CKcon 2.0: State of the ATT&CK; Blake Strom, MITRE
MITRE ATT&CKcon 2.0: State of the ATT&CK; Blake Strom, MITRE
MITRE - ATT&CKcon1.4K views

Viewers also liked

Ruxmon April 2014 - Introduction to iOS Penetration Testing by
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testingeightbit
4.9K views121 slides
Introduction to iOS Penetration Testing by
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration TestingOWASP
2.4K views57 slides
Hacking and securing ios applications by
Hacking and securing ios applicationsHacking and securing ios applications
Hacking and securing ios applicationsSatish b
15K views46 slides
iOS Application Penetration Testing for Beginners by
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
8.4K views97 slides
Yeni s by
Yeni sYeni s
Yeni sCiendt Cientha
260 views7 slides
Latihanpowerpoint1siska by
Latihanpowerpoint1siskaLatihanpowerpoint1siska
Latihanpowerpoint1siskaCiendt Cientha
192 views6 slides

Viewers also liked(18)

Ruxmon April 2014 - Introduction to iOS Penetration Testing by eightbit
Ruxmon April 2014 - Introduction to iOS Penetration TestingRuxmon April 2014 - Introduction to iOS Penetration Testing
Ruxmon April 2014 - Introduction to iOS Penetration Testing
eightbit4.9K views
Introduction to iOS Penetration Testing by OWASP
Introduction to iOS Penetration TestingIntroduction to iOS Penetration Testing
Introduction to iOS Penetration Testing
OWASP2.4K views
Hacking and securing ios applications by Satish b
Hacking and securing ios applicationsHacking and securing ios applications
Hacking and securing ios applications
Satish b15K views
iOS Application Penetration Testing for Beginners by RyanISI
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
RyanISI8.4K views
Christmas by 6gymnira
ChristmasChristmas
Christmas
6gymnira167 views
PayOnline.ru offers Pay-Travel for tour agents and operators by Neil Bryant
PayOnline.ru offers Pay-Travel for tour agents and operatorsPayOnline.ru offers Pay-Travel for tour agents and operators
PayOnline.ru offers Pay-Travel for tour agents and operators
Neil Bryant1.6K views
PayOnline.ru Pay-Standard by Neil Bryant
PayOnline.ru Pay-StandardPayOnline.ru Pay-Standard
PayOnline.ru Pay-Standard
Neil Bryant1.6K views

Similar to Yow connected developing secure i os applications

YOW! Connected 2014 - Developing Secure iOS Applications by
YOW! Connected 2014 - Developing Secure iOS ApplicationsYOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS Applicationseightbit
565 views78 slides
AusCERT - Developing Secure iOS Applications by
AusCERT - Developing Secure iOS ApplicationsAusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS Applicationseightbit
452 views93 slides
Breaking Secure Mobile Applications - Hack In The Box 2014 KL by
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KLiphonepentest
2K views45 slides
iOS Application Security.pdf by
iOS Application Security.pdfiOS Application Security.pdf
iOS Application Security.pdfRavi Aggarwal
5 views28 slides
DEF CON 24 - Dinesh and Shetty - practical android application exploitation by
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationFelipe Prado
40 views135 slides
Building a Mobile Security Program by
Building a Mobile Security ProgramBuilding a Mobile Security Program
Building a Mobile Security ProgramDenim Group
1.1K views35 slides

Similar to Yow connected developing secure i os applications(20)

YOW! Connected 2014 - Developing Secure iOS Applications by eightbit
YOW! Connected 2014 - Developing Secure iOS ApplicationsYOW! Connected 2014 - Developing Secure iOS Applications
YOW! Connected 2014 - Developing Secure iOS Applications
eightbit565 views
AusCERT - Developing Secure iOS Applications by eightbit
AusCERT - Developing Secure iOS ApplicationsAusCERT - Developing Secure iOS Applications
AusCERT - Developing Secure iOS Applications
eightbit452 views
Breaking Secure Mobile Applications - Hack In The Box 2014 KL by iphonepentest
Breaking Secure Mobile Applications - Hack In The Box 2014 KLBreaking Secure Mobile Applications - Hack In The Box 2014 KL
Breaking Secure Mobile Applications - Hack In The Box 2014 KL
iphonepentest2K views
DEF CON 24 - Dinesh and Shetty - practical android application exploitation by Felipe Prado
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
Felipe Prado40 views
Building a Mobile Security Program by Denim Group
Building a Mobile Security ProgramBuilding a Mobile Security Program
Building a Mobile Security Program
Denim Group1.1K views
Android security by Mobile Rtpl
Android securityAndroid security
Android security
Mobile Rtpl1.9K views
What's in a Jailbreak? - BSides 2019 keynote by MarkDowd13
What's in a Jailbreak? - BSides 2019 keynoteWhat's in a Jailbreak? - BSides 2019 keynote
What's in a Jailbreak? - BSides 2019 keynote
MarkDowd13240 views
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors by Ryan Elkins
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja WarriorsRyan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins - Simple Security Defense to Thwart an Army of Cyber Ninja Warriors
Ryan Elkins817 views
Virtue Security - The Art of Mobile Security 2013 by Virtue Security
Virtue Security - The Art of Mobile Security 2013Virtue Security - The Art of Mobile Security 2013
Virtue Security - The Art of Mobile Security 2013
Virtue Security1.3K views
Intro to INFOSEC by Sean Whalen
Intro to INFOSECIntro to INFOSEC
Intro to INFOSEC
Sean Whalen1.2K views
Owasp Mobile Risk Series : M4 : Unintended Data Leakage by Anant Shrivastava
Owasp Mobile Risk Series : M4 : Unintended Data LeakageOwasp Mobile Risk Series : M4 : Unintended Data Leakage
Owasp Mobile Risk Series : M4 : Unintended Data Leakage
Anant Shrivastava40.3K views
Expand Your Control of Access to IBM i Systems and Data by Precisely
Expand Your Control of Access to IBM i Systems and DataExpand Your Control of Access to IBM i Systems and Data
Expand Your Control of Access to IBM i Systems and Data
Precisely132 views
Analysis and research of system security based on android by Ravishankar Kumar
Analysis and research of system security based on androidAnalysis and research of system security based on android
Analysis and research of system security based on android
Ravishankar Kumar3.5K views

Recently uploaded

Software testing company in India.pptx by
Software testing company in India.pptxSoftware testing company in India.pptx
Software testing company in India.pptxSakshiPatel82
7 views9 slides
Winter '24 Release Chat.pdf by
Winter '24 Release Chat.pdfWinter '24 Release Chat.pdf
Winter '24 Release Chat.pdfmelbourneauuser
9 views20 slides
SAP FOR CONTRACT MANUFACTURING.pdf by
SAP FOR CONTRACT MANUFACTURING.pdfSAP FOR CONTRACT MANUFACTURING.pdf
SAP FOR CONTRACT MANUFACTURING.pdfVirendra Rai, PMP
11 views2 slides
HarshithAkkapelli_Presentation.pdf by
HarshithAkkapelli_Presentation.pdfHarshithAkkapelli_Presentation.pdf
HarshithAkkapelli_Presentation.pdfharshithakkapelli
11 views16 slides
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...Deltares
16 views12 slides
Citi TechTalk Session 2: Kafka Deep Dive by
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Diveconfluent
17 views60 slides

Recently uploaded(20)

Software testing company in India.pptx by SakshiPatel82
Software testing company in India.pptxSoftware testing company in India.pptx
Software testing company in India.pptx
SakshiPatel827 views
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge... by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
DSD-INT 2023 Delft3D FM Suite 2024.01 2D3D - New features + Improvements - Ge...
Deltares16 views
Citi TechTalk Session 2: Kafka Deep Dive by confluent
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
confluent17 views
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon by Deltares
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - AfternoonDSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
DSD-INT 2023 - Delft3D User Days - Welcome - Day 3 - Afternoon
Deltares13 views
Consulting for Data Monetization Maximizing the Profit Potential of Your Data... by Flexsin
Consulting for Data Monetization Maximizing the Profit Potential of Your Data...Consulting for Data Monetization Maximizing the Profit Potential of Your Data...
Consulting for Data Monetization Maximizing the Profit Potential of Your Data...
Flexsin 15 views
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ... by Deltares
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
DSD-INT 2023 Wave-Current Interaction at Montrose Tidal Inlet System and Its ...
Deltares9 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm13 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable11 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy8 views
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema by Deltares
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - GeertsemaDSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
DSD-INT 2023 Delft3D FM Suite 2024.01 1D2D - Beta testing programme - Geertsema
Deltares17 views
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)... by Deltares
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...
Deltares9 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri711 views
Cycleops - Automate deployments on top of bare metal.pptx by Thanassis Parathyras
Cycleops - Automate deployments on top of bare metal.pptxCycleops - Automate deployments on top of bare metal.pptx
Cycleops - Automate deployments on top of bare metal.pptx
Software evolution understanding: Automatic extraction of software identifier... by Ra'Fat Al-Msie'deen
Software evolution understanding: Automatic extraction of software identifier...Software evolution understanding: Automatic extraction of software identifier...
Software evolution understanding: Automatic extraction of software identifier...
Elevate your SAP landscape's efficiency and performance with HCL Workload Aut... by HCLSoftware
Elevate your SAP landscape's efficiency and performance with HCL Workload Aut...Elevate your SAP landscape's efficiency and performance with HCL Workload Aut...
Elevate your SAP landscape's efficiency and performance with HCL Workload Aut...
HCLSoftware6 views

Yow connected developing secure i os applications

  • 1. Developing Secure iOS Applications YOW! Connected 2014 Michael Gianarakis
  • 2. About me ! ! ! @mgianarakis Practice Manager at Securus Global Application security for most of the last decade Good guy that thinks like a bad guy
  • 3. This presentation • Aims to give a good overview of how to design secure iOS applications • Focuses on the key security issues commonly found in iOS applications • Not a guide to hacking iOS applications
  • 4. Topics • Overview of the iOS attack surface • Common iOS security issues • Secure iOS application design principles • Secure development approaches for key security iOS issues
  • 6. Other Apps Your App 3rd Party Services Network iOS Device Your Backend IPC, iOS 8 Extensions WiFi, LTE
  • 7. Other Apps Your App 3rd Party Services Network iOS Device Your Backend Malicious apps Jailbroken or compromised device Man in the middle attacks Server compromise and web attacks
  • 8. Understanding the risk profile of your app • Important first step that is often overlooked. • Drives the security design of your application • Key considerations: • What information is in the app and how sensitive/valuable is it? • Who are the likely threat actors? How capable are they? • What are the likely attack scenarios for each threat actor? • What is your tolerance for risk? • Regulatory requirements?
  • 9. Common iOS Application Security Issues
  • 10. Common Issues • Based on working with a range of companies and a variety of applications including: • Mobile banking and trading apps • Board paper apps • Internal business apps • Retail apps • Social networking apps • Games
  • 11. Common Issues • Binary and Runtime Security Issues • Transport Layer Security Issues • Data Security Issues
  • 12. Get these right and you are well and truly ahead of the pack
  • 13. Secure iOS Design Principles
  • 14. Don’t trust the client or the runtime environment
  • 15. Users will connect to untrusted networks
  • 16. Don’t store anything sensitive on the device
  • 17. Binary and Runtime Security
  • 18. Binary and Runtime Security • As a reflective language, Objective-C can observe and modify it’s own behaviour at runtime. • Can be great from a development perspective • Not so much from a security perspective
  • 19. Binary and Runtime Security • The ability to create and call ad hoc classes and methods on the fly allows attackers to manipulate and abuse the runtime of the application: • Bypass security locks • Break logic checks • Escalate privilege • Steal information from memory. • Implementing runtime security checks significantly increases the security of your application • You should always assume that your application will run on a compromised device
  • 21. Myths surrounding jailbreaking • Generally speaking, iOS is one of the most secure operating systems available • One of the defining security features of iOS is the chain of trust. Every bit of code is signed and approved by Apple. • Break that trust and all bets are off
  • 22. Myths surrounding jailbreaking • Some of the security issues discussed in this presentation will require a compromised device • This is usually the cause of a lot of misunderstanding when it comes to assessing the impact of these issue
  • 23. Myth 1 - Public jailbreaks are the only jailbreaks • I often hear “but there is no jailbreak for version x.x.x so we are safe” • FACT: Public jailbreaks for every version of iOS released so far • FACT: Not all users update to the latest firmware • FACT: iOS vulnerabilities are extremely valuable, there are many more exploits than just those that people give out for free on the internet
  • 24. Myth 2 - Jailbreaks require physical access to the device • I often hear “well someone would need to steal the device to compromise it” • FACT: Not all exploits require physical access. • jailbreakme.com TIF image processing vulnerability and PDF processing vulnerability required only a user visit a web page in Safari • Remote code execution via SMS found by Charlie Miller (https:// www.blackhat.com/presentations/bh-usa-09/MILLER/BHUSA09- Miller-FuzzingPhone-PAPER.pdf) • Nitro JIT vulnerability to download and execute unsigned code via POC app that was approved also found by Charlie Miller (http:// reverse.put.as/wp-content/uploads/2011/06/ syscan11_breaking_ios_code_signing.pdf)
  • 25. Myth 3 - Jailbreaks are always obvious to the user • It is a commonly held misconception that if Cydia is not on the device then it is not jailbroken. • Cydia is an app that is commonly installed with public jailbreaks but is certainly not a prerequisite or in any way required for a jailbreak. • In fact, any kind of targeted exploit is unlikely to install Cydia in the first place.
  • 26. Myth 4 - Jailbreaking is Apple’s problem • FACT: The security of your app, your data and your users is your responsibility. • FACT: The security risk to your organisation is your responsibility. You will be the one that suffers the impact if your app is compromised and you should be actively managing that risk. • FACT: Apple won’t secure your app for you.
  • 27. Myth 5 - You can completely protect against jailbreaking • FACT: Unfortunately you will never be able to completely secure an application. • The idea is to raise the bar for the security of your app so that it becomes too difficult or costly to attack.
  • 29. Debug Check • A simple and effective method of securing the runtime is to implement anti-debugging control. • There may be reasons to allow an application to run on a jailbroken device but there are no legitimate reasons for debugging a production application
  • 30. Debug Check • Debugging protection can be implemented using the following techniques: • Periodically monitoring the process state flag to determine if application process is being debugged and then terminating the process. • Using the ptrace request PT_DENY_ATTACH two prevent future tracing of the process. This can be done with the following function call from within the application: • ptrace(31,0,0,0) • These techniques should be used in conjunction with each other to provide a more robust anti-debugging control.
  • 31. Jailbreak Detection • There are multiple ways to implement jailbreak detection but the two most common methods are: • File system check • Sandbox integrity check !
  • 32. Jailbreak Detection • File system checks test for the presence of files that are typically found on jailbroken devices. • Some examples of files to look for: • /Library/MobileSubstrate/MobileSubstrate.dylib • /var/cache/apt • /var/lib/apt • /bin/bash and /bin/sh • /usr/sbin/sshd and /etc/ssh/sshd_config
  • 33. Jailbreak Detection • When implementing a file system check you should ensure you check for multiple files using different methods such as fileExistsAtPath and isReadableFileAtPath ! !
  • 34. Jailbreak Detection • A sandbox integrity check tests that the integrity of Apple’s sandbox is intact on the device, and that the application is running inside it. • A sandbox integrity check works by attempting to perform an operation that would not typically succeed on a device that has not been jailbroken. • A common test is to attempt to use the fork function to spawn a new child process which will succeed if the sandbox has been compromised or if the application is running outside of the sandbox
  • 35. Jailbreak Detection • Check out the IMAS project’s Security Check module https://github.com/project-imas/ security-check ! ! !
  • 36. Inline Functions • Any sensitive functions such as the security checks should be compiled as inline functions • Inlining functions complicates attacks that involve editing memory and patching the application by forcing an attacker to find and patch all occurrences of the code. • Specify a function as inline using the __attribute__((always_inline)) compiler directive.
  • 37. Inline Functions • This directive may not always be honoured however. To minimise the chance that this will happen configure the following: • Set the -finline-limit compiler flag high enough to allow for inlining of your code (e.g. 5000) • Set the optimisation level at least -O1 • Don’t use -unit-at-a-time (note this is automatically set at -O3 and above • Don’t use -keep-inline-functions if your functions are static
  • 38. Address Space Validation • Any time malicious code is injected into your application it must be loaded into an address space • Validating the address space adds complexity to attacks as it forces an attacker to inject the malicious code into the existing address space with the valid code or attacking dynamic linker
  • 39. Address Space Validation • The dladdr function in the dynamic linker library returns information about the address space a particular function belongs to. • Passing it the function pointer of a class’s method implementation can determine whether it came from your app, Apple’s frameworks, or an unknown/malicious source
  • 40. Avoid Simple Logic • Simple logic checks for security functions and business logic are susceptible to to manipulation. • Examples include: • - (BOOL) isLoggedIn • BOOL isJailbroken = YES • - (void) setDebugFlag
  • 42. Securing Memory • Instance variables stored within Objective-C objects can be easily mapped inside the Objective-C runtime. • Never store anything in memory until the user has authenticated and data has been decrypted. • Manually allocate memory for sensitive data rather than storing the data (or pointers to this data) inside Objective-C instance variables. • Wipe sensitive data from memory when it’s not needed.
  • 45. Transport Layer Security • Users will connect their devices to untrusted networks • If your app handles sensitive data you should be encrypting all traffic between the app and the back end.
  • 46. Protocol Version • If using NSURLSession you can specify the minimum supported TLS protocol version by setting the TLSMinimumSupportedProtocol property in the NSURLSessionConfiguration ! !
  • 47. Cipher Suites • You should disable support for low and medium strength cipher suites on the server • Medium: ! ! • Low: !
  • 48. Certificate Validation ! • Always perform certificate validation checks • When using Apple frameworks iOS will accept a certificate if it’s signed by a CA in the trust store • Certificate validation checks will often be overridden in development to avoid issues with self-signed certs. • Typically this is encapsulated in a variable somewhere or in some other simple logic that can be subverted.
  • 50. Certificate Validation ! • To avoid having to do this, use valid certs in development (e.g. free certs) • If you do need to disable validation, ensure that the production builds essentially “hard code” validation. • Consider certificate pinning.
  • 51. Certificate Pinning • Mobile apps are great candidates for certificate pinning as they only need to communicate with a small, clearly defined set of servers • Certificate pinning improves security by removing the need to trust the certificate authorities. • iSEC partners have a great library for implementing certificate pinning https:// github.com/iSECPartners/ssl-conservatory
  • 53. Two types of data security issues…. • Sensitive data stored on the device by the application that was not secured appropriately by the developer • Unintended data leakage via system functionality !
  • 54. Insecure Data Storage • It’s common to find sensitive data stored insecurely on the device. • As a general rule sensitive information should not be stored on the device at all. • Really consider the need to store sensitive information on the device. Generally it is functionally and technically possible to not store the data at all.
  • 55. Property List Files • Don’t store sensitive information using NSUserDefaults. Plist files are unencrypted and can easily be retrieved from the device and backups ! ! !
  • 56. SQLite Databases • Avoid storing sensitive information in SQLite databases if at all possible. • If you need to store sensitive information encrypt the database using SQLCipher https://github.com/ sqlcipher/sqlcipher • If you are using Core Data the Encrypted Core Data module of the IMAS project leverages SQLCipher to encrypt all data that is persisted https:// github.com/project-imas/encrypted-core-data/
  • 57. Data Protection APIs • If you need to write files with sensitive information to the device (not credentials) at a minimum write files with an appropriate data protection attribute • If you don’t need to access the file in the background use NSFileProtectionComplete (for NSFileManager) or NSDataWritingFileComplete (for NSData). • With this attribute set the file is encrypted on the file system and inaccessible when the device is locked.
  • 58. Data Protection APIs • If you need to access the file in the background use NSFileProtectionCompleteUnlessOpen for (NSFileManager) or NSDataWritingFileProtectionCompleteUnlessOp en (for NSData) • With this attribute set the file is encrypted on the file system and inaccessible while closed. • When a device is unlocked an app can maintain an open handle to the file even after it is subsequently locked, however during this time the file will not be encrypted.
  • 59. Unintended Data Leakage • Sensitive data captured and stored automatically by the operating system. • Oftentimes developers are unaware that the OS is storing this information.
  • 60. Background Screenshot Cache • Every time an application suspends into the background, a snapshot is taken to facilitate the launch animation. • Stored unencrypted in the app container. • This allows attackers to view the last thing a user was looking at when the application was backgrounded.
  • 62. Background Screenshot Cache • Place content clearing code in the state transition methods applicationDidEnterBackground and applicationWillResignActive • The simplest way to clear the screen contents is to set the key window’s hidden property to YES. ! !
  • 63. Background Screenshot Cache • Be careful, if there are any other views behind the current view, these may become visible when the key window is hidden. • Other methods: • Manually clearing sensitive info from the current view • Placing the launch image in the foreground • Note: ingoreSnapshotOnNextApplicationLaunch will not prevent the screenshot from being taken
  • 64. URL Caching • iOS automatically caches requests and responses for protocols that support caching (e.g. HTTP/ HTTPS) and stores them unencrypted in a SQLite database in the app container. • Make sure to configure the server to send the appropriate cache control headers: !
  • 65. URL Caching • Can also control caching in the client. • For NSURLConnection implement the connection:willCacheResponse: delegate method ! ! • For NSURLSession set the URLCache property to NULL
  • 66. Logging • Less of an issue since iOS 7 • Pre-iOS 7 any app was able to view the device console and thus any sensitive data that was logged. • Still a good idea to make sure nothing sensitive is logged.
  • 67. Logging • If you must log sensitive information in development for debugging purposes special care should be taken to ensure that this code is not pushed to production. • One way to do this is to redefine NSLog with a pre-processor macro such as #define NSLog(…)
  • 68. Pasteboard • When the Cut or Copy buttons are tapped, a cached copy of the data stored on the device’s clipboard -/private/var/mobile/Library/ Caches/com.apple.UIKit.pboard/ pasteboard. • If the application handles sensitive data that may be copied to the pasteboard consider disabling Copy/Paste functionality for sensitive text fields (note this is done by default for password fields)
  • 69. Pasteboard • To disable pasteboard operations for sensitive fields subclass UITextView and override the canPerformAction:withSender: method to return NO for actions that you don’t want to allow or just disable the menu completely ! !
  • 70. Autocorrect Cache • iOS keeps a binary keyboard cache containing ordered phrases of text entered by the user – /private/var/ mobile/Library/Keyboard/dynamic-text.dat • To avoid writing data to this cache you should turn autocorrect off in text fields whose input should remain private. • To turn autocorrect off, the developer should set textField.autocorrectionType to UITextAutocorrectionTypeNo for all sensitive text fields
  • 72. Cryptography • Getting cryptography right in mobile apps is difficult. • The primary challenge is key management. • Most apps fall prey to storing the key with the lock. • Need to use a key derivation function.
  • 73. Key Management • Don’t hard code an encryption key in the binary as it can easily be retrieved running strings on the binary. • Storing an encryption key in the Keychain is not secure on compromised devices. • On a compromised device encryption keys can also be retrieved from memory. You should manually allocate memory for encryption keys rather than storing them in Objective-C instance variables. • Wipe keys from memory when not needed.
  • 74. Key Management • Use a key derivation function to derive a key to use to encrypt the master key. • Should be based on a secret input such as the user’s password. • Don’t just use a cryptographic hash of the key. • Use a sensible salt such as the identifierForVendor
  • 75. Insecure Algorithms • MD5, SHA1, RC4, MD4 algorithms are weak and should not be used. ! ! !
  • 76. Custom Encryption Algorithms • Don’t do it. ! ! !