Is there a way to have a secure by design client-server communication in a sense that the server can check if the client is not a modified version?What I'd like to do is give the user access to both the client's and the server's source code, but keep him from communicating with a modified version.As a practical example, let's suppose a multiplayer race game. Is there a way to give the user access to the source (and to compiling it and playing it on the server if he wants) but keeping him from, let's say, altering the speed of his car to 2x normal speed and using this new version to play?As I understand, the compiled program could generate some hash and send it together for the server to verify. But then there also comes stuff like being able to get this code and making another version send it, etc.If this is a known problem, please also provide further information about it.(Any recommendations on books or papers related to that are also welcome)
How to make a Secure by Design client-server communication?
distributed systems;security
The short answer is: No, you can't verify what code is running on the client.  As a result, you should never trust what is running on the client.You could use all sorts of hashes, but nothing prevents a malicious client from lying to you about its hash and telling you what you want to hear.  Asking the client to hash itself and tell you its hash would be like having airport security ask passengers Are you a terrorist? and then believing them when they say No.In principle this problem could be solved with trusted hardware on the client, such as a a TPM.  Currently, a TPM is about the only way to check that the client is running unmodified code.  However, in practice using TPMs for this has major issues that typically render it not deployable in practice for the purpose you have in mind.Therefore, in practice the answer is basically no, there's no way to check.  See https://security.stackexchange.com/q/72091/971 for an explanation why there is no way to do this without trusted hardware (like a TPM).  As a result, the standard mantra is you can't trust the client.  See e.g., https://security.stackexchange.com/q/40378/971 for some discussion of alternative architectures don't rely on trusting the client.For a partial explanation why TPM-based solutions are not really deployable in practice, see https://security.stackexchange.com/q/2459/971.If you want to explore the TPM approach, see https://security.stackexchange.com/q/5570/971 and https://security.stackexchange.com/q/4008/971.  However, I don't recommend it as a promising avenue.  In the future, Intel will be releasing SGX technology, which might be a better way to achieve this -- but it has not yet been released, so it will be quite some time before you can count on all your clients to run on hardware that supports SGX.