Secure website-authentication using GPG keys

Posted on Dec. 9, 2007 by Ben Dickson.

This is an old post from 2007. The content may be outdated or no longer relevant.


This is an old post I wrote, which was originally posted on neverfear.org on Sun, 9th Dec 2007 23:00:43. Archived here for posterity.

There are 10 comments on this post.


Overview

Currently, most websites log you in the same way: You enter a username and password, the web-server hashes the password (generally via MD5(), or SHA1()). This hash is then compared to the one stored in a database - if it matches, the user knows the original password, so it logs them in.

This method has numerous problems, such as the password being sent unencrypted to the web-server, and the fact many users reuse passwords, if an intruder works out a users password (though any means), there is a good chance they can log into the same users email account, online banking etc etc..

The whole username/password login method has many flaws, most are down to the fact most people struggle to remember a single 5-6 character password, let alone multiple random messy looking passwords such as "Xm2K?pdT&av", as most "good password guides" suggest.

GPG ("GnuPG"/"GNU Privacy Guard") is a free/open-source replacement for PGP (archive.org link) . I won't go into what GPG is, since I guess quite a lot of the people reading this already know, however if you do not, it is primarily used to sign or encrypt email messages - see the Wikipedia page on it (archive.org link)

Back to website-logins. When you enter a username/password into a website, you are basically trying to prove you are you, but with this method, you are only really proving you know the password - something that is surprisingly easy to capture. GPG is far more secure than a simple password, as it uses a public/private key system - anything signed/encrypted by GPG is effectively using a 4096 character password, and you never send your password anywhere; only you can sign a message with your private key, and others verify it using your public key.

Since GPG is basically used as an identity-verification tool, it seems logical to use this to prove who you are. You give the site your public key, it gives you a random string, you sign it with your private key and it knows what key-owner signed the string. No private data (private key or password) is ever transmitted.

Steps

Problems

Implementation

This is just a concept currently, I haven't tried to implement this yet. The biggest hurdle currently seems like the connection between the webpage and the GPG system.

The most obvious method would be system() calls to the "gpg" binary. This would be cross-platform and fairly easy to implement, but does raise possible command-injection security problems (admittedly these are easy to prevent with input-sanitisation).

There is a GPG extension for PHP (called GPGext), which would certainly make implementing this far easier, but I always preferred native implementations over extensions that require shared libraries in system folders and such. There are similar libraries for various other languages commonly used for server-side programming (Perl/Python/Ruby/etc)

Alternatives

Conclusion

For most sites, this is fairly overkill in terms of security. For "normal" users it's complicated - setting up GPG alone is beyond a lot of people. But, for certain sites (very technically-oriented sites, like NEVERFEAR), where the users are very technically competent, it really becomes a matter of do the users really care enough about their account's security?

Taking NEVERFEAR as an example, I'd imagine, no. The most a malicious user could achieve would be to make or delete that users posts - something easily undone.

There are two important things when it comes to security systems. First and most obvious, is the actual security improvements, and second is connivence. If the security improvements aren't worth the reduced convenience, it's not going to be popular.

The security improvements are fairly substantial. SSL for a site like NEVERFEAR isn't practical. With the GPG login system, SSL would be more or less unnecessary, since no passwords are ever sent, and the "signed-message" used to login is invalid once the user has used it once.

The problem is, are these security improvements worth the hassle of having to use GPG every time they want to login? With the regular username/password system, browsers have built-in functionality to remember passwords, so all they have to do is click "Login". Compare this to having to copy a string, run the GPG command, enter their GPG pass-phrase, paste the string, copy the output to the page and click "Login"..

That's not to say if the method would ever popularised, it couldn't be made much easier (By having it built into the browser, or with browser-extensions) - but the possibility of that happening is nearly zero, so the benefit of only having the GPG password to remember is no longer valid (as you still need to remember passwords for every other site on the internet..)

I may make a test site, to prove the concept, but I don't see it progressing much more than that.

One last thing - this GPG auth system is applicable to any system that can deal with text being sent/receive. IRC for example. This may be a more plausible testing ground for such a concept. Many networks use their own NickServ auth systems, and it would be fairly simple to add a GPG-Auth command to the services, without disruption regular /msg NickServ identify commands. OperServ would benefit most greatly from this, as it would help secure the fairly powerful oper logins, and opers are always going to be very technically competent. The fact IRC clients are also very easily scriptable helps too.