Is my authentication system secured?

77 Views Asked by At

I want to implement an authentication system by following good practices, i want it as simple as possible and secured (im not going to implement some magic hashing function or something to feel a hero..) just wanting to use already known hash but not sure the right way of using it. I read some articles on how Lastpass (a password management company) mange to handle their authentication and i loved their idea.So i wanted to implement my own authentication based on it.

Basically im creating an authentication key from the password on the client side (so the password is never sent as a plan text to the server). that authentication key im sending to the server than do some hashing operations also in the server side and compare the result to the one inside the database.

On my client side:

auth_key = PBKDF2(SHA256, password+username, last_login_fe_salt, fe_rounds)

explanation - hashing password+username+last_login_fe_salt text fe_rounds times

last_login_fe_salt -> a random salt sent to the user once he/she input their username in text field - To be honest, not sure how this last_login_fe_salt is efficent for the cryptography against Dictionary attacks but atleast two people having the same password will send different hashes on their network. any hacker can get this data by asking from the server, i can add server side limitations (req/s if it makes some difference etc.. let me know what you think) also adding captcha might be a good idea. When a user logged in successfuly the server generates a new random string and saves in into the database.

*I didnt see any explanation which salt Lastpass uses on their client side hashing, they are using PBKDF2 algorithm that needs a salt parameter.

fe_rounds -> number of rounds given by the server when typing username - its fixed for everybody and configurable by the server, also in articles i read about Lastpass they dont explain from where they receive the client side number of rounds...

so now we send auth_key as is to the server...

On my server side

now we are creating a new hash to compare the one inside the db. Why another hash? if i understand correctly we bind the hash for server side data, like a combination of a password (that only the user knows) and server data.

db_auth=PBKDF2(SHA256, auth_key, user_be_salt, 100,000+user_configurable_rounds)

user_be_salt -> a random number that saved in db known only to the server and the ones who obtain the database, this changes on every successful login.

user_configurable_rounds -> number of iterations, every user can choose the amount of iterations (like in Lastpass) so attacker need also to guess the number or iterations?

I would be happy to hear what do you think about this authentication system, if its wrong than explain to me why and tell me what Lastpass do because i did not understand their entire authentication flow.

1

There are 1 best solutions below

0
On

Most of what you're doing is useless from a security perspective. Lastpass has unusual security requirements -- don't treat them as a source of best practices.

If the client is responsible for hashing, and all of the parameters to that hashing are fixed, the hash effectively becomes the password. An attacker doesn't need to know the original password; they can simply pass the hash to the server.

Generally speaking, there is no way to verify a password over a network without either sending the password across the network (for traditional password authentication protocols), or having the server store the password in plaintext (for less commonly used protocols like SRP). Of the two, the former is preferable, as it's possible to secure the password in transit using protocols like SSL/TLS, whereas protocols like SRP require the plaintext of the password to operate.

Tweaking the PBKDF round count, either on the client or server side, is pointless. Set a fixed round count that makes the hash slow, but not so slow that it will place an undue load on the client or server. (100,000 rounds is probably excessive for a server-side hash. It takes roughly half a second to verify a password with those settings, so just two login requests per second would use 100% of one core on your server!)