How to store critically sensitive information such as secret, key, token, encryptionKey in iOS application

Rajan Twanabashu picture Rajan Twanabashu · Mar 30, 2017 · Viewed 7.4k times · Source

When we talk about securing iOS application we often forget to secure most critically sensitive information such as secret, key, token, encryptionKey. This information is stored in iOS binary. So none of your server side security protocol will help you.

There are lots of suggestion that we should not store such information in the app but store in the server and get it via SSL secured web service call. But this is not possible for all application. E.g. if my application does not need web service at all.

In iOS app we have following option to store information.

  1. UserDefault: Not appropriate for this case
  2. String Constant: Not appropriate for this case. Can be reverse engineer to retrieve or just use strings command
  3. Secure Database: Store in Secure and encrypted Database. But again have responsibility to secure database username and password.
  4. KeyChain: Best to store critical info. But we cannot save information before installing the app. To store in the keychain, we first need to open the app, read from some source and store in the keychain. Not appropriate for our case either.
  5. Custom Hash String Constant: Not to directly use secret, token, key from service provider (mixpanel, paypal), instead use hash version of that information from custom key. This is also not perfect solution. But add complexity during hacking.

Kindly send some awsome solution to this problem.

Answer

Michał Myśliwiec picture Michał Myśliwiec · Apr 11, 2017

If you don't want to use your own backend then use Apple. You can configure On Demand Resources and keep data file with your key, token, any secret on Apple server. After first download you can write this data to Keychain which is secure enough. I'm guessing networking between iOS and Apple server is also secure enough.

On-Demand Resources Essentials

Accessing and Downloading On-Demand Resources