I'm using custom authentication for Firebase in one of my apps. I'm generating the uid of the user by SHA256 hash of the user's email address.
My question is, how secure is this? Do I need to worry about collisions? Cause if there is a collision it would give complete account access to another user whose email's hash is the same.
If this is not secure can anyone please recommend me a way to generate a unique string from an email address that won't have collisions?
Related
Our website utilizes HTTPS and our question is:
Are we violating GDPR consent by storing use email in cookies?
Other question:
It this even advised to do?
I am completely aware that cookies are not a secure way of storing sensitive data. What we are trying to accomplish is to store login information in order to help returning customers to only enter their password on the login form by storing their email data.
I am developing an app which uses Facebook login, and which contains a messaging platform. Messages are stored in a Firebase database, and I would like to have some sort of encryption such that the database stores the encrypted messages, and only the sender and receiver can decrypt them.
I know the sender/receiver need some unique key to encrypt/decrypt the messages, but I am unsure as to how I should generate this key, and as to where it should be stored? Basically, there are plenty of tutorials on message encrypting, so I am wondering about the general information structure of an app which involves this kind of encryption, rather than about what exact code to implement!
I thought about basing the encryption key on a user's Facebook access token, but these change every 60 days so I assume it wouldn't work?
Thank you for any help or suggestions!
I've used password_hash($pwd, PASSWORD_BCRYPT) to create a hash and store in the user table. It will be used for login verification.
Since hashing is a one way function,
My question is can I use the same hash as the account verification code in the activation email send to user.
Will it compromise security since knowing the hash doesn't reveal the password.
Yes, it would compromise security because an attacker with access to the email account (either presently or at any future point in time if the email is never deleted), could run a password guessing attack on the hash.
If would be better to generate a 128-bit key using a CSPRNG, this can be emailed to the user as is. On the server-side you would want to hash this using SHA-2 for storage, because that way if your activation table data was ever exposed, an attacker could not activate accounts that do not have valid email addresses. Note that no salt is needed for automatically generated keys of this strength.
This approach is fairly simple, and mitigates the risk in sending the password hash directly.
I need to authenticate users using an api key, but before handling it over to them I need to check their credentials, obviously. I think the process needs to go like this:
client->server: GET /user?username=fred
server->client: nonce=XYXY
client->server: POST /login?hashval={hash(username + password + nonce)}&nonce=XYXY&username=fred
server compares the result of hash(username + passwordFromDB + nonce) with hashval and responds with the API-key if equal
But if there was somebody eavesdropping the connection, although it wouldn't be able to directly discover my user's password, since it already knows the username and the nonce, if the password was easy enough the man-in-the-middle would be able to match my hash by trying all the generic possible values for the password.(brute-force attack)
I know connection over HTTPS and a strong password would make this process secure, but are there any other recommendations or ways of making this process more secure?
Thank you
This is basically a form of digest access authentication and as such has its same limitations.
Since all the details to compute the hash are sent along with the hash, the only thing that an attacker needs to "reverse" is the password. If that is weak, then rainbow table or brute force attacks could crack it. The only way to delay an attacker is to have a very long and strong password.
But since you are using an API key for service authentication, as a man-in-the-middle attacker I would let you authenticate with a password and then just get the API key from the response. I assume you use the API key for authentication of the rest of the requests (just like a session cookie is doing for web applications)?
There are of course other variations of securing a service, depending on what you are doing, but actually making it secure means using HTTPS as you mentioned yourself.
Consider the following interaction:
A user stores their username and password on a web server. For the sake of security, the server records a hash of the password plus some unique salt.
While the user is using a client application, it makes a request to the server submitting their username and a hash of the password plus some other unique salt.
So you have the following information on the server and need to know whether or not the request is authentic:
The server's salt
The server's hashed password
The client's salt
The client's hashed password
Again ... client sends: clientSalt + MD5(clientSalt + password). Server has serverSalt + MD5(serverSalt + password). I don't want to know the password, I just want to know if the hashes were calculated from the same password.
Without knowing the password that was hashed, is there any way to verify that both hashes are of the same password?
My goal is to allow some form of secure authentication in a client-server environment without ever exchanging the actual password over the wire. This is just one idea I've had, but I don't even know if it's possible.
That would require unhashing the password, which is not possible. If the server receives: salt, md5sum, it can't see what went into the md5sum.
A challenge-response protocol would work instead. The server should generate a random value nonce and send it to the client. The client calculates md5(md5(password) | nonce)) and returns it to the server. The server verifies by checking md5(storedpassword | nonce).
No, you can't do this.
Once you add a salt into the mix it becomes practically impossible to compare hashes. (To do so would require "un-hashing" those hashes somehow before comparing the "un-hashed" data.)
Challenge-response authentication is probably the way to go, possibly using Kerberos, depending on your tradeoffs. One of the tradeoffs being the possibility for attackers controlling the clients to use compromised hashes to authenticate themselves.
Don't invent your own cryptographic protocols. Use one that is well-known and well tested. If possible, use an existing (vetted) implementation.
My goal is to allow some form of secure authentication in a client-server environment without ever exchanging the actual password over the wire. This is just one idea I've had, but I don't even know if it's possible.
For this, I advise looking into Kerberos: Official Site and Wikipedia
It's impossible. If you don't store password on the server, user must provide it.
OR
If you store password on the server, user can provide hash calculated using requested salt.
You will not be able to verify the hash with this setup.
If you don't want someone to see the password go over the wire, SSL is the easier way.
If you don't want to use SSL, you could check out SRP.
Additionnally: don't use MD5+Salt to store your password, use key strengthening functions like bcrypt or scrypt.