views:

187

answers:

7

I'm designing an iPhone app that communicates with a server over HTTP.

I only want the app, not arbitrary HTTP clients, to be able to POST to certain URL's on the server. So I'll set up the server to only validate POSTs that include a secret token, and set up the app to include that secret token. All requests that include this token will be sent only over an HTTPS connection, so that it cannot be sniffed.

Do you see any flaws with this reasoning? For example, would it be possible to read the token out of the compiled app using "strings", a hex editor, etc? I wouldn't be storing this token in a .plist or other plain-text format, of course.

Suggestions for an alternate design are welcome.

A: 

I suggest to add some checksum (md5/sha1) based on the sent data and a secret key that your app and the server knows.

epatel
Not sure why this got voted down. It's a common technique. In this situation, though, the trick is hiding the secret key from device owner, when the device needs the secret key to send the message.
erickson
I agree. Hiding is hard if one want to make a truly secret key. But then he will need to recreate the stuff on the server. Which I would consider harder to do if he's not running an own server...
epatel
...which also is a weak link, specially when hosted somewhere "else"
epatel
+1  A: 

The way I understand it, yes, the key could be retrieved from the app one way or another. It's almost impossible to hide something in the Objective-C runtime due to the very nature of it. To the best of my knowledge, only Omni have managed it with their serial numbers, apparently by keeping the critical code in C (Cocoa Insecurity).

It might be a lot of work (I've no idea how complex it is to implement), but you might want to consider using the push notifications to send an authentication key with a validity of one hour to the program every hour. This would largely offload the problem of verifying that it's your app to Apple.

wbg
+2  A: 

In general, assuming that a determined attacker can't discover a key that is embedded in application on a device under his physical control (and, probably, that he owns anyway) is unwarranted. Look at all of the broken DRM schemes that relied on this assumption.

What really matters is who's trying to get the key, and what their incentive is. Sell a product aimed at a demographic that isn't eager to steal. Price your product so that it's cheaper to buy it than it is to discover the key. Provide good service to your customers. These are all marketing and legal issues, rather than technological.

If you do embed a key, use a method that requires each client to discover the key themselves, like requiring a different key for each client. You don't want a situation where one attacker can discover the key and publish it, granting everyone access.

The iPhone does provide the "KeyChain" API, which can help the application hide secrets from the device owner, for better or worse. But, anything is breakable.

erickson
Thanks for the answer and especially for the link to the related question.
lawrence
A: 

Applications can be disassembled so that they could find your key.

Wahnfrieden
A: 

This is a duplicate of my question, and the answer seems to be 'no you cannot'

http://stackoverflow.com/questions/1165979/what-is-the-best-way-to-hide-encrypt-a-string-in-objc-c/1166003#1166003

erotsppa
A: 

More information is needed to determine whether the approach is sound. It may be sound for one asset being protected and unsound for another, all based on the value of the asset and the cost if the asset is revealed.

Several earlier posters have alluded to the fact that anything on the device can be revealed by a determined attacker. So, the best you can do is determine valuable the asset is and put enough hurdles in the way of the attacker that the cost of the attack exceeds the value of the asset.

One could add to your scheme client-side certificates for the SSL. One could bury that cert and the key for the token deep in some obfuscated code. One could probably craft a scheme using public/private key cryptography to further obscure the token. One could implement a challenge/response protocol that has a time boxed response time wherein the server challenges the app and the app has X milliseconds to respond before it's disconnected.

The number and complexity of the hurdles all depend on the value of the asset.

Jack

Jack Cox
A: 

You should look into the Entrust Technologies (www.entrust.com) product line for two-factor authentication tied to all sorts of specifics (e.g., device, IMEI, application serial number, user ID, etc.)

jonhwilliams