by UnicycleSkewer · 6y ago · 0 comments
Unlike a pepper it is possible to change the encryption key if it is leaked. I don't think changing a pepper for existing hashes is possible, but if they are encrypted you can just reencrypt them with the new key.
So is there an obvious downside I'm not seeing to hash with a salt and then encrypt?
The downside for the scheme is complexity and limited upside; complexity gets a lot more attention when it comes to security considerations.
Best practice especially needs to be simple; it's easy to mess this stuff up and hard to understand. A lot of the comments on this post betray a very poor understanding of password storage; they simply haven't come across the correct information.
Overall pepper is good as long as you include salt. There are times when the db gets leaked and the env variables don't.
There's nothing wrong with your scheme if it's implemented properly, but being able to change the site-wide key is a limited upside compared to using a pepper. There is an upside though.
And all of this doesn't matter much as long as you do the bare minimum of using a tuned pbkdf+salt and keep your stuff patched.
Just make sure you use a suiting AES mode. If it turns out that you xor'd all hashes with the same stream that depends on your pepper only, it's not really helpful :).
One, slightly longer password checks. And two, the temptation to lean on the AES key and set the cost of the hash too low. In the case the key does get out - we had an entire era where people stole environment variables from servers - then you decrypt the entire password file once and have cheaper guesses per second.
Maybe the real question is why use a pepper over encryption?
They have the same downside (as you mentioned) but at least you can change the encryption key without having all the users change passwords. I don't see any advantage in using a pepper over encryption, except maybe implementation complexity.
Like any disaster preparedness situation, make sure your strategy doesn't count on an asset you've already listed as unavailable.