Can I ask a broad question of what the “correct” c...
# cfml-general
s
Can I ask a broad question of what the “correct” cypher is for hashing these days?
is PBKDF2 the go-to?
I ask this broadly as I have a few legacy projects that really need their password management beefed up to use hashing beyond md5 and a couple others that use salted + hashed SHA-512
p
bcrypt for stuff like that imo
👍 1
s
@Patrick thanks - is that because the work factor is easier on the host architecture for bcrypt than pbkdft2?
I know that the latter has a low memory footprint I’ve not looked into bcrypt as much
p
yea its much easier work factor for sure. Are there gov specific requirements or what is your issue on the pbkdft2 approach- just that its a lower SHA?
s
No - there’s no hard requirements on what I use beyond some of the clients that need upgraded being on some hardware that may not cope as well with the increased resource requirements of one over the other
I mainly just need to make a decision on what I develop as a generic solution to those that need upgraded
if we’re talking on the order of a few ms on logging in then I’m not concerned
p
Yea I would put bcrypt at easier and maybe same level field around memory as pbkdft2, Bcrypt for avg projects has always worked solid, Gov stuff goes way diff path.
yea it would be ms if even noticable
s
great, all I need to know really
thanks @Patrick
I nearly did the karma command that IRC used to have 😂
p
haha oh yea those days of fun
s
It makes me feel old when I think of it but also nostalgic since it basically led to here and it’s turned into a better resource for all cf devs!
p
honestly I had totally forgot about that until you mentioned it there lol
we oldies
s
It’s a niche language so unexpected benefits when you’re not expecting it! I’ve just joined a company whos senior staff I met years ago at CFCamp so
you never know!
c
Previously used bcrypt, but switched a while ago to Argon2id as it's well regarded and Lucee has built-in support. https://docs.lucee.org/reference/functions/generateargon2hash.html
p
yea that is another good one, wasnt sure on usage/weight
s
Thanks @cfsimplicity, I did look at that but wasn’t sure where to look for details on the impact of its memcost argument and parallelism
The only thing I know about it is it tends to be more resistant to GPU and brute forcing but not how “better” it might be than bcrypt
p
Just a quick search and it appears that Argon2 is memory intensive to prevent gpu attacks
yea you just said it
s
thus far I’ve never had to pay any attention to how long it might add to a users log in time or how complex it might make that process
or how expensive it might make it computationally
p
yea its a give/take thing to analyze, and something on an average playing field should be decent enough with the assumption that you have other methods in tact to prevent brute; aka 5 login attempts block, other various WAF stuff
s
Yeah was just about to say I’ve utilised login attempts and other things to mitigate risk
Also most clients are either on an internal network (so not public facing) or using an OOTB solution like Masa or Preside
it’s just those few clients that aren’t I’m looking at hardening now
I used this lib years ago: https://github.com/finalcut/SaltAndHash
p
Cloudflare is a great starting point if public facing
s
Of the clients that are public facing cf has not been a viable option due to cost, being behind a nat gateway or needing a static ip, and/or lack of knowledge on my part of whether implementing it would be the solution
(mostly cost)
but I have a few poc branches on those projects that need hardening using bcrypt (the forgebox lib you linked to @Patrick)
p
yea if internal your risk is substantially lower but still should not be discounted, so hardening even with bcrypt is a good step forward.
s
the hardest part is figuring out how to convert the existing to the new process. Before what I’ve done is just double hashed
Either double hash the existing passwords or require the user to reset their password the next time they log in
Though I’ve lost count on the number of times I’ve had to advise clients on not forcing an expiry / change password policy
p
Typically I would implement a user must change password approach within their next 5 login attempts or something
c
We've transitioned a few times without requiring users to reset. It's always been possible to detect what algo was used for the hash stored for a user, so when they next log in, if it's a legacy hash then authenticate using that algo. If successful, hash and store the presented credentials using the new algo. To avoid a prolonged transition, you can require a reset after a certain period of not logging in, which people expect anyway.
👍 1
s
@cfsimplicity that’s kind of what I did before, hence the double hashing
I’d validate their “old” password then hash it properly and use that going forward
👍 1
☝️ 1
but still hash it with the old algo and then hash again with the new one to validate
means I don’t need to know their existing password or ask them to reset I just did it silently
d
You mean hash it w old algo to validate the login, then w the new one and store it, so there's nothing the user has to do. Right? Just to say it, the whole point of bcrypt is that the work factor can or does expand over time, so tomorrow's faster computers can be made to be slow enough trying a bunch of possibles that trying a ton of them is prohibitive. Faster and less memory intensive is the opposite of better, unless you don't care how easy it is, in which case maybe don't worry about this much.
z
java added the some post quantum level crypto recently
s
@zackster is that over engineering though 👀
z
my dearly beloved password1 needs a lot of protection!
s
well if we’re being honest/realistic it doesn’t matter what it is as long as it’s hashed properly!
it’s bad enough having to encourage everyone in my family and friend circle to get a password manager and that it’s okay to not remember your password and that it doesn’t need to be complicated even a long distinct string that you remember is perfect
not to mention having to tell people who should know better that the official advice is to NOT require passwords to be changed after x time and that a length minimum is a red flag not a length maximum
g
In cryptography REALLY gives you a buzz - the NIST website is an absolute goldmine of information / presentation notes/slides and articles on advice (like Password for parents with young children) In a cryptography presentation (by this I mean attended by mathematicians who create and attack algorithms) in January this year, it was stated that BCrypt it not suitable for password hashing after the Aug 2022 breach of LastPass. The hacker(s) are still unknown and the LastPass hack has been named as the source for hundreds of millions of dollars(USD) of stolen cryptocurrency from wallets. It went on to say that the current implementation of Argon2i is susceptible to an attack vector known as "Pebbling". (there are 3 variants of Argon2. 2i, 2d and 2id. 2i is specifically used for password hashing - 2d is used for hashing data (files) and 2id is a combination of both.) Despite Argon2 winning the hashing competition and despite the lobbying to NIST for its inclusion in the "Approved" list, it is not likely to be approved until the Pebbling vulnerability is addressed and a substantial amount of time (time to be tested / hacked / etc) has passed to prove its robustness. None of this is to say that BCrypt as an algorithm is a poor choice - or that you should avoid Argon2, either. Despite the current state of things I have applications where Argon2 was specifically requested - even with the knowledge of the Pebbling attack vector. I personally flip-flop between BCrypt/Argon2 when choosing an algorithm. They are both spectacularly better than MD5/SHA-1. The very best advice at the present time is: Use a password generator for passwords. Use a Memory intensive algorithm Despite the constant attacks, use a password safe. Use a "local" one as opposed to online - if you're concerned about the online presence. (Backup your password database regularly) Or use a hardware password safe - instead of a software safe. (I use a yubikey - there is an NFC version and you can get them with fingerprint scanner too. There is also a FIPS certified version if you're paranoid / need a govt approved device. (Just because I am paranoid - doesn't mean THEY aren't out to get me! 🙂 ) AND use MFA. It is a real pain BUT is the current strongest protection we have. (As long as you ignore the fact that it is entirely possible to receive another person's phone calls and SMS messages - without THEIR phone ever ringing / getting the SMS) Of course - YOU would have to be targeted for exploitation for this level of scrutiny...
I realised that I "glossed over" the "pebbling" exploit as if you all inherently knew what the term meant - sorry... Argon2 - uses "Steps" of computation -where a subsequent steps requires the results of the previous step to work. This is what gives Argon2 its "Memory hardness" the processing and storage of the outcome of a given step requires an amount of memory to ne used. By increasing the steps required - you increase the memory required per run of the algorithm. The pebbling exploit - swaps out the ongoing memory consumption - with a computational task, to retrieve the result of a step. Thus swapping a memory resource requirement with a computational one. This weakens the memory hardness of the algorithm - given enough compute power, to make the time required tolerable. The exploit is mathematically theoretical - and even if used - the Argon2 algorithm is still considered "safe" as long as the work factor, parallelism, etc are all set to non-trivial amounts. According to the presentation (and let me remind you - this is a presentation in the "theoretical" - the BCrypt algorithm is still safe too - as long as you're willing to tweak the configuration to the point that it takes minutes (plural) to complete a hashing pass. For regular use - either IS an appropriate choice. If security is an all or nothing requirement for your application / where it is deployed - then you're most likely additionally using MFA/biometrics/security cards/hardware tokens etc - so the theoretical hack of just the hashing algorithm - is only one part of the security chain.
d
@gavinbaumanis Do you have a link to the NIST discussion about BCrypt and the LastPass breakin? I don't understand how that (terrible) event relates to the security of BCrypt in other contexts.
p
Here is some good insight to bcrypt: https://specopssoft.com/blog/hashing-algorithm-cracking-bcrypt-passwords/ @Dave Merrill
d
Good article, but unless I'm thick, it doesn't link any vulnerability in BCrypt to the LastPass incident. Yes any credentials contained in that breach are at risk, but that has nothing to do w BCrypt, and doesn't make BCrypt any less secure. Yes short, common, reused, and known-compromised passwords are a huge risk, but again that has nothing to do w BCrypt. What am I missing?
s
If I remember the details of the same incident it was encrypted data taken not hashed
although the hashed data taken they also said was hashed with pbkdf2
Most incidents these days have all stemmed from social engineering as well and through third party tech as well
I've got used to haveibeenpwned emailing me to say I've appeared on a cred dump lol
I've also started using phrases for passwords now as long as the app I'm using has logical password requirements! I was limited to a length on one app and when I got in touch with them to ask why there was a length limit they told me it wasn't even them that enforced it and when I contacted the actual maintainers they couldn't give me an answer either it was very frustrating
When I see a length limit I see them storing it in plain text or an identifiable manner
I've also gotten tired of informing various parties about the outdated advice around forcing expiry or changing passwords
Just point them to the NCSC articles around why it's no longer an advised approach 🤷 /rant
I'm regularly surprised at how weak some people's passwords are but worse than that how many people use the same passwords for several things or just variations of the same password
I think it was Troy Hunt that said in a post one time that the best password is one you don't remember and I took that to heart ha
d
FYI, I think the max length string that BCrypt can hash effectively is 72 characters, it truncates the input beyond that. This SO page talks about it. I'm not 1 million percent certain that old info still applies, but I haven't found anything saying otherwise.
s
That's interesting I wouldn't think there was a maximum
Since I discovered salting and hashing I've ranted about passwords to anyone that will listen
And get annoyed at encryption and hashing being confused
I'm a nerd basically and only feel justified speaking to other devs who know about crypto haha
Thanks for that so link @Dave Merrill but think it's safe to say only a rare person will try use a pw longer than 50 chars
d
Depends on how you have your password app configured to generate them 🙂
FWIW, cfdocs actually says the limit is 72 bytes: https://cfdocs.org/generatebcrypthash Adobe docs don't mention that.
Wikipedia also mentions the 72 byte limit, seems it's still real.
p
I think part of the point regarding bcrypt is related to the lead into quantum computing being able to crack stuff faster etc but in a normal realm app environment it is perfectly fine at the moment. @Dave Merrill
👍 1