Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
4.86/5 (6 votes)
See more:
Hi all,

I need to develop a client/server architecture:

- language c#
- native client
- server: web service, may be wcf service

The biggest challenge ist to ensure, that only our client software can talk (send data) to the web service.
I protect the client itself with a digital certificate and some other things so it can't be modified. But how to make sure that nobody captures the network traffic and then sends faked data to the service. SSL is not possible.
Can I use the public key from the digital certificate (Microsoft Code Signing certificate) to encrypt the data before sending? But if so, someone else could also use this public key to send encrypted data to the service.

What would be the right (a good) solution for that problem?

Thanks.

Thom
Posted
Updated 17-Feb-11 6:33am
v2
Comments
Sergey Alexandrovich Kryukov 17-Feb-11 2:17am    
Pretty interesting yet practically sound Question, my 5.
--SA
Sunasara Imdadhusen 17-Feb-11 2:24am    
Good question!!

Part 1



This is absolutely possible. This is quite apparent, but logical proof of the method needs effort.

First, let's do our assumptions. I you cannot accept some of them — I have a plan "B".
First, we need to consider three parties: Service S, Client C and "Middleman" M; Middleman is able to spy on all communications between C and S. Apparently, M would not be able to impersonate C only if C has certain "benefit" over M. Not breaking the level of generalization, let's assume that the benefit is certain key C receives in its deployment bases on user authentication. The full source code of client can be open, only a key is secret.

Now, let me assume you know the method of deployment of the key to all clients even over Internet (without SSL) the way M cannot get this key even it it spies all the time. I assume that because this is a well-known method. I you're not sure it's possible, read this: http://en.wikipedia.org/wiki/RSA[^]. If your not convinced yet, I'll explain that on you request.

Now, I'm going to do the easiest assumptions on communication method. 1) It should be session-based non-secure protocol (HTML or TCP), 2) The session is divided in two parts: authentication followed by trusted; during authentication part client and service exchange messages used to proof authenticity of the client; after that, client is considered trusted and further work is done without any encryption. You did not require secret data communication, only authenticity of the client. If these two assumption are not OK, I can discuss plan "B" on further request.

Now, let's use same very RSA and create two keys. Further speculations are meant to maintain that the method is as strong as RSA. RSA is implemented in .NET. Let's follow the steps.

1) Generate two keys using RSA key generation function RSA => (Ks, Kd).
The function has no "backdoor": it is not possible to calculate one key base on knowledge or another key. I'll call Ks a "encrypting" key, Kd — a "decrypting" key:


(unencrypted data, Ks) —> (encrypted data)
(encrypted data, Kd) —> (unencrypted data)


2) Let's deploy Kd with C.
At this step, S has Ks and Kd, C has only Kd, M has not keys or data.

3) S starts, listen to connections, C connects, S accept (new) connection.

4) Authentication part of session protocol started. S generates "Authentication Token" Tu (unencrypted) and encrypt it into encrtypted token Tu:
(Tu, Ks) —> Ts, and sends it to a connected client C. New Tu is generated randomly for every new session.

5) C use Ks to decrypt Ts:
(Ts, Ku) —> Tu.

6) C sends Tu back to S openly, S compares its values with the value stored before sending it to C. That creates an evidence of C. Trusted part of protocol starts.

7) At this point M has both Ts and Tu. It cannot be used for impersonation of C, because it would require to connect to create a new session; but for this new session Authentication Token will be new, not known to M. Also, as there is no RSA "back door", M cannot obtain any of the keys from data.

