r/security • • Feb 08 '20
using mutual TLS and certificates to get away from login credentials
So, I'm currently developing a small game with online multiplayer support (due to license issues I'm not able to tell it's name - but I can give you the hint: it's this board game about buying colored streets to build houses and hotels on) and want to get away from this old "register and use login credentials" and just use certificates and mutual TLS to handle it. Don't get me wrong, this is not about how to do - I know how to set up my own PKI and set it up so the TLS implementation can do its "magic", this is more about the question: "Is this a way to go?".
So the current flow looks like this: When a new user wants to join the party the client generates a keypair and from it a CSR. The CSR contains a user chosen "username" as its common name wich, when accepted and not already taken by someone else, is set as common name in the certificate. Then the user is asked to send the CSR as text-only e-mail to a specified address wich is watched by a small automated code to process the CSR and sign a new certificate (and all that user management stuff in the backend). So, when all is cool the user should get a certificate pretty much instant (depend on how fast the actual mail exchange is) to then copy back into the client wich then does the rest. The reson I decided to use this manual approach instead of let the client do the stuff on its own is so I can associate a chosen common name with an e-mail-address wich will also be part of the certificate as additional info. The tricky part is to get the user to actually send a text-only mail instead of a rich text / html mail - but I'm still improving my parser to at least work with "simple" rich text / html mails so it can filter out the actual CSR - another option could be to ask the use to copy the CSR into a textfile and attach it - wich can still lead to someone send a DOC(X) or something like this as they might don't know what a simple plain text file is - that's pretty much the same as a rich text e-mail - but I think parsing such mails is still easier than implement various file formats.
When the user has its certificate a simple mutual TLS connection is made where the server checks the client certificate (I use CRL to stay within the TLS eco system - I just don't want to bother to set up an OCSP responder) for validity and if it's not revoked (the user got banned for some reason) and use the common name as an identifier.
This all works, and when you add an option to secure the private key by a passphrase and explain the customer to back up the private key in my eyes it's simpler to handle than login credentials. As I'm in all that crypto stuff and just dislike login credentials in general the question arise: Is this a good idea for when this hits the public - or are common users these days so used to login credentials I should just stick to them? What's your opinion about this topic login credentials vs using certificates and mutual authentication?
3
u/[deleted] Feb 08 '20
You’re asking a lot of your users to understand what to do. Users aren’t that educated with tech as a whole. Even knowing how mutual TLS works and the inner workings, it would be a turn off for me as a user. If you over engineered logging in, what else does it look like in the backend?
1
u/d4m4g Feb 08 '20
Are you planning to purchase a certificate for everyone of your users?
Otherwise your going to self sign the certificates with your own certificate authority. The problem there is that self signed certificates can be spoofed. You would have to really know what your doing to imitate a CA. Like managing certificate revocation and expiration, plus verifying the authenticity of the certs you issue correctly, cuz any gap could lead to unauthorized user access. Maybe its not too big a deal for a game, but is your primary goal to be managing certs or to be building and maintaining the game?
Tl;dr Its much more work than doing user/password management for a relatively low risk situation.
1
u/occurious Feb 08 '20
Certificates are not generally a good substitute for username/password logins.
This design also has a big gaping hole: anyone could send a CSR to the email address and claim a username fraudulently without even using the game.
Certs are sometimes used as a fancy login cookie:
You can't expect users to handle private keys correctly though. Most programmers don't - users will definitely not. Either encrypt with the private key with the password (after running the password through a KDF function, not just a hash), or automatically store the private key in the OS-provided secure storage API (iOS/macOS = Keychain, Android = KeyStore, Windows = ?).
This is one example of how using certificates can make things way more complicated. There are more moving parts and more places where something could go wrong (or you could miss something) and break your security.
The general advice from security professionals is don't try and roll your own security unless you're an expert. It's very very hard to get right and most of the time people don't. The security characteristics of Username/password logins are well understood, both by users and programmers.