views:

506

answers:

11

As much as I understand it is a good idea to keep passwords secret from the site administrator himself because he could try to take a user's email and log into his mailbox using the same password (since many users use the same password everywhere).

Beyond that I do not see the point. I know it makes more difficult the dictionary attack but... if someone unauthorized got into the database, isn't it too late to worry about passwords? The guy has now access to all tables in the database and in a position to take all the data and do whatever he wants.

Or am I missing something?

+6  A: 

The guy might be in a position to do everything he/she wants to your system, but you shouldn't allow him/her to do anything with other systems (by using your users' passwords).

Password is a property of your users. You should keep it safely.

Mehrdad Afshari
+6  A: 

Many of your users use the same credentials (usernames/passwords) at your site as they do at their bank. If someone can get the credentials table, they can get instant access to a bunch of bank accounts. Fail.

If you don't actually store passwords, then attackers can't steal your users' bank accounts just by grabbing the credentials table.

Justice
+6  A: 

The bigger problem is that people tend to use the same password everywhere. So if you obtain a database of usernames and unsalted passwords, chances are good they might work elsewhere, like hotmail, gmail etc.

Paul Dixon
+4  A: 

This article goes in depth into the positive aspects of hashing and salting you passwords:

http://www.developerfusion.com/article/4679/you-want-salt-with-that/

TheTXI
Great article! Just read that.
User
+2  A: 

Of course, storing hashes of passwords instead of plain-text does not make your application secure. But it is one measure that increases the security. As you mentioned if your server is comprised this measure won't save you, but it limits the damage.

A chain is only as strong as its weakest link

Hashing passwords is only strengthening one link of the chain. So you will have to do more than that.

f3lix
+6  A: 

It relies on the fact that a hash is a one way function. In other words, its very easy to convert a password into a hash, but very difficult to do the opposite.

So when a user registers you convert their chosen password into a hash and store it. At a later point they login using their password and you convert the password to its hash and compares it this is because, to a high level of probablity if (passwordhashA == passwordhashB) then passwordA=passwordB.

Salting is a solution to a related problem. If you know that someones passwordhash is, say ABCDEF, then you can try calcuolating hashes for all possible passwords. Sooner or later you may find that hash('dog') = ABCDEF, so you know their password. This takes a very long time, but the process can be speeded up by using pre-created 'dictionaries' where, for a given hash you can look up the corresponding password. Salting, however means that the text that is hashed isnt a simple english word, or a simple combinationofwords. For example, the case I gave above, the text that would be hashed is not 'dog', but is 'somecrazymadeuptextdog'. This means that any readily available dictionary is useless, since the likelyhood of it containing the hash for that text is a lot less than the likelihood of it containing the hash for 'dog' This likelihood becomes even lower if the salt is a random alphanumeric string.

Visage
I would even say it's impossible to do the opposite, since one single hash matches more than one password. However, one can try to compute a (not the) password matching the hash.
Brann
+4  A: 

The site admin may not be the only person who gets access to your password. There is always the possibility of a dump of the whole database ending up on a public share by accident. In that case, everybody in the world who has internet access could download it and read the password which was so conveniently stored in cleartext.

Yes, this has happened. With credit card data, too.

Yes, it is highly probable that it will happen again.

Treb
+3  A: 

"if someone unauthorized got into the database, isn't it too late to worry about passwords?"

You're assuming a poor database design in which the authorization data is comingled with application data.

The "Separation of Concerns" principle and the "Least Access" principle suggest that user credentials should be kept separate from everything else.

For example, keep your user credentials in an LDAP server.

Also, your question assumes that database credentials are the only credentials. Again, the least access principle suggests that you have application credentials which are separate from database credentials.

Your web application username and password is NOT the database username and password. Similarly for a desktop application. The application authentication may not necessarily be the database authentication.

Further, good security suggests that access to usernames and passwords be kept separate from application data. In a large organization with lots of database users, one admin should be "security officer" and handle authentication and authorization. No other users can modify authorization and the security officer is not authorized to access application data.

It's a quick audit to be sure that the security officer never accesses data. It's a little more complex, but another audit can be sure that the folks with data authorization are real people, not aliases for the security officer.

Hashed passwords is one part of a working security policy.

S.Lott
+2  A: 

In addition to what has already been said regarding salting, there's another problem salting solves :

If you use the same salt everywhere (or no salt at all), it's possible to say just by looking at the database that user foo and user bar both have the same password (even if you don't know what the password is).

Then, if one achieve to get foo's password (using social engineering for example), bar's password is known as well.

Also, if the salt is everywhere the same, one can build up a dictionary dedicated to this specific salt, and then run a brute-force attack using this 'salted' dictionary.

Brann
+1  A: 

This may be a bit off topic, but once in a while, I notice some websites are not using hashing (for example, when I click the forgot password button, they send me my password in cleartext instead of allowing me to chose another one).

I usually just unsubscribe, because I don't think I can trust a website designed by people not taking the elementary precaution of hashing passwords.

That's one more reason for salting:)

Brann
Yes, I agree. Unfortunately a huge number of very valuable sites do it this way. One of those I can think of right now was NameCheap registrar. I used it a few years ago and I remember it was quite honoured by the community. Anyway, storing password in plain is highly unprofessional...
User
A: 

People seem far too complacent about this! The threat isn't some guy with shell access to your system or to the backup media, it could be any script kiddie who can see the unprotected (but dynamic) part of your site(*) and a single overlooked SQL injection threat. One query and suddenly he can log in as any user, or even as an admin. Hashing the passwords make it far less likely that the attacker can log in as any particular user using their password -or- update a record with their own password.

(*) "unprotected" includes any part of the site that can be accessed as a self-registered user. Contrast this to a bank site, for instance, where you must have an existing bank account to gain access to much of the site. An attacker could still open a bank account to gain access to the site, but it would be far easier to send big guys with bigger guns after him when he tries to crack the system.

bgiles