7 ms·
Instead of idiot questions like FizzBuzz maybe recruiters should be asking about password storage best practices instead
by raverbashing 10y ago
Instead of idiot questions like FizzBuzz maybe recruiters should be asking about password storage best practices instead
- rcconf 10y agoI've asked these questions in interviews and a lot of programmers seem to know the basics (what a hash is), but seem to fall short when it comes to things like what a salt is, modern storage techniques (bcrypt, scrypt, PBKDF2) and how rainbow attacks can be used to crack hashes. It's a bit tricky to fail someone in an interview because they don't know security. I think the better way to handle security in a company is to hire a programmer that knows it and teaches it to other programmers during code reviews.
- t3nary 10y agoHashing with an insecure algorithm and without good salting isn't much better that not hashing at all though.
- dzhiurgis 10y agoHow do you store salt?
- CiPHPerCoder 10y agoThat question should never even need to be asked. The library you're using should take care of that for you. In PHP: $storeMe = password_hash($plaintext, PASSWORD_DEFAULT); if (password_verify($plaintext, $storeMe)) { // Logged in } The detail is totally abstracted away. All sane password hashing libraries offer this API. See: https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016 https://paragonie.com/blog/2016/02/how-safely-store-password... EDIT - CANNOT REPLY: > One major failure of this article: > > You should generate a random salt for each user and store it alongside the user > record in the DB. No, you shouldn't. Your library should do that for you, and store it as a single string that's opaque to the developer. > I completely disagree. This implies that my DB ORM handles password stuff, > which doesn't make sense. See the passlib section: https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016#python https://paragonie.com/blog/2016/02/how-safely-store-password...
- tamana 10y agoBut then you are using php so you already lost.
- CiPHPerCoder 10y agoIf there was any truth at all in that claim, you should be able to compromise paragonie.com right now simply for it running PHP. Otherwise, that claim is false.
- jjawssd 10y agoOne major failure of this article: You should generate a random salt for each user and store it alongside the user record in the DB.
- dchest 10y agoHow is this a failure? That's correct. (If your password hashing library doesn't handle this automatically, of course. But it does the same internally.)
- jjawssd 10y agoIs it normal for password hashing libraries to save salts to a database?
- dchest 10y agoYes, they usually produce a string that looks something like "salt||hash". (Salt is a non-secret value.) This result of bcrypt: $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy |/ \| \____________________/\_____________________________/ | | salt hash | cost | algorithm, version You store this string in the database.
- zo1 10y agoThe big thing about this, is that it is perfectly "OK" to store both the algorithm, cost, and salt alongside the hash. Most people seem to think, and myself included when I was new-to-it, that storing all those things together would compromise the security. The point of the hash is that it is impossible (almost) to get to the hash without the user's password, and there is no way to get to the password with the entire string you posted.
- dchest 10y agoNope, it is much better for those who use passwords with good entropy.
- staticelf 10y agoCryptography is hard and best practice should be to use common libraries to help you get it right.
- cm2187 10y agoIt's not about writing your own crypto. It's about knowing not to use the md5 library but the bcrypt library instead.
- tamana 10y agoIdeally the md5 library documentation says "this is a digest function, not a secure bash"
- geocar 10y agoThose words might as well be in greek. How about: You should use the md5 function to produce a string you can compare with the md5 function. md5 is obsolete, does not offer much security, and should not be used in new programs except for the purposes of interoperating with old programs, and even in that case, one should weigh the risks of interoperation with the costs of replacing. If you are looking for a suitable replacement for md5, you should instead be looking for specific use-cases, such as content verification (links...), authenticated content verification (links...), password verification (links...), random number generation (links...), shared secret encryption (links...)
- cm2187 10y agoIn fact you only want to use it when your comparison can afford collisions (md5 generates a lot of collisions). Sha256 is pretty much collision free.
- golergka 10y agoPersonally, I think it's quite enough if a programmer at least knows that he doesn't know certain aspects of security — and instead of importing standard library's md5 module, spends at least 20 minutes on Google when faced with such a task.
- MOARDONGZPLZ 10y agoIs there a good article or breakdown on modern best security practices? I am a relatively experienced programmer and know what a hash and salt are, and have read the wikipedia article on rainbow tables (though I now forget what they are other than that they make attacks of certain things easier), but that's the extent of my knowledge.
- CiPHPerCoder 10y agoHere's one. Title: How to safely store your users' passwords in 2016. https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016 https://paragonie.com/blog/2016/02/how-safely-store-password...
- jtchang 10y agoThat site recommends libsodium which by default uses Argon2. The issue is that Argon2 is not very mature yet. Also if you are using python there is no good library out there. Ideally you want something well tested since it is possible for libraries to have bugs as well.
- barsonme 10y agoThere's this good link from Thomas Ptacek: https://gist.github.com/tqbf/be58d2d39690c3b366ad https://gist.github.com/tqbf/be58d2d39690c3b366ad
- zo1 10y agoThe best one I've come across is actually an answer on the Security StackExchange. http://security.stackexchange.com/questions/211/how-to-securely-hash-passwords http://security.stackexchange.com/questions/211/how-to-secur...
- Royalaid 10y agoThe best resource I have found is https://www.owasp.org/index.php/Main_Page https://www.owasp.org/index.php/Main_Page
- t3nary 10y agoYeah, I'm currently taking a computer security class for master students and we spend quite some time on passwords. Made me think that this should be in an obligatory course for bachelor students (or some stripped down version that teaches the basics). It's mind-boggling how many well-known companies stored passwords badly.
- joshstrange 10y agoAs another comment mentioned I think the issue is far less that computer scientists don't know good PW practice and far greater that management doesn't care to give them time to work on it.
- sillysaurus3 10y agoRecruiters should be administering work sample tests tuned to the signal of what the company makes, and the company should be doing security audits at a regular interval. It's strange that candidates would be expected to have any knowledge of security when security is very hard to get right. This is the domain of a dedicated specialist, not a generalist who's usually pressed for time and whose work usually isn't audited. If you want to get security 90% right, you can spend a few days doing the cryptopals challenges. But you need to get security 100% right, because 90% right means your systems can be compromised. A situation like that pretty much demands security audits. (It doesn't help that the go-to answer of "Who should we contact to get a security audit?" is "Someone that will charge half a year's salary of a decent engineer," though.)
- tamana 10y agoOh come on. Asking someone about password ecryption is basic computer science and general intelligence . Its. It about writing bcrypt. Its about thinking for five minutes about why we have passwords and what protection they need to be meaningful passwords.
- CiPHPerCoder 10y ago> password encryption https://paragonie.com/blog/2015/08/you-wouldnt-base64-a-password-cryptography-decoded https://paragonie.com/blog/2015/08/you-wouldnt-base64-a-pass...
- sillysaurus3 10y agoThat you would deny someone employment at your company based on their lack of bcrypt knowledge -- knowledge which can be gained in five minutes on Google, which candidates don't have access to during an interview -- is evidence of how broken our hiring processes are. If you want secure systems, audit them.
- tensor 10y agoAuditing isn't enough in my experience. Most audits are just focus on paper security. They'll run nessus and some other automated tools, do no filtering and have your developers actually check any results, and then go through an extensive box checking exercise that is incapable of handling any app specific context. In the worst case, they may recommend outdated or harmful practices that will actually lower security. For example, complex password rules and rotations instead of strength checking and password managers. This leads to users just writing things down since they can't memorize ever changing passwords. Or they may force you to install antivirus on systems that don't need it, even though antivirus systems have been shown to be full of security flaws that actually weaken system security when installed into privileged or sensitive subsystems. Paper security is distinct from genuine security. They overlap certainly, but paper security is not enough to make you secure.
- whatever_dude 10y agoIn theory, everyone knows what's the best (or at least a good enough) way to do something like this. In practice, there's a lot more things involved leading to stupid decisions like this. Something that was supposed to be temporary made permanent by growing technical debt, unclear responsibilities, moving priorities, etc. Security is never any company's top priority just because it's not visible. Changing a color of a button is normally more important.
- mmahemoff 10y agoThat would be useful, but won't solve the problem alone. It's highly likely there were any number of engineers in these companies fuming about poor practice, but lacking management support to prioritise it. Look at how TalkTalk ignored a security researcher's warnings a year before incurring a major attack. They were also storing in plain-text, available to support staff, and came up with comments like "We're squeaky-clean on security". This is a PR response, not one from the engineers who know what's going wrong. https://paul.reviews/value-security-avoid-talktalk/ https://paul.reviews/value-security-avoid-talktalk/