100M clear text passwords stolen from Russia's biggest social network
thestack.com
thestack.com
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.
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...
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...Otherwise, that claim is false.
You should generate a random salt for each user and store it alongside the user record in the DB.
This result of bcrypt:
$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy
|/ \| \____________________/\_____________________________/
| | salt hash
| cost
|
algorithm,
version
You store this string in the database.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.
So somebody with resources and motive could still brute-force that string. It seems that storing the salt somewhere else would add a comparable amount of security as the salt itself. It seems prudent along the lines of "don't put all your eggs in one basket."
Yes. Because if you had two users with the password 'dadada' they would hash to the same value
Now 1234:dadada hashes differently then 1326:dadada hence preventing the use of a prehashed table (you could go through all salts for common passwords, but it's usually a bit long as well)
In our case, we use an immutable attribute of each user as their hash. This might be an internal identifier, or the timestamp on which their account was created, or something like that.
You do manage it yourself. Password hashing library doesn't access your database, it produces a string that you store, which includes salt and password hash.
In our case, we use an immutable attribute of each user as their hash
What? You really need to talk to security-competent people.
I assume you mean "as their salt". And even then, why the half-measure? Just laziness? Sure, a guessable/computable salt is better than no salt, but it's not nearly as good as a random salt.
Yes, thanks for clarifying what I meant to type.
why the half-measure? Just laziness? Sure, a guessable/computable salt is better than no salt, but it's not nearly as good as a random salt.
But isn't the salt essentially safe to make public anyway? That being the case, how does it matter what value you use, so long as it differs between users?
Good look at the issue here: http://security.stackexchange.com/questions/41617/do-salts-h...
If there's a reason for it (in most cases, there is none), some trade offs are possible, e.g.:
Salt is a large random string unique per user, not per password.
Given two hashes of passwords for the same user it reveals whether passwords are the same.
Salt is a small random string or some predictable value.
Attackers can precompute guesses and then look them up.
If you use some immutable identifier per user as salt, both of these attacks are possible. Is there a reason for this? Since you already store password hash in your database, I'm 100% certain that it's not, you can generate large random salt per each password hash and store it.
As for "safe to make public": there are many things in crypto called "public" where "public" doesn't mean that the whole world is free to get it, but instead means an opposite of "private", or, as I like to call them, "non-secret". Yes, salt can be made public, but shouldn't (unless there's a reason for it — like in a kind of client-side crypto where server stores salt and sends it to clients) to avoid precomputation.
Of course it's per user.
But "large" makes some sense. My current implementation has maybe 20-22 bits of uniqueness in the salt, certainly less than 16 bytes.
I don't think 16 bytes is necessary even as insurance against the future. Rainbow tables are still expensive to build.
On the other hand, maybe to build just a small table addressing the stupidest passwords ("password","12345678",etc.) it's worth making it more difficult.
What I meant is that it shouldn't be per user, it should be per password. If a user changes his password, he should get a new salt.
The birthday problem comes into play here.
If you have 22 bits of entropy in your salt, after 2048 users (2^11) you will find two with the same salt, with 50% probability. If they also use the same password, this makes attacking your users much easier.
Don't make it easy for attackers. Use 16 bytes from a CSPRNG. Better yet: Use a password hashing library that takes care of this for you.
If you use a 128-bit (16-byte) salt, you have a 50% chance of a collision after 2^64 passwords.
I completely disagree. This implies that my DB ORM handles password stuff, which doesn't make sense.
Python 3 example:
Syntax: hashlib.pbkdf2_hmac(hash_name, password, salt, iterations, dklen=None)
Example:
>>> dk = hashlib.pbkdf2_hmac('sha256', b'password', b'salt', 100000)
>>> binascii.hexlify(dk)
b'0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5'
Extremely simple and safe to use. Trivial to store and save/retrieve the salt from DB.
1) You need to store the salt alongside the password.
2) If you want to futureproof the stretching factor (e.g. change from 100000 to 1000000), you need to store that alongside the password hash as well.
3) If you want to futureproof the hashing algorithm, you need to store that alongside the password hash.
The value of the *crypt solutions is that they store the input parameters as part of the stored secret. So you can make adjustments later on without invalidating existing stored passwords, or having to resort to annoying "double-hashes" to migrate to a new approach.
I don't understand your comment about the ORM needing to handle passwords. It's a simple fetch of a field from the DB, which you then pass as an input to your password validator. How is that any harder than fetching a salt and a hash and passing those to your validator?
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...)
https://paragonie.com/blog/2016/02/how-safely-store-password...
http://security.stackexchange.com/questions/211/how-to-secur...
It's mind-boggling how many well-known companies stored passwords badly.
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.)
https://paragonie.com/blog/2015/08/you-wouldnt-base64-a-pass...
If you want secure systems, audit them.
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.
That is to say, you can tell someone to google and they'll find "Use bcrypt", but they'll still feel scared and confused because they don't even know if this is quality suggestion or not let alone what bcrypt is doing and why it's better than MD5.
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.
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/
Slightly less advertised news: This never happened, the data is from a 2011-2012 leak, and everyone from it was forced to change passwords long ago.
The "33,236 times" password is actually mildly obscene, meaning something close to "everything went to hell". Doesn't make any special sense to me.
It's not a reference to anything i'm aware of.
It's worrying because the founders of VK started Telegram which claims to be end-to-end encrypted.
There was also "remind password" feature: https://twitter.com/extractor/status/739801634423857152
Also, they used to store MD5(password) in cookies.
Yes, these are the same people who made Telegram.
Also, you missed a part of my comment where I said that they sent passwords by email when you clicked "I forgot password".
It's a common name, apparently the English speakers traditionally translated Greek name Μαρίνα (Marina) to "Margaret."
edit: ugly sentence structure.
I'd use bcrypt if I were working on my own project though. I think scrypt goes too far, I would actually be concerned about its speed and memory utilization hurting responsiveness for any sort of web server or other latency-sensitive system.
I wish that there was some way to shame these companies. I've seen some websites that list some of these offenders but they don't appear to be effective enough. I want news articles written about these companies in the magazines that the CIOs care about, with their photo right next to the article.
There should be a warning in the browser that these websites are known to store password in plaintext. This can be achieved by an extension too.
In the website you linked, there is a "3rd party tools" link [1] that has a Chrome extension [2] and a Firefox addon [3] that do just that.
[1]: http://plaintextoffenders.com/tools
[2]: https://chrome.google.com/webstore/detail/plain-text-offende...
[3]: https://addons.mozilla.org/en-US/firefox/addon/plain-text-of...
Edit: LeakedSource has been wrong in the past and will be wrong again. https://news.ycombinator.com/item?id=11805691
They're leeches of the worst kind.
I just happened to find more information on the leak on the page that I linked.
What gives? Russian speaking countries? Multiple accounts per user?