Best Practices for Writing Secure iOS and Android Apps
These guidelines address security and should be followed in addition to standard coding best practices.
- Use native SSL libraries on the OS. Some third-party libraries have vulnerabilities such as Heartbleed, which can be exploited for man-in-the-middle attacks.
- Use mutual SSL authentication in your apps to validate server connections to ensure that your app is communicating to the server you expect and not a man-in-the-middle.
- All app communication should be encrypted.
- Pin certificates use for encrypted communications and mutual authentication. Do not rely on root certificates stored in the OS, as new roots can be added, which can lead to man-in-the-middle attacks.
- Avoid using precompiled third-party libraries, since you do not know what they do. These could be ad libraries, encryption libraries and graphics libraries. Do not download libraries from non-trusted parties.
- Only enable inter-app communication for apps you trust and that your app must communicate with.
- Ensure inter-app communication is also encrypted.
- Do not store files unencrypted. Ensure that encryption libraries are fully utilised. Do not store non-essential personally-identifiable information inside your app.
- It is better to download this from servers as needed.
- Do not store passwords on the device. If you must, store only a hash of the password.
- iOS apps should store secrets and credentials in the Key Chain. This leverages the security that is built into the Key Chain.
- Do not send confidential information via SMS or APNS messages. They can be read by anyone who has access to the phone, even if the phone is locked.
- Be wary of any plug-ins that your app uses. These are often vectors for introducing security vulnerabilities into apps.
- Only use code and development tools from trusted vendors, and only download core development libraries and tools from Apple or Google’s actual download sites. Do not download development tools from unofficial sites, or your app could be infected with malware such as Xcode Ghost.
- Enable Position Independent Execution when compiling your app. PIE is important to reduce the chance that malicious apps and tools can access known memory locations in your app.
- Only declare permissions that you actually need and use in the app. Do not just copy a permissions list from a generic app.
- Be very wary of embedding API keys into your app where the API can be used to access sensitive data or accounts on cloud services. Assume API keys have been copied (because they can be copied from any jailbroken or rooted phone). Ensure that access controls are enforced by the addition of a password or other user credential that is entered by the user and not common to all apps.
- Financial services apps should consider adding code to check for jailbroken and rooted phones, and not allow transactions from compromised phones.
- Have code reviews by team members or external parties.
- Analyse your app with tools to validate its behaviour prior to release.
Appcare…..we care for your app !!
Source : https://www.proofpoint.com/sites/default/files/pp-mobile-defense-best-practices.pdf