views:

351

answers:

6

For example, if the user has JavaScript enabled, we send hash his password and send the hash. If not, we send the password unhashed and a flag to mark that it is unhashed. We then build the hash (if it's unhashed) and compare it to the stored hash.

This seems to be secure and simple. Why isn't it a popular way to send a password? Did I miss something?

In another word: why better is lose hash then unhashed password? (imo most of us have only few passwords to many sites)

+1  A: 

Note, that if you only hash the password, the hash is going to be exactly the same each time.

You should rather use some kind of challenge/response mechanism similar to APOP in POP3 protocol

Pawel Lesnikowski
but password is exactly the same too...
Rin
@Rinz: then send a challange together with the login form.
Joachim Sauer
Challenge should change each time the user logs in (use thread id, timestamp)
Pawel Lesnikowski
+2  A: 

Then I just wiretap the hash and log in with that?

If you're concerned about security you should be using SSL. Then you can just send the password as is.

Also, SSL proves that the server they're logging into is not someone impersonating you.

wefwfwefwe
Agreed. Certs are so cheap now, why lose sleep over it?
Don Branson
+4  A: 

JavaScript can always be tampered with. By hashing the password using JavaScript you at least are exposing your rules on how to store passwords. From a hacker perspective it's the same thing to catch the real password and send it to you system or to catch de hashed password and send it to your system.

If you really need to improve password security I would recommend using https and hashing it at Server side. Don't forget to use a salt key.

Sergio
A: 

See Perl/Javascript MD5 Secure User Authentication for an implementation and discussion.

Sinan Ünür
+1  A: 

You're making your job more complex than it is. Just send the password as plain-text, a hash won't improve security in any way. (See other's answers)

If you use the same hashing algorithm for storing the passwords in your databases, you actually decrease security. Because if someone can get the hashed passwords from it, he can use them to authenticate himself. (He doesn't have to dehash them) If you have SQL injection or other information leaking problems on your website, this will be the case.

svens
+8  A: 

The real problems here are man-in-the-middle attacks, where someone sniffs what comes down the wire. It doesn't matter if you send the hash of the password or the password itself, if someone downstream can read this, they can log in as that person. The only secure option is to use SSL to stop anyone but the server from being able to decrypt the password-hash/password.

JonoW
well SSL can be circumvented too. There is a man-in-the-middle to do that
mfeingold
With challenge/response you can deal with this issue.
Pawel Lesnikowski
mfeingold - Yes SSL can be circumvented by the proxy tricking the user to post their details under http:// rather than https://, but if a user is smart enough to ensure they are logging in on a page that has a valid certificate of the site they're on, the proxy cannot get their password. Obviously not all users would know to check this. It may not be 100% fool-proof, but it's as good as it gets.
JonoW
SSL is secure. However, as JonoW explained, it can be circumvented by "automated" social engineering - but only by that. Then again, that's probably enough. :)
Ilari Kajaste
Ilari, there is recent news that makes "SSL is secure" require a caveat: http://www.cgisecurity.com/2009/11/steve-dispensa-and-marsh-ray-have-published-a-paper-describing-a-weakness-in-the-tls-negotiation-process-from-the-whitepaper.html
micahwittman