1

I have some data I’ve spent months collecting, cleaning and structuring. The app I'm building will be able to search the data. So far I'm storing the sqlite file in the users filesystem and not on a remote server because I want the search result to be instant to give users the best experience possible, independently of their connection speed.

But I've just discovered anybody with a jailbroken phone can just "steal" the information store in my sqlite file.

The last thing I want is for someone to get the result of my hard work and publish it on a website which could potentially makes the app useless.

Is there any way to stop this from happening?

Thanks for your help!

Johann
  • 12,158
  • 11
  • 62
  • 89
  • possible duplicate of [Encrypting SQLite Database file in iPhone OS](http://stackoverflow.com/questions/929744/encrypting-sqlite-database-file-in-iphone-os) – Roger Jun 23 '11 at 17:33
  • The phone doesn't have to be jailbroken, necessarily. I could open up your application's IPA file (it's just a ZIP) from the iTunes Library on my computer and poke around in the app itself (it's just a bundle folder), and pull the SQLite DB right out. – Sixten Otto Jun 23 '11 at 17:34

2 Answers2

6

What you want is a form of DRM. Ultimately, DRM cannot prevent a dedicated attacker from getting at the underlying data. Anything the user can access can, in theory, be accessed by a malicious application.

You can encrypt the rows of the database and hide the key somewhere in the app, but an intrepid hacker will find it. You can download the whole file on first run and encrypt it with a key unique to that device, but then you have to store the key somewhere or have an algorithm for regenerating it--and a hacker can get at either (even if it's in the keychain.) If you require a network connection and use a key generated from something server-side and client-side... well, an attacker can just spoof the request and get that server-side component anyway.

So it really depends how secure you want to be. If you just want to keep honest people honest, simple encryption is often good enough. If you want to make a bulletproof DRM system... you'd be the first to accomplish it.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
  • I like your humour! But it's a bit depressing at the same time... So I suppose not copying the sqlite file in the users filesystem and leaving it in the resource folder won’t make any difference? – Johann Jun 23 '11 at 17:21
  • No, it wouldn't make any difference where you store the file. – Sixten Otto Jun 23 '11 at 17:35
-1

You can use Encrypted Core Data to secure your data.

This library actually decrypts your database at runtime. You can leave your PASSCODE in your .m file. (My assumption is that it is difficult to get the hardcoded PASSCODE from the object file)

And as @jonathan put it, if some person is desperate to get your data, they will.

EDIT:

As Zaph mentioned in the comments section, do not try to put password in your code either directly, or by obfuscating them in your code by some logic, as any one who is desperate to get your key could reverse engineer your binary and get it.

Is it possible to reverse-engineer my iPhone application?

Community
  • 1
  • 1
RK-
  • 12,099
  • 23
  • 89
  • 155
  • Put the PASSCODE in the Keychain, that is what it is for.The SO Question referenced states: "not easily reverse engineered". That is fine if the potential attacker is lazy, can the OP depend on that? – zaph Oct 31 '14 at 11:30
  • If the device is jailbroken, is not it the passcode can be taken from the device? – RK- Nov 02 '14 at 14:32
  • 1
    For a jailbroken iOS device there are only two options: a brute force attack against the AES key or against the user's passcode (PIN). The first is essentially not possible. To attack the user's pin requests must be made to the Keychain and that is rate limited by the Keychain, there is no other way to brute force against the user's passcode. Apple has promised that as CPU speeds increase the minimum time between passcode attempts will not decrease. The user should choose an extended passcode. Note: people who jailbreak do not care about security but content owners probably still do. – zaph Nov 02 '14 at 14:37
  • Thanks Zaph. I assumed you can crack the keychain if device is jailbroen. :) – RK- Nov 04 '14 at 04:17