0

Recently, We developed an application that we want it's users to pay for a monthly subscription in order to use it. So the first thing that came to our minds how to implement a secure way for our application to check for the User validity and those ideas came up

  1. Using WebClient to enter to our website and Login using the user provided credentials : However, this might be vulnerable to MITM attack.
  2. Using the first approach but using SSL certificate (to make sure that we are connecting to our server and not the attackers') : However, Fiddler can easily do a MITM attack and decrypt the SSL communication, which will result in the same vulnerability as the first approach.

Due to the internet's lack of documentation of what we need, we had to ask here for someone to explain how could we make sure that:

  1. Our application only connects to our server and not any fake hosted server (by the attacker).
  2. The communication is secure. Not altered or edited some how in order to grand unfair access to our application. (by sending a fake response to the app or editing the original response before the application receives it).

Note: we totally understand that the attacker may just deobfuscate the application and do whatever he want to it. So we are planning to get a goodobfuscatorin order to at least make it harder for the attacker to do so.

Roman Ratskey
  • 5,101
  • 8
  • 44
  • 67
  • 1
    "Fiddler can easily do a MITM attack"... no, it can't. The user has to explicitly approve the fiddler root certificate as trusted, and there are big, fat warning signs telling them that it's a really bad idea. – spender Mar 17 '14 at 02:12
  • @spender: That doesn't matter; the user is the enemy here. – SLaks Mar 17 '14 at 02:13
  • Indeed. My preference would be to keep the gold on the server. The client is intrinsically untrustworthy. Make users pay for data-access, not for the app itself. – spender Mar 17 '14 at 02:14
  • @spender: the problem is that the application is not designed to depend on a server. and this is why we are trying to at least implement a secure login system. – Roman Ratskey Mar 17 '14 at 02:17
  • @spender Also will creating a socket server that handles some functions (to make the application depending on our server) be vulnerable to the same things like MATM ? – Roman Ratskey Mar 17 '14 at 02:26
  • IMO, http is really the only really reliable protocol. A socket is just as vulnerable to mitm as any other transport, but you're increasing the chance that your users may not be able to connect (in particular if they're sitting behind a corporate firewall). – spender Mar 17 '14 at 02:30
  • Fiddler part of question is covered here - [What is point of SSL if fiddler 2 can decrypt all calls over HTTPS?](http://stackoverflow.com/questions/10808930/what-is-point-of-ssl-if-fiddler-2-can-decrypt-all-calls-over-https/10808950#10808950) – Alexei Levenkov Mar 17 '14 at 02:55

1 Answers1

1

You can use SSL Certificate Pinning.

Set the ServerCertificateValidationCallback to only accept your certificate's public key, or one of its signers. (this means you can never change certificates)

This will completely prevent SSL MITM (which works by using a different certificate and making the computer trust it).

Of course, it doesn't prevent attackers from cracking open your app and bypassing the check altogether, especially if you store local state.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • can i have a small conversation with you regarding this topic, because i have some questions. I wont take a lot of your time btw :p – Roman Ratskey Mar 17 '14 at 02:15
  • so... by using the certificate pinning, i can make sure that the problems described at the question is eliminated (like the editing and altering of the requests and so on ?) – Roman Ratskey Mar 17 '14 at 02:57
  • +1. HTTPS with client certificate is easy and secure solution to authenticate both sides. @RuneS - Note that you trying to build more security than even all bank sites require - you'll need to understand what threats you trying to prevent - much bigger topic than single SO question can cover. – Alexei Levenkov Mar 17 '14 at 02:59
  • @RuneS - no, you will only make it a bit harder (i.e. Fiddler needs additional configuration to supply client certificate) - you can't really prevent user from seeing/altering its own traffic. – Alexei Levenkov Mar 17 '14 at 03:00
  • @AlexeiLevenkov i am not saying `PREVENT` but make it as much harder as it can. – Roman Ratskey Mar 17 '14 at 13:04
  • I mean will using Certificate Pinning make me at least 80% sure that the connection between my application and the website is secure enough and prevent replay attacks (aka MATM or Fake Server attacks). – Roman Ratskey Mar 17 '14 at 13:07
  • @LaJmOn: Of course. However, that requires modifying the client application, as I said at the end of my answer. – SLaks Mar 17 '14 at 16:04
  • @RuneS - **you** need to understand your requirements. So far you trying to find a way prevent user from tampering with user's own traffic - there is not much to do here short of hardware (i.e. machine itself like remote desktop on your servers/Xbox/PS/Nintendo/... or physical keys/smartcards) which gives client identity. Side notes: your security concern about Fiddler able to decrypt SSL traffic is misunderstanding, unclear what you mean "MATM" (probably [MITM](http://en.wikipedia.org/wiki/Man-in-the-middle_attack)) – Alexei Levenkov Mar 17 '14 at 16:04
  • Note my comment above about client cert was misunderstanding of @SLaks's answer - suggestion is to verify server's cert. Client certs could help identify client but not be much better than regular HTTPS without a lot of efforts to build more secure solution in non-friendly environment. – Alexei Levenkov Mar 17 '14 at 16:13
  • I am really new when it comes to security, But what i need is not preventing the user from tempering with his own traffic but with the traffic of my application (you know the replay attacks ?) when someone records the response received by my application (a valid response) then creates a fake server that mimics mine and just keep replaying to my application with the same thing over and over granting himself an access to the application.. – Roman Ratskey Mar 17 '14 at 16:16
  • @AlexeiLevenkov so obviously and very shortly what i need here is a secure way to check whether the user has valid account through my website that makes sure (at least 80%) that the only way to use my application for free is to CRACK it not just playing with the packets to fool it and gain access. (as i seen such thing happening to some applications) – Roman Ratskey Mar 17 '14 at 16:18
  • @RuneS now I see what you trying to do - good luck with that - building software licensing is hard. Indeed SLaks's suggestion is very good for your case (assuming client code is not modified). Note: it would be so much easier to implement if you actually serve some useful dynamic/computed data required by your app from your server ... – Alexei Levenkov Mar 17 '14 at 16:33
  • @SLaks won't you speak to me a little bit about the approach you pointed me to ? – Roman Ratskey Mar 17 '14 at 17:09
  • What is your question? – SLaks Mar 17 '14 at 17:30
  • @SLaks Will using Certificate pinning guarantees me that the connection is encrypted and it is hard to alter\edit the messages sent between the application and the website. Also how can i make the `HttpClient` only accepts my certificated through it's public key ? – Roman Ratskey Mar 20 '14 at 17:31