Semisecure Login Reimagined

Prior to WordPress 2.5, I’d been using a plugin called Semisecure Login. This plugin would encrypt your password when logging in via a one-way md5 hash and compare this to your password’s md5 hash on the server side (prior to WordPress 2.5 passwords were stored in the database as md5 hashes). A nonce was thrown in for good measure to help prevent replay attacks. This, effectively, provided a “semisecure” login environment. It obviously wasn’t as secure as using an SSL cert (it wouldn’t prevent session hijacking, etc.) but I liked it.

With the release of WordPress 2.5, passwords are now hashed up by phpass before entering the database. Further complicating the matter, phpass salts each password before hashing. This change effectively “breaks” Semisecure Login. Using a plugin, it’s possible to revert back to the md5 hashes, and Semisecure Login for WordPress 2.5 takes advantage of this.

On the other hand, I wanted to keep using the new phpass hashes and still provide a semisecure login environment. This thread details the difficulty in making this happen. There didn’t seem to be any way to use one-way hashing, and using standard secret-key encryption was out (for obvious reasons). The only thing that left me with was to try and use public-key encryption.

RSA is a popular public-key algorithm, and I was able to find a few implementations in both JavaScript and PHP. My main criteria in picking which implementation(s) to use were (1) interoperability between JavaScript and PHP, (2) efficiency, speed, and performance and (3) a solution that would work for most shared hosts. I ended up settling on the jsbn library for JavaScript and OpenSSL on the PHP side. Unfortunately, PHP’s built-in openssl functions are rather limited when it comes to generating RSA keypairs, so I had to rely on making calls directly against openssl when generating a keypair. This works great on a Linux server but is currently untested on Windows (although I have a feeling it would work as long as the folder where OpenSSL lives was added to the system path).

Download
You can download Semisecure Login Reimagined at its official Wordpress page. Additional information, such as installation instructions and changelog, are located there as well.

Requirements

  • Wordpress: 2.1 to 2.5.1 (2.5.1 is the latest version at the time of this post)
  • PHP: 4 or 5 (tested as far back as 4.4.6 and up to 5.2.6)
  • OpenSSL (initial keypair generation is handled by direct calls, while decryption is handled by built-in PHP functions)

All tests were performed on various Linux servers. PHP’s program execution functions need to be enabled for the initial keypair generation (safe mode should also be disabled for this). After the keypair is generated, it’s safe to go ahead and re-disable these functions and/or re-enable safe mode. Everyday use of this plugin relies on PHP’s built-in openssl functions.

Update (6/13/08)
As of v1.1.0, keypair generation will work even if safe mode is enabled or the PHP execution fuctions have been disabled. This alternative keypair generation mode will only work if you’re running PHP 5.2.0 or greater, however.

Leave a Reply

19 Comments

  • kiran (Jun 05, 2008)

    Hi MOggy.. I love the way u themed your blog (purplemoggy). Love
    the creative work involved. Since i was i addicted to it, i tried
    to make my blog look similar to your blog. PLease give a flash to
    it and please comment http://restrike.blogspot.com/ Hope u wont be
    angry for doing it without your concern. Regards Kiran

    Reply

  • moggy (Jun 05, 2008)

    Looks good, kiran.

    Reply

  • kiran (Jun 07, 2008)

    Thanks Moggy… Could u please help me with the social bookmarking
    stuff? i cant get that attached with my posts. thanks again Kiran

    Reply

  • Dave Brondsema (Jun 24, 2008)

    Thanks for working on this and making a plugin that works with 2.5!

    Reply

  • Trackback (Jul 05, 2008)

    Leonaut.com

  • baron (Jul 24, 2008)

    hi. Thanks for plugin perfect. Regards

    Reply

  • Philix (Jul 28, 2008)

    This is a cool plugin

    Reply

  • Trackback (Aug 30, 2008)

    Poojan Blog

  • JeKoPhoto (Mar 03, 2009)

    Moggy, first I want to thank you for this great plugin! It is a
    really good choice for those who are not able to use ssl. Did you
    thought about encrypting the username too? I think this could
    improve the level of security. So there would be absolutely no
    login information which goes unencrypted through the net and an
    possible attacker did not know the half of the needed information
    ;-) Would be interested what you are thinking about. Cheers, Jens

    Reply

  • m0rebel (Mar 08, 2009)

    I recently discovered this plugin and it’s awesome! I have a
    computer security blog and I just wrote a post recommending it.
    Check it out:
    http://blog.banditdefense.com/2009/03/08/wordpress-password-security-on-a-budget/

    Reply

  • moggy (Mar 09, 2009)

    Jens –
    The default cookie(s) that WordPress uses stores your username as plain-text. So there’s no point in encrypting the username when logging in since it’s going to be sent “over the wire” 3 seconds later anyway.

    Reply

  • JeKoPhoto (Mar 09, 2009)

    Moggy, thanks for pointing that out – I was not be aware of this by
    now. In fact it would be sensless in this circumstances to en- and
    decrypt the username. Thanks again, Jens

    Reply

  • Álvaro Degives-Más (Mar 14, 2009)

    Hi Moggy, the plugin is really awesome. Thanks so much! I have a WP
    based site I maintain for a non-profit, which gives me a puzzling
    error upon activation of the plugin:

    Parse error: syntax error, unexpected ‘;’, expecting ‘)’ in
    /[path-to]/public_html/wp-content/plugins/semisecure-login-reimagined/SemisecureLoginReimagined_RsaKeys.php
    on line 73

    I can’t figure out what’s going wrong there… It
    activates, but seemingly won’t generate the keys, no matter the
    setting I choose. Could you point me in the right direction?
    Server’s running PHP5.2… Dunno what other info might be helpful
    to you. Thanks in advance!

    Reply

  • Álvaro Degives-Más (Mar 14, 2009)

    Scratch that… I installed the previous version (1.4.0) created
    the keys, upgraded to the current, problem solved. :-) Works like a
    charm. Thanks!

    Reply

  • moggy (Mar 16, 2009)

    Sorry about that. Looks like there was a typo. I just pushed an update to fix the issue.

    Reply

Recent Comments

  • moggy: Do you have a phpinfo page? Does it list openssl? If not, it’s possible to install...
  • Micah: Does this plugin not work with Windows servers? It’s referencing OpenSSL but...
  • Chantak: Can you add the Poly1305-AES encryption in your plugin? The link is:...
  • Micah: I actually did set the nonces option to async and that didn’t work. I tried to...
  • moggy: @Micah — Thanks for the report. If you disable JavaScript in your browser you should...

Archives