Okay, I have a rails backend server which is pretty much just a database server.

The database contains information about different types of a substance, and that substance's confidential inherent percentage makeup.

Admins on the app can create PATCH requests to update records over time, and users of the app on login sync their local REALM database with the server in case any admins have added/deleted/modified any records. The realm database on the app is created and encrypted with a key that is stored in keychain on the first use of the app.

Also on first use, the app will sync completely with the server, retrieving all of the sensitive substance records and storing in encrypted local REALM database.

I am going to encrypt transmission from the outside with ssl, and implement ssl pinning to inhibit MITM attacks.

But what can I do to prevent the public from ever finding out the makeup of these confidential substances?

The only reason the data is stored locally is for offline use. Otherwise I would have the users query the server with the percentage makeups they needed, and the server return with the names of the suitable options.

  • 1
    If you allow the data to leave machines you physically control, you lose control of the data. Commented Jan 3, 2016 at 22:25
  • Since the client devices have to work with unencrypted data or eventually decrypt the stored data with a key (local key is not secure, remote is not an option due to offline use), I don't think it's possible the way you want. Commented Apr 3, 2016 at 19:33

2 Answers 2


Never Trust A User

What does this mean? Always assume a user will have access to any and all data on a user's device. You cannot stop them from getting it because they can just follow through your memory heap, find it RIGHT before encryption, and take it.


Some bad news boss. You can't. Even if you limit it to being on the remote server only they can still just brute force every combination they are curious about and get it. The only thing you can really do is make it not feasible to do so with rate limiting so that it would take them YEARS. If they have a local copy of the database, and just watch for that encryption key in memory they can get the data either way.

If they can get the data through any way, they can get the data.

It's a sad truth of security.


As you mention - SSL is good only for protecting from MITM.

There is nothing you can really do to protect the data you stored at the clients devices. The clients can always find some simple or advance methods (depends on how much effort you put into this) that will allow them to read and access what ever the client app can access.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .