ScuffleTV / scuffle

Live streaming platform
https://scuffle.tv
224 stars 25 forks source link

Password security: algo, strength, managment, etc #68

Open IS2511 opened 1 year ago

IS2511 commented 1 year ago

Collecting here all the info about passwords and how we manage them. This should be closed when we are satisfied with our level of password security and management procedures.

This is a collection from 3 posts by me:

I'll only combine all of them in this initial text.


About password algorithms

AFAIK "argon2 + salt + pepper" is the last word in password hashing. bcrypt is practically legacy by now. Giving it a quick search just^1 in^2 case^3, I see no problems. I would encourage to read the OWASP cheatsheet^1 in particular.

If we really want to get into it, we could try to follow NIST guidelines^4. Document B says you SHOULD salt and lists a few recommended options for hashing:

Examples of suitable key derivation functions include Password-based Key Derivation Function 2 (PBKDF2) [SP 800-132] and Balloon [BALLOON]. A memory-hard function SHOULD be used because it increases the cost of an attack. The key derivation function SHALL use an approved one-way function such as Keyed Hash Message Authentication Code (HMAC) [FIPS 198-1], any approved hash function in SP 800-107, Secure Hash Algorithm 3 (SHA-3) [FIPS 202], CMAC [SP 800-38B] or Keccak Message Authentication Code (KMAC), Customizable SHAKE (cSHAKE), or ParallelHash [SP 800-185].

But if we don't need FIPS-140^5 compliance, I don't think we need to strictly follow that.

About password strength

About proper passwords and stuff, I think we should research this later and come up with a better algo to determine the strength of a password. 8+ chars and at least one uppercase+digit+special is ok, but I want to accommodate for more diverse password styles. Like long_phrase_passwords with no digits or uppercase letters, etc. As some inspiration, take a look at password entropy with https://xkpasswd.net/s/ Some^6 more^7 inspiration^8. Especially the first^6 one.

funny and true (spoiler) ![xkcd comic 936. password strength](https://imgs.xkcd.com/comics/password_strength.png)

About password peppering

Consider adding peppering. Since argon2 (as an algo) even supports it with it's "secret"^9, and argon2 (the lib) implements it^10. Notes on how to properly do peppering from OWASP Password Cheat Sheet^11, my beloved.

Also check out counter-points to pepper^12 (and the two^13 links^14 from that answer are also interesting), even if most of them don't apply to our case because we are using argon2 as intended, it has the "secret" param for a reason. However, secret rotation should be considered, as OWASP^11 also mentions.


Participation

Disclaimer

IS2511 commented 1 year ago

Peppering is annoying to work with and also does not really do much. Since peppering means we have to introduce state (we have to store the pepper) and if an attacker somehow manages to breach into our system, its very likely that they will have the pepper too.

_Originally posted by @TroyKomodo in https://github.com/ScuffleTV/scuffle/pull/63#discussion_r1126563003_

It just becomes annoying to work with since we then have to know about the pepper here. perhaps we can add it but I am not sure if it actually does anything extra. Argon2 is already impossible to crack using any means, adding peppering means we have to keep track of a state all for it to be impossible * 2?

_Originally posted by @TroyKomodo in https://github.com/ScuffleTV/scuffle/pull/63#discussion_r1126565693_

TroyKomodo commented 7 months ago

Is this issue superseded by #176 @IS2511 ?