Adding the ruby tag because this is also a good example of quickly analyzing encrypted data in Ruby.
I’m really impressed with this, but then again I don’t do much reverse engineering.
Seems like the vulnerability in Snapchat could be mostly mitigated by preventing the MITM with the use of some kind of certificate pin within the Snapchat client.
I’m curious whether it’s common practice to pin the actual cert or to just pin the known CA cert to verify against? I think it’s enough to pin the CA cert for most applications, since you are already implicitly trusting your CA not to grant a cert representing your entity to another party. Using a self-signed certificate and pinning it would also be a solution I think.
But if you are a mobile developer using HTTPS for network communication I’d be interested in what you have implemented.
You’re correct about the two possible solutions. Moxie wrote a great article explaining how to do this for Android applications.
The choice of using a self-signed certificate or trusting a single CA certificate depends on the traffic profile of your application. If your application only talks to servers that you control, it’s in your best interest to take the time and generate self-signed certificates. If your application needs to talk to servers outside of your control (such as a browser or IM client), trusting a single CA certificate is the way to go.
If the server is out of your control even pinning the CA cert is a little risky. The owner could install a new cert signed by a new CA at any time. I would recommend against this unless you have some assurance from the service provider that the CA won’t change.
I believe you could work around this by trusting a wide set of known, good CAs. Basically whitelist all the legit CAs - So if the owner changes from Verisign, to Digicert, for instance, you won’t have to change anything. But it does prevent someone malicious from trying to install an self-signed CA.
I always feel like I’m missing something when I read an article that involves installing a CA on the victim’s phone/computer. If you have that kind of access, aren’t there a myriad of other things you could do? Can someone help me understand why things like this are notable if they require installing a CA like this?
Installing the certificate on his phone was just a way to fool Snapchat into validating his proxy that he setup. The “victim” here isn’t the owner of the phone, it’s the application itself.
It’s interesting to note that a user can essentially bypass SSL out from under an app; this might not be that exciting to MITM yourself for most apps, but for Snapchat it allows the user direct access to the data they’re trying to restrict from the user.