A mobile client calls an API. In the call it has to use an API key, oauth token, signature, something like that, to identify the calling app for back end management. The calling app gets billed on usage. The key/token/signature has to be stored on the client. A rogue developer downloads the app, sniffs the app/device and gets the key. It then uses it in its own app to avoid paying.
How can I protect against this situation? cannot think of a solution.
Thanks
Geoff
Geoff,
The app should be embedded with the client ID/secret, send a request to allow access associated to a user, user approves, generate the OAuth token, store the token, and use that for future calls. An app wouldn't be able to do anything with the client ID/secret without following the standard OAuth procedure.
If the app isn't user-based, or is open source (where the encryption key used for the secret can be changed), then it can be more complicated. At that point the OAuth specification is more of an unnecessary overhead, aside from standardization. Our API is open source, and the app is used to administration the website. We don't want to embed any keys. We don't want to pass any credentials (or require SSL). I've gotten around it by altering the spec a bit. Only the client ID is stored in the app, for tracking purposes. The user chooses a user in the admin, generates an Auth Code, inputs the code into the app, which logs them in (by generating and storing an OAuth token in the background). It has a number of advantages: 1) can be open sourced and not reliant upon encrypted keys 2) no user credentials are passed, only temporary/restricted keys, 3) app privileges are entirely based upon the key, 4) key can be revoked, and app would never have access to user credentials to circumvent that. 4) the auth codes are consumed, can only be used once, and are temporary.
I don't know if this helps, but figured I would throw it out there.
What your client is asking for is akin to asking how to keep his highly secure bank vault from getting cracked. We've all seen movies that show how to do it but in real life it almost never happens.
Rather than try to build a better security system than the industry standard oAuth the better approach might be to build in triggers that puts temporary accounts blocks on accounts that start generating massive amounts of calls and include a whitelist for the rare clients that need massive amounts of calls that actually are legitimate?
-Mike
- The identity of the app itself (e.g. Tweetdeck) has an essentially unlimited quota since many people
could download it.
- However each individual user (e.g. your Twitter user) does have a limited quota (they may all be equal
or not if you have different usage tiers) across all apps they may use.
This way reverse engineering the app doesn't help much, because the abusive developer still needs to get hold of end user credentials and if they do, the quota are likely to be limited to what's reasonable for one human user per day and not bulk download.
When there are no authenticated users, as has already been said it's much harder and background monitoring is probably your best bet. A word of warning here though - it's still better if you can do this with something that isn't the application ID if the applications are used by many people because you'll punish more popular apps. So if you can use something like phone UUID (thanks apple for removing these…), some hash created on app creation, IP Addresses (have their own problems but some utility). The problem with all of these is that they are relatively easy to spoof - they just make it a bit less trivial to attack.