views:

76

answers:

1

Hi there.

Im searching for the most secure (but yet doable) way of password management in a web app.

Right now, I save the password as hash. The DB account of the app is restricted to excecution of stored procedures and I authenticate users by giving the username and the hashed password to a stored procedure that returns 1(true) or 0(false).

So there is no chance of getting the password from the server, even if you have the DB account of the app. Thats what i like about this solution. But to use this, the client has to submit his password over the web, or at least a static hash that could be catched.

So I came to idea of using a handshake like this:

  • Client asks server for salt.
  • Random salt is given to client and stored on server for this single client.
  • Client makes Hash(salt + password) and returns this hash to server
  • Server makes Hash(salt + password) and checks if its same then from client

Using this handshake makes it possible to check the password without sending itself or a static hash of it. Just a dynamic salted hash, that is different each time the user logs in => Highly secure.

But for this handshake i need the password or at least the hashed password from the DB. But this enables someone to get at least the hashed password and bruteforce it outside the app.

What would you prefer? Keeping password inside DB and make anything there(secure server), or get it out of DB and do it outside(secure transmission)?

Thanks in advance, Marks

+2  A: 

Your proposed solution does not really solve the problem. The server has to know the password nevertheless, so it had to be transferred at some point in plain, which was what you wanted to avoid in the first place. This way you only avoid the password being sent again every time, but if someone caught it the first time it was transferred?

I think you should not reinvent the wheel :-) Use SSL for all connections and then your first solutions works fine. You can even perform the hashing on client side, so only the hash is sent over the secure channel. Your server will never know the password, and it doesn't have to.

David Sauter
Agreed, SSL should be secure enough. Definitely hash the passwords in the database too, although MD5 is suspect these days so I could use a more secure hash algorithm to do this. Your proposed handshake is similar to MS-CHAP which is also suspect.
Jamie Chapman
You're right, but I think its less likely that the password is sniffed this single time, than one of the following hundreds or thousands of times the user logs in. My connection is SSL nether the less, I just wanted some extra security. Right now I use FormsAuthentications built in SHA1 hash, but i need SHA-256 at another place, so i think i will switch to that.You think stored procedure GetUser should return hashed password? Or just return null instead?
Marks
When you talk about "security", you always assume a worst case scenario. You assume that the attacker is always present and exploits every weakness in your system with maximal effectiveness. In this sense, it does not matter whether he can read your password once or a hundred times, fact is he can read it. Your customers don't want to hear you say "it's not so likely an attacker can read your password" :-)Whether your stored procedure returns the hash or `null` is up to you, the server should be protected with other means to prevent remote access anyway (firewall, security patches, ...)
David Sauter