views:

123

answers:

4

We are in the process of writing a native windows app (MFC) that will be uploading some data to our web app. Windows app will allow user to login and after that it will periodically upload some data to our web app. Upload will be done via simple HTTP POST to our web app. The concern I'm having is how can we ensure that the upload actually came from our app, and not from curl or something like that. I guess we're looking at some kind of public/private key encryption here. But I'm not sure if we can somehow just embed a public key in our win app executable and be done with it. Or would that public key be too easy to extract and use outside of our app?

Anyway, we're building both sides (client and server) so pretty much anything is an option, but it has to work through HTTP(S). However, we do not control the execution environment of win (client) app, plus the user that is running the app on his/her system is the only one that stands to gain something by gaming the system.

A: 

Since you're controlling the client, you might as well embed the key in the application, and make sure the users don't have read access to the application image - you'll need to separate the logic to 2 tiers - 1 that the user runs, the other that connects to the service over HTTP(S) - since the user will always have read access to an application he's running.

If I understand correctly, the data is sent automatically after the user logs on - this sounds like only the service part is needed.

Aviad P.
Whoever downvoted this, please provide a reason. The original poster specifically said he controlls the calling environment, i.e. the client, and if so - my answer is valid.
Aviad P.
I'm not the DV, but he also suggested that he knows that an attacker can extract the key, which means they're not actually in control of the execution environment. I think they meant to say that they merely are building both the client and the server.
EricLaw -MSFT-
I've been unclear originally and have updated the question to reflect that we're not actually controlling the execution environment of client application.
nnc
+9  A: 

Ultimately, it's not possible to prove the identity of an application this way when it's running on a machine you don't own. You could embed keys, play with hashes and checksums, but at the end of the day, anything that relies on code running on somebody else's machine can be faked. Keys can be extracted, code can be reverse-engineered- it's all security through obscurity.

Spend your time working on validation and data cleanup, and if you really want to secure something, secure the end-user with a client certificate. Anything else is just a waste of time and a false sense of security.

nitzmahone
I realize now that you're right, and it would all be just a false sense of security. But would client certificate help here at all if the user is actually the one that would be trying to game the system by uploading fake/fabricated data?
nnc
Only in that you'd know pretty positively who was doing it and you can revoke their certificate if they're compromising the system (assuming you set up your CRLs/OCSP correctly on the CA that issued it and on the validating server).
nitzmahone
Right, someone who controls the client can do anything, including bypassing all of your security measures. This could take the form of modifying the program's variables in-memory, which is very hard to defend against (impossible in practice), including potentially running it in a VM and modifying the memory from outside the VM (where the app doing the modifying cannot be detected).The OP's best bet is to try to validate the upload so that nothing BAD can happen even if garbage gets uploaded - it may be one day, due to a client-side bug, anyway.
MarkR
+2  A: 

About the best you could do would be to use HTTPS with client certificates. Presumably with WinHTTP's interface.

But I'm not sure if we can somehow just embed a public key in our win app executable and be done with it.

If the client is to be identifying itself to the server, it would have to be the private key embedded.

Or would that be too easy to extract and use outside of our app?

If you don't control the client app's execution environment, anything your app can do can be analysed, automated and reproduced by an attacker that does control that environment.

You can put obfuscatory layers around the communications procedure if you must, but you'll never fix the problem. Multiplayer games have been trying to do this for years to combat cheating, but in the end it's just an obfuscation arms race that can never be won. Blizzard have way more resources than you, and they can't manage it either.

bobince
+2  A: 

You have no control over the binaries once your app is distributed. If all the signing and encryption logic reside in your executable it can be extracted. Clever coders will figure out the code and build interoperable systems when there's enough motivation to do so. That's why DRM doesn't work.

A complex system tying a key to the MAC address of a PC for instance is sure to fail.

Don't trust a particular executable or system but trust your users. Entrust each of them with a private key file protected by a passphrase and explain to them how that key identify them as submitters of contents on your service.

Alexandre Jasmin
Based on the answers here, I've realized that there is no real "solution" to this problem as the user is the only one that gains something by gaming the system, so I don't think private key with a passphrase helps in this case?
nnc
Well if the user sees no detriment *privately signing* someone else timely uploads or if integrating their key in another app is to their advantage there's not much you can do.
Alexandre Jasmin