0

Typically for user passwords we store their hashes and salt alongside in the database - one per user.

I wonder the security implications of hashing the same password twice and storing locally both.

hash(pwd, salt1)  # => $digest1$salt1
hash(pwd, salt2)  # => $digest2$salt2

Would storing these two in the same database make it easier for an attacker to figure out the password? Does it matter if the 2nd hashing uses salt1 or salt2?

The use-case for this is that I want to use the 2nd hash as an encryption key for user's secrets.

10
  • 1
    If you use the same salt, then for the same password you will obtain the same hash.
    – mentallurg
    Commented Mar 29, 2023 at 7:40
  • What is the purpose of storing two hashes of the same password ?
    – elsadek
    Commented Mar 29, 2023 at 8:20
  • 1
    OP, I agree with @schroeder. This is not a zero-trust system, as your system would see the user's password in plaintext (after it is sent through the TLS tunnel) when the user logs in, and therefore, your system would have everything it needs to access the user's secrets. Instead, you might want to look at SRP protocol See protonmail.com/blog/encrypted_email_authentication for an interesting read on how ProtonMail authenticates the user, without knowledge of the user's password, where the user also ends up with a key for encrypting their secrets as well during the process.
    – mti2935
    Commented Mar 29, 2023 at 12:02
  • 1
    If you plan to use hash #2 as a secret key then you are literally storing a user's secret key in your database as cleartext. Have you thought this through?
    – John Wu
    Commented Mar 29, 2023 at 22:42
  • 1
    If you are planning to use the value as an encryption key then it should not be stored or sent together with the encrypted data. That would make the encryption useless as any potential attacker would likely get access both if they were compromised.
    – n-l-i
    Commented Mar 30, 2023 at 11:32

1 Answer 1

3

If proper salts are used then there are no security implications in this case. In fact, for bigger system this will be a rather common occurrence as there will be multiple users having the same P@ssw0rd!.

It requires that the salts are cryptographically random and only ever used once. So the second hashing must not reuse the salt that was used for the first hashing.

1
  • My web credentials are a little out of date but I thought adding the username to the hashing operation was a mitigation for accidental common password/salt.
    – foreverska
    Commented May 31, 2023 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .