How to properly use hashes and salt to protect against MITM and database
access?
I want to protect a website against two security threads, one is a Man in
the Middle attack and the other against unauthorized access to the
database to get passwords.
I'm aware that to protect user's password stored in the database the best
way to do it is hashing and salting the password using good hashing
algorithms like sha512.
Also that to protect the password from a Man in the Middle sniff attack
you can also hash and salt the password before is sent through the
network.
For what I've read the proper way to protect passwords against a database
intrusion is
To Store a Password
Generate a long random salt using a CSPRNG.
Prepend the salt to the password and hash it with a standard cryptographic
hash function such as SHA256.
Save both the salt and the hash in the user's database record.
To Validate a Password
Retrieve the user's salt and hash from the database.
Prepend the salt to the given password and hash it using the same hash
function.
Compare the hash of the given password with the hash from the database. If
they match, the password is correct. Otherwise, the password is incorrect.
And that to protect a password against a sniffing attack the server
provides a random salt string to the client application for it to hash it
with the password before sending it through the network back to the server
to be compared. But how can you compare the received password if the one
stored in your database has been hashed with a different salt (if the
method for protecting passwords against database access was used) ?
I'm really confused. Can these two security threads be solved by combining
these two methods if so, how? or instead of hashing and salting for the
sniffing attack the best way to protect is to use SSL?
Thanks in advance I hope all this makes sense.
No comments:
Post a Comment