If there is a reason to concern about open sending of Tu from C to S, this part also can have plan "B" based on additional pair of keys (one of them will be open and known to M to make this part of communication a secret from M.

That's it. Any concerns, further questions?

—SA
 
Share this answer
 
v9
Comments
Sandeep Mewara 17-Feb-11 5:34am    
Wooo! 10+

Bookmarked... need to give concentrated time to understand all.
Sergey Alexandrovich Kryukov 17-Feb-11 19:19pm    
Thank you, Sandeep.
This is not really difficult, the clear identification of goals here is a major concern.
--SA
Sandeep Mewara 17-Feb-11 5:34am    
BTW, comment from OP:
Hello SAKryukov,

first of all, thank you for your considerations.

Concerns? Yes.
I understand the way how the keys are exchanged. But the problem still is, that someone could write a fake client, which looks for the service like the real client. The faked client could also implement the key exchange protocol and so be treated as our client. So my point is not to secure the communication itself but to proof the correctness of the client against the server (service).

As I wrote:
'to ensure, that only our client software can talk (send data) to the web service.'

Or do I miss the point? It would be nice if you could clarify this.

Thanks.

Thom
Espen Harlinn 17-Feb-11 9:31am    
A very good effort, my 5++
Sergey Alexandrovich Kryukov 17-Feb-11 19:21pm    
Thank you, Espen.
Let's see how it will finally resolve. Quite interesting Question, anyway.
--SA
I found a part of the solution by myself so I post it here as answer.

I've to use a client certificate for Authentication.

I have to set the 'Client Credential Type' to Certificate. I also found how to use a certificate from a file and not from registry: An easy way to use certificates for WCF security[^]

But again there are 2 questions open:
1.
Can I use for this also the already available code signing certificate? I think not because the client needs the private key of the certificate and this is something I will not give out.

2.
How do I make sure that no other program uses my certficate to identify itself against the server service? I need to copy the certificate to the client computer and so, everyone could use it (or simply post it in the inet for everybodies use). I know I can protect the certificate with a password but this password must be then inside my exe which can be decompiled.

What is the complete solution?

Thanks
Thom
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-Feb-11 13:43pm    
I answered your questions in my comment to my Answer, please review it, then respond.
Again, available certificate will not help.
What really can make your application to be different is if you sign the application with the same key used as a proof of its ability to decipher the Token. Modified client application will not be able to run at all, newly created fake client application will not be able to decipher the Token.
--SA

Part 2



This is a different Answer based on clarification of the problem. Previous Answer is named as "Part 1", this one will be "Part 2".
The Answer in Part 1 remains valid, but it's based on the assumption that a trusted channel for distribution of software certificate can be created. Initial requirements (no SSL, etc.) are related only to the Service and Client run time when client software is already deployed; there were no limitation on the mechanism of deployment.

According to the clarification, Client software is freely distributed to some anonymous clients, so there is no way to distribute any information secret from third party, which opens the possibility to forge Client software with modified behavior which could mimic the same authentication procedure a legitimate Client software can pass. How that is possible? 1) It is useless to spy on network package during exchange of Authentication Token, because these packets are used only once (see Part 1), 2) it is not possible to modify original Client software keeping its digital signature, because the assemblies can be signed and a private key is stored at software team only. Nevertheless, it's possible to run Client software under debugger and capture the Ku key before decryption of the Authentication Token.

That leads to one obvious solution which I don't really like. The client software should be protected with one of the powerful software protection tools which, in particular, make both code analysis and debugging impossible (I have experience working with XHEO Code Veil, http://xheo.com/products/code-protection). The problem is that powerful solutions are proprietary. The real problem is not even license and royalty costs which can be considerable, but the lack of opportunity to evaluate strength of protection and validity of company's claims. That will solve the problem in principle, but again, it doesn't make me satisfied.

Unfortunately, this is inherent problem of the approach when the modification of Client software is freely distributed and the possibility of the modified Client behavior presents a threat. I already expressed my concern: this can be considered as the bigger architectural problem, a fragility of the general data model. However, I clearly realize that rethinking of this model can be not feasible.

Part 3



The schema with software protection (Part 2) was actually a combination with Part 1, a plan "B". I think the problem needs a radically different approach, plan "C". It should not require global change in the architecture and sit in the thin communication layer between Service and Client.

My idea is moving all business logic from Client part to Service, where it is not accessible for modification. This is relatively small modification of the architecture. There can be different approaches.

One obvious approach is transforming of the application into ASP.NET tier to represent the complete communication layer between Service and Client. This is quite doable. The potential problem is significant change in client capabilities due to limitations of HTTP protocol.

Alternative approach is to stay with regular UI-enabled client working through the transport protocol, but cleared from business logics, which is moved to the Service-part counterpart. Here I have some preliminary schemas which need some extra thinking.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900