SQL Antipatterns, Volume 1, B5: encourage password-specific hashing algorithms as the first choice (chapter 20)

Hi Bill.

I’m glad to see you cover a lot of important topics about dealing with passwords in Chapter 20, “Readable Passwords”.

However, I have to admit I was a bit crestfallen to see that password-specific hashing algorithms, e.g. Argon2, PBKDF2, and Bcrypt, only receive a passing mention in the very last paragraph of the chapter, and only then with the qualifier of “if you need to develop very secure systems, you should move on to more advanced techniques…”

I propose that the chapter encourage readers to consider password-specific hashing algorithms as their first choice, and only then fall back to rolling their own with SHA + salt if circumstances dictate. In my experience, using a dedicated package such as bcrypt is less intimidating, less likely to screw up, is better documented, and results in less code.

OWASP’s Password Storage Cheat Sheet provides a lot more detail and justification for why password-specific hashing algorithms should be the first choice for any system tasked with storing passwords:

Also, regarding security, perhaps the “password reset” email examples on pages 235-6 can be updated to use “https” instead of “http” in the links.

Thanks again, Bill. I think all your hard work in creating a new edition of the book will greatly benefit the industry.

Thanks Ted! I’m only able to do minor edits at this point, because we’re finishing up and going to production very soon. I agree with you about making a stronger recommendation for modern cryptographic hash algorithms.

I can’t make a major rewrite now, and ultimately it’s a book about SQL, not cryptography. But I’ve edit to make the recommended practice more clear :

“The techniques in this chapter are still relevant regardless of the type of cryptographic hash algorithm you use, but you should use the current recommended algorithms such as the following:”

Then I followed the list of algorithms with:

“The above list will eventually become outdated too. If you’re responsible for implementing an authentication system, then you should keep yourself up to date on the latest standards of cryptography.”

I’ve fixed the https references in the example URLs. Ironically, the link to the bcrypt source doesn’t support https!

1 Like

Sounds great Bill; thanks!

I think you’re referring to http://bcrypt.sourceforge.net/. If so, that page appears to be twenty years old and lacks links to Bcrypt implementations in various languages.

Perhaps using https://en.wikipedia.org/wiki/Bcrypt as the reference would serve readers better.

Normally I don’t like to use Wikipedia links, because some folks have issues with the fact that it’s a tertiary source. But I already broke that rule the other day because I found anchormodeling.com is flaky and was intermittently not responding. So I linked to the Wikipedia article on Anchor Modeling instead. So I’ve fixed the link to Bcrypt to use its Wikipedia article too.

1 Like

Thanks, and I understand the reticence towards referencing Wikipedia.

I looked around for a more direct source before making the suggestion but I didn’t find anything else that quickly got to the point and listed implementations in various languages / environments.

Much like the Anchor Modeling situation, I think it’s the pragmatic choice in this limited circumstance.

Thanks again and congrats on going to print production!

1 Like