Any advice on storing passwords securely?
Nov. 20th, 2011 07:01 pmI'm currently adding Wordpress support to my link poster. And I've hit a hitch with passwords.
LJ's security means you pass the username and MD5(LJChallenge+MD5(Password)) - where LJChallenge is retrieved for each call you make. This means that I can store the MD5 of the user's password rather than storing it in plain text. While I am completely trustworthy, it's nice that I can browse the datastore and check things look ok without accidentally seeing people's passwords.
Wordpress, on the other hand, uses the MetaWeblog API for posting. Which takes the user's password in plain text.
Which means I can't hash the password when it's submitted, I have to store it in a way that I can return it back to its true value when required.
Anyone got any suggestions for what to use for this that's reasonably secure?
(I'm working in Java, which seems to have libraries for just about everything, if that helps.)
Edit: I've submitted a suggestion to DW and LJ to support OAuth. Can't see it happening this week though.
LJ's security means you pass the username and MD5(LJChallenge+MD5(Password)) - where LJChallenge is retrieved for each call you make. This means that I can store the MD5 of the user's password rather than storing it in plain text. While I am completely trustworthy, it's nice that I can browse the datastore and check things look ok without accidentally seeing people's passwords.
Wordpress, on the other hand, uses the MetaWeblog API for posting. Which takes the user's password in plain text.
Which means I can't hash the password when it's submitted, I have to store it in a way that I can return it back to its true value when required.
Anyone got any suggestions for what to use for this that's reasonably secure?
(I'm working in Java, which seems to have libraries for just about everything, if that helps.)
Edit: I've submitted a suggestion to DW and LJ to support OAuth. Can't see it happening this week though.
no subject
Date: 2011-11-21 04:18 am (UTC)S, y'know, if it'd help this project along anyway ;-)
no subject
Date: 2011-11-20 07:16 pm (UTC)But that also means that the MD5 of the password is all an attacker needs to steal in order to authenticate as the user, of course. You only need the real password if you're authenticating via the real client – but a bent client could bypass that stage and directly use MD5(Password) just as your own code is doing. So the same care you're intending to apply to the plaintext Wordpress passwords should also have been applied all along to the hashed LJ ones!
no subject
Date: 2011-11-20 07:19 pm (UTC)Obviously all security is ephemeral, so the question is, how do I encrypt/decrypt this stuff as necessary, while making sure that someone else running off with the contents of the database can't use it?
no subject
Date: 2011-11-20 07:29 pm (UTC)I need to store the data, the method of encrypyting it, and the key in the same place, or it can't work automatically. It seems impossible to me that you could actually have security in this case.
Hence me wanting advice :->
no subject
Date: 2011-11-20 08:04 pm (UTC)At work we encrypt credit cards using PGP, and the public key is available to any code, but the private key is only available to one user (and root, obviously), on a very locked-down box that only talks to the credit card company. That works because we sometimes want to say "charge that card again" (in which case we pass the encrypted version to the payment gateway, which decrypts it before passing it on), and we sometimes want to say "was this card ever used?" (in which case we look at an MD5 hash we also store), but we never need to know "what's the plaintext version of this credit card?" so we're safe.
no subject
Date: 2011-11-20 08:10 pm (UTC)But by the time you've deleted every single entry, I guess it doesn't matter anymore who has control...
But notice that the MD5 of the password itself is never sent. So an attacker must have control of one of the endpoints to get that information.
no subject
Date: 2011-11-20 07:25 pm (UTC)no subject
Date: 2011-11-20 07:28 pm (UTC)And yes, OAuth would make my life harder, but would be more secure.
Still better than MetaWeblog, which takes plain text, of course.
no subject
Date: 2011-11-20 07:47 pm (UTC)There's a bunch of libraries out there for OAuth, so I shouldn't imagine it'd really make your life too much harder. Once the handshake's done, you just sign your request with the token, which amounts to a similar sort of situation. But yeah, beggars can't be choosers.
Do they at least do it over SSL ..?
no subject
Date: 2011-11-20 07:49 pm (UTC)Wordpress use http://andrewducker.wordpress.com/xmlrpc.php
So, no.
no subject
Date: 2011-11-20 07:50 pm (UTC)no subject
Date: 2011-11-20 08:15 pm (UTC)http://en.blog.wordpress.com/2011/07/07/oauth2-support-developer-resources/
no subject
Date: 2011-11-20 08:00 pm (UTC)I assume you need to provide their username and password for each API call? So effectively their plaintext password is going to be easily available from pretty much everywhere in your code? Yeah, you're fucked.
If you want to claim the stuff's encrypted, you could use e.g. PGP, and that might help if the encrypted passwords are in a database, the private key's somewhere else, and only the database gets hacked. It's a long shot, though.
no subject
Date: 2011-11-20 08:03 pm (UTC)Someone on Twitter already suggested just running it through ROT13 (and back when I need it) :->
And yes, I agree, fucked. It would be better if they supported OAuth (as
no subject
Date: 2011-11-20 08:14 pm (UTC)http://en.blog.wordpress.com/2011/07/07/oauth2-support-developer-resources/
no subject
Date: 2011-11-20 10:11 pm (UTC)Just brute force the MD5 passwords back to the original text and store that, it'll save you time later when you have to adapt to them using salts and other such things to compensate for not using bcrypt2 properly in the first place.
no subject
Date: 2011-11-20 10:12 pm (UTC)no subject
Date: 2011-11-21 09:03 am (UTC)WP is yet again demonstrating that it's a POS that doesn't consider security properly *sigh*
no subject
Date: 2011-11-21 09:36 am (UTC)How does Drupal do clients/remote posting?
no subject
Date: 2011-11-21 09:42 am (UTC)(Unless I'm misunderstanding this: http://drupal.org/node/295 )
no subject
Date: 2011-11-21 01:56 pm (UTC)Also it's been pulled :)
A 3-digit page ID on d.org though... wow. That's ancient.
no subject
Date: 2011-11-21 01:57 pm (UTC)There's an Oauth module for Drupal.
no subject
Date: 2011-11-21 01:58 pm (UTC)Glad it's been pulled, what do clients use nowadays instead?
no subject
Date: 2011-11-21 02:07 pm (UTC)no subject
Date: 2011-11-21 02:08 pm (UTC)That does make things simpler.
no subject
Date: 2011-11-21 02:13 pm (UTC)Part of the problem with Drupal is that features like that were still kicking about in Core, but totally untouched by Core devs who are off busy building sites for Sony and the White House and so do more hardcore stuff. Hence wither away and because they're in core it's hard to work on them.
BlogAPI was pulled for D7 IIRC, and Blog itself was pulled recently, so it now lives as a contrib module where it should get more attention from interested parties.