362 points · by mrzool · 6y ago · 338 comments
They care (sometimes, sometimes they don't act like it, see https://www.ieee-security.org/TC/SPW2020/ConPro/papers/bhaga... ) that it was compromised.
An end user doesn't have any control or knowledge over the password storage mechanism for any sites, so the best thing is to use a strong random password generating password manager--because that is something the end user can control.
However, for the websites managing passwords, I'd suggest reviewing the NIST guidelines: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.S...
The sysadmin resigned, no tech person anymore. The boss got a lost password inquiry from a customer, panicked, called former admin for help, not a single word he understood, hit the forum.
And in the forum post he said the admin “wouldn’t cooperate”, “very adamant and confrontational” about “giving out encryption keys” to “decrypt valuable customer database we can’t afford to rebuild but might have to” and how it’s driving the company towards bankruptcy over last few days etc etc.
Eventually forum members realized he’s talking about a password reset, and convinced him it’s actually impossible to recover hashed password nor it’s necessary which is the point, you just verify identity and let them change the password etc etc, but it took hours for the community, on top of a day and half or so of tense hours for the boss guy’s company, to just understand the situation and act accordingly.
So I think it might be worth communicating how passwords work every once in a while.
It's not a matter of principle, it's a matter of headaches. It's very unlikely that a customer like that would pay enough to make it worthwhile.
Happened to me two times, changed password, locked out, had to reset. then while logging in, I noticed their requirement of 12 characters, at next reset used 12 characters, & did not get locked out.
Or better yet, pick one of the other algos with better limits and protection like Argon2 or Scrypt.
Iterated password hashing algorithms like bcrypt [2] use a parameter tuneable by the site operator that drastically varies the computational cost of calculating the hash, so a brute force attack on the hash could be required to use orders of magnitude more computational power to crack. The tradeoff is that it will make users wait longer to log in, and (might) incur additional operational cost to the site. This is why it's a tuneable parameter: Up increases security at the cost of user delay and operations.
In theory. In practice, the user delay and operational cost are also proportional to the user's password length, which you don't control. Observe, the leak. This can cause wildly varying response times for authentication attempts, and opens your authentication system up to a DoS attack. The only reasonable solution is to put a small cap on password length so that the longest passwords don't take more than 2-5 times as long to compute, as per each site's tolerance of variance.
So why does the runtime of the iterated hash function depend on the length of the password? In each iteration the user's password is joined to the previous iteration's hash, and hashed together to get this iteration's hash. The runtime of any hash function is proportional to the length of the data fed in, the data fed in includes the user's password, thus the runtime of an iteration is proportional to the length of the user's password. So the runtime of the whole iterated password hash is `O(Iterations * PasswordLength)`.
There are various schemes one could come up with to change the time to `O(Iterations + PasswordLength)` ~ `O(Iterations)`, such as concatenating the first hash of the user's password instead of the password itself on all successive iterations, so all iterations but the first are independent of the user-chosen password length. There could be some security/entropy-based arguments for avoiding this solution, though I don't know what that could be.
Hi Westpac.
But yes, at that point all you can do is either complain to the website purveyor or vote with your feet (if the latter is an option).
"Your password is too long!"
"Your password uses special characters!"
... they are not only incompetent to write code which handles passwords, they have been so misinformed that they are an outright liability. They need to relearn everything they currently know on the subject and start over. Few things in the technical world instantly convey such utter anti-knowledge as the presence of either or both of those error messages in a codebase.
I do think the message got a little lost in the post though, with the follow-on discussions of salting, bcrypt vs. md5, etc.
The problem is that the term is _inaccurate_ because it is _overly precise_.
---------------
When you find yourself arguing over details you find pedantic, then it is a sign that you either:
A. Are failing to realize why some detail actually _does_ matter in that context.
B. Are using overly-precise terms and should see if you can "go up one abstraction layer", likely by asking "why does someone care?"
What a spot-on observation. Maybe this is why I am always so pedantic, even when I tell myself that it's not necessary in said context. Subconsciously, I'm implementing this connection, and I can't turn it off.
relevant MCU quotation, from Civil War,
[ROGERS/CAPT] Sometimes... I wish I could.
[STARK] No you don't.
[CAPT] Yeah, you're right - I don't.
And my mum who's not really techie does care because she gets emails from Yahoo and the like saying sorry we've been hacked yet again please reset your passwords and gets in a panic over it.
Reminds me of an experience I had in college. I was working phones over the summer at a call center and had this software developer call in. This was during the runup to Y2K, and I mentioned the "Y2K bug" and he starts ranting about how it's not a bug.
And I'm like, yes I understand it's not technically a bug, but most non-technical people don't know the difference.
I've never understood why people are like this with non-technical folks. If you're having a technical discussion with another technical person, then yes, the distinction absolutely matters. But to non-technical people? Who exactly benefits from that?
On the other hand, the general water-level of knowledge is frustratingly low at times: I’ve received customer support which insisted that they couldn’t register proof of identity to activate a SIM card for an iPhone, only for Android; a salesperson saying iPhones couldn’t be used in those cheap strap-a-phone-to-your-face 3D headsets; and a previous boss had to tell off one of their own customer support team for saying their product didn’t support Firefox when the only browser installed on the customer support team’s computers was Firefox.
If you encrypt a password, it means that somewhere you have a key that you use to decrypt it to check if it's valid on the user login. It means that there is a way that you (or more importantly an attacker) can use to decrypt the passwords.
Instead if you use a good hashing algorithm is practically impossible to find the password given the hash. Yes if the password is really simple you can get it, but come on, if the password is really simple what's the point of protecting it?
By the way I think that we should phase out password anyway, I mean that I prefer to implement in the applications that I develop a password-less authentication: when you want to sign in a mail (or an SMS) is sent to you, you click on a link with a temporary token and you are authenticated.
No password to remember, not having to implement forgot password, change password, recover your password, not having to store the password, not having the user have to choose a password, and I hate choosing password (in fact I ended up using a password manager that generates random passwords for me, but it's not the ideal solution, because then password have to be synced on all my devices, not all websites/apps have forms made correctly to support password manager, and the password manager extension (Bitwarden) goes in conflict with the integrated Firefox password manager so I end up having password saved in the password manager and other in Firefox and it's a mess).
Please don’t do this. For one thing, SMS is fundamentally broken as a secure delivery method. But more than that… it’s just so, so deeply annoying.
Once we're in the realm of 'you only have to remember this one password' you might as well use a password manager that unlocks with that password and does the rest for you (be it with autofill or webauthn and the likes).
Yubikeys are fine too, even as a single factor in some cases.
Literally this converted into:
1- Users abandoning on sign-ups "oh how am I supposed to find a password I will remember"
2- Users bashing us on the app store reviews: "make it super hard to sign-up" even though we only ask for username and password, not even an e-mail
3- Users logging in, liking the app, then a few months later when they got logged out for whatever reason, completely forgetting what their password was and not having a fallback e-mail.
We ended up pulling it back. We just have a small note now that says "easily guessable password" but allow them to proceed with registration.
- Our app was _deleted_ without any notice and any means of appealing (didn’t appear in the appeals page, and of course there’s no human support). We even filed a ticket and were told that they couldn’t help us because the app was “gone” in their system. Luckily we require an email address or we would have completely lost the ability to authenticate a subset of our users. - A different internal app was banned from using “Facebook Login” because we were “providing a broken user experience” — the app was not even exposed for login in our system. We couldn’t appeal because the warning notice didn’t allow responding from our mailing list. Changing the primary contact didn’t work either, and we even disabled the login on the app just in case. Still revoked with no means of getting it back.
Google has been less awful to work with, but they make you jump through lots of hoops to get public login permissions. In summary, think very carefully about a third party Oauth solution.
2. If someone has access to your email, you're screwed anyway because they can lock you out and reset every password.
Your email password, effectively, becomes the password for that website. I.e. security-wise, I think they're equivalent.
Every single one of them. Email is a plain text protocol.
This is both good and bad. When I needed a whole team to have access to my account, I just built a mailing list, and used that address for signing up. Yes, it was annoying that we'd all get email every time someone logged in on a new device, but it was also pretty straight forward to use.
edit: but infosec isn't completely equal to cryptography, so some deterrence like that will prevent some attacks. But it's like adding a real beefy padlock on your door (the hashing), and then putting a piece of tape to keep your door shut. Or putting a piece of tape over the keyhole of your padlock.
And no, pepper is not encryption. Encryption is reversible, you can decrypt the ciphertext with the key.
Hashing isn't encryption / Confidentiality isn't integrity / RAID isn't backup / Income isn't profit
Not knowing the difference doesn't mean there isn't a difference.
> An alternative approach is to hash the passwords as usual and then encrypt the hashes with a symmetrical encryption key before storing them in the database, with the key acting as the pepper.
https://cheatsheetseries.owasp.org/cheatsheets/Password_Stor...
I love workshopping copy!
How about:
To mitigate events like this, we only store a scrambled version of your password. Though your actual password can’t be simply unscrambled from the leaked data, it is possible it could be deduced by a guess and check process - especially if you are using a weak or common password.
"Scrambled" is imprecise enough that it could mean either hashed or encrypted. In radio usage, it specifically refers to encryption, so someone researching "scrambling" would get confused very quickly by that explanation.
I never hear about the term "workshopping copy" but I believe it is one of those underrated skills that is fundamental in communication online.
The only caveat is that your database isn't coupled tightly with your application code, so your pepper remains secret even if your DB is breached (which is usually the case).
Upon password creation:
1. Generate hash as hash of password + salt.
2. Encrypt the hash with a public key from KMS (you can store the public key in your server code).
3. In your database store the encrypted hash, the salt, plus some "key ID" that identifies which KMS public key you used (this is so you can rotate keys later).
Upon user login to verify the password:
1. Retrieve the user's encrypted password hash, salt and KMS key ID from the database.
2. Make a call to KMS to decrypt the hash (KMS internally stores the corresponding private key but never lets you access it).
3. Then hash the password the user entered + salt and compare it to the decrypted hash to see if there is a match.
Benefits of this are:
1. If an attacker steals your database, they can't decrypt any of the passwords or the password hashes.
2. KMS never exposes the private key of the async key pair, so you know this won't get exposed either. The only way to decrypt something is to make an API call to KMS.
3. Thus, the only valid attack really is if the attacker is able to gain the same access privileges as your server. But even then they still need to call KMS one-at-a-time to decrypt hashes, and all of those KMS calls are logged in an audit trail, so it should be much easier to see if you have anomalous calls to KMS. There is a huge benefit here in that it is impossible to do bulk decryption without a giant audit trail.
The main argument I've heard against pepper is because people are afraid of losing the pepper. It either needs to be directly in your code which is easier to leak, or out of band which is easier to lose.
edit: Does anyone else want to goto waffle house whenever they talk about salting and peppering their hash? Too bad the closest one is an hour away.
If it's just the db that is exposed though, it could be a small added layer of protection.
And yes, I would not ever do it instead of a salt.
Let me explain. for example, I might have my NextJS frontend in Vercel using it's secret management /env tools.
The backend as a vanilla node-apollo-server-express could probably be on a cheap VPS, being monitored/restarted/load-balanced by PM2.
The database would be cloud, either PostgreSQL as a Service, or Fauna or something.
Would this scenario be better than just cramming everything into a VPS and trying to get that as secure/closed down as possible and be done with it (do monthly updates and whatnot)...
I've faced recently this conundrum at job. Small new app will not have more than a few hundred concurrent users optimistically...
This isn't true, you could simply do encrypted_pw = md5(pepper + md5(password)) or whatever.
Edit: Getting a bunch of comments on this, just want to clarify that I used md5 purely to illustrate a one-way hashing function. In actual practice, you'd use something else (HMAC with SHA256 most likely).
(Ignore md5)
No, I strongly recommend not to do so. The reason you put an salt in is to prevent multiple hashs to be the same (because people use the same password) with a pepper you still protect against cross reverencing the hash with other databases, but any two users in your database will still have the same hash and people tend to reuse passwords (or similar passwords) so this is a very real attack vector to get passwords without really braking any hash fully (E.G.: user with known password on different platform => try out similar passwords => broke hash for anyone with similar password).
So a unique per hash specific salt is the most important thing to do.
Pepper/shared secret can make it additionally harder to crack any hashes as while you know all salts (they are stored alongside the hash) you don't know the pepper.
Lastly there is additional data (AD) (named sometimes differently). Which can prevent some form of hash reuse attacks where you e.g. find some form of attack which allows you to override hashes+salt in the db (but not more). Then you could rewrite all hashes to known ones and get access. Tbh for many systems if an attacker can do something like this they don't need to do that anymore. But for other (often large and complex) systems it's helpful.
The idea behind AD is that you (somehow depending on algorithm) include some additional data which needs to match. The most common example is to use the user id (if immutable) as AD so this hash+salt(+pepper) is only usable for given user and never for any other user.
If you ever write a auth sub-system for a big enterprise system I would recommend you to use salt+pepper+AD(uid), for everything else I would think salt+pepper is enough. But never should you use a hash without unique salt under any circumstance. It's always the wrong path to take.(For password hashing.)
Or at least that's my opinion.
The SHA-family cryptographic hash functions are purposefully designed for throughput, if you combine them thousands of times like in PBKDF2 they can be fine. One round of SHA256 is trivial to brute-force especially with the plethora of ASICs available.
HMAC is also completely unnecessary here, and see the article title for your variable naming: it's not encrypted_pw it's hashed_pw.
Further, there’s so little reason not to salt, so you ought to do it. It’s built in to the hash strings in most modern pw hashes. Peppers are also a great idea. Defence in depth!
There are many attack scenarios in which storing a secret separate from the DB doesn't get you much at all. Suppose an attacker finds an RCE vulnerability in the application – then they can slurp up the contents of the DB, but they can read the pepper from the configuration too.
Suppose they just have a SQL injection – they can't directly get the pepper from a SQL injection, assuming it is being stored somewhere outside the database. But, it may help them do it indirectly – for example, they could UPDATE their account to have admin privilege, and then access admin-only features of the application which may end up revealing the pepper. I've seen many apps which have admin-only screens to run arbitrary scripts, view configuration files or environment variables, install plugins, etc – those kind of features are helpful in supporting the application, but can be used to turn a SQL injection into more complete control over it
But what about having separate auth sub-service with separate database.
Who says a SQL injection allows yourself to update your account to be admin. (SQL has their own permission system even through its not used that much).
Who says making yourself application admin allows yourself to do more then banning users.
Sure for many especially smaller systems pepper won't help much and AD (additional data) is even less likely to help.
But for many (especially bigger/enterprise) systems this might very well not be the case.
Furthermore pepper usage tend to not really hurt.
I think it's a fallacy to assume just because many less well build systems allow SQL injection to escalate that all do so and pepper is useless. Especially given that most systems need to have some config secret management system anyway and as such adding a pepper tend to be somewhat cheap to to (dev effort) and doesn't really cost much at runtime either (normally).
Sure, my point was mainly about classic monolithic apps. If you split your app up into lots of separate micro-services, my point may no longer hold.
> Who says a SQL injection allows yourself to update your account to be admin.
I wasn't talking about a database superuser account, I was talking about an application-level admin. Usually there is some database table which stores user permissions, and an attacker can do an UPDATE/INSERT on that table to grant an ordinary user account full admin permissions, or even create a brand new user with those permissions. All this can happen within the single ordinary DB account used by the application (given most applications only use one DB account)
If the auth is a service accessing only via some remote access protocol that only allows a minimum number of operations that do not map directly into database commands they cannot exploit RCE in the app to get auth database.
Such service can also enforce reasonable rate limits and quotas, something that a regular direct database access can't enforce.
Salting is easier since it can be completely wrapped up in the key derivation function. The programmer doesn't have to know anything about it, they just use generate_key(passwd) and check_password(passwd, key).
Never stored, hopefully, but the website has a chance of seeing it everytime one signs in. A malevolent site or developer or admin could store the password somewhere or try to reuse it on a number of other well known sites. Hence, one different password per site to protect also against the sites themselves.
Indeed. I don't understand why challenge-response auth isn't more widely deployed, or even part of the web APIs.
Sure, it doesn't mitigate ALL attacks, but it does mitigate SOME attacks even if you're already on TLS.
I think other schemes that did a lot less had plenty of time to displace passwords if they were going to. And they didn't.
So, implement WebAuthn and have done with it.
The server would only ever have your 'public key'. I'm not sure where you get the saltiness to prevent lookup tables but still let me log in from three devices with the same credentials.
https://blog.cryptographyengineering.com/2018/10/19/lets-tal...
This approach is sometimes called a "Deterministic password manager" and that might be the phrase you wanted.
There are several problems with this approach, especially with regard to the need to sometimes change passwords.
But the point your parent was making is that in the modern era (certainly this century) none of this was necessary, there are asymmetric PAKEs which render it unnecessary for a site to know your password at all in order to confirm that you still know what it is.
Preferably one generated by a password manager, large and random and totally unrelated to any other password of the user.
[1] Napkin math: Single Titan RTX does some 65GH/s of MD5, so if you have 80bit password it would take in the order of 2^80/65e9 seconds = 500e3 gpu-years to crack
grind up a cow. store the ground beef somewhere
when a user wants to login, grind up the new cow in an identical manner.
compare the new ground beef with the stored ground beef.
if match (the new cow is a clone of the old cow), authenticate
You take your letters and substitute them for numbers, A = 1, Z = 26.
Like a checksum, you add all the letters together. The same word produces the same sum each time, but if I had the sum, I wouldn't know for certain what the original word was.
Unlike a pepper it is possible to change the encryption key if it is leaked. I don't think changing a pepper for existing hashes is possible, but if they are encrypted you can just reencrypt them with the new key.
So is there an obvious downside I'm not seeing to hash with a salt and then encrypt?
The downside for the scheme is complexity and limited upside; complexity gets a lot more attention when it comes to security considerations.
Best practice especially needs to be simple; it's easy to mess this stuff up and hard to understand. A lot of the comments on this post betray a very poor understanding of password storage; they simply haven't come across the correct information.
Overall pepper is good as long as you include salt. There are times when the db gets leaked and the env variables don't.
There's nothing wrong with your scheme if it's implemented properly, but being able to change the site-wide key is a limited upside compared to using a pepper. There is an upside though.
And all of this doesn't matter much as long as you do the bare minimum of using a tuned pbkdf+salt and keep your stuff patched.
Just make sure you use a suiting AES mode. If it turns out that you xor'd all hashes with the same stream that depends on your pepper only, it's not really helpful :).
One, slightly longer password checks. And two, the temptation to lean on the AES key and set the cost of the hash too low. In the case the key does get out - we had an entire era where people stole environment variables from servers - then you decrypt the entire password file once and have cheaper guesses per second.
Maybe the real question is why use a pepper over encryption?
They have the same downside (as you mentioned) but at least you can change the encryption key without having all the users change passwords. I don't see any advantage in using a pepper over encryption, except maybe implementation complexity.
Like any disaster preparedness situation, make sure your strategy doesn't count on an asset you've already listed as unavailable.
Often you cannot do better in explaining it without doing a mini course. And people would have to sit down, concentrate and work through the new concepts and that's tiring, looks like school, "I was never good at math", and you lost everyone. You can't make the average person understand hashing, mainly because the don't care and will glaze over. You can dress it up with engaging stories and metaphors, and they will remember the engaging story but not actually build the right mental model if you actually poke at their understanding.
If your email is compromised, the attacker can request a password reset, then log in that way.
Why isn’t it common to use “login emails” with a one time token login buttons in the email?
The only downside I see is that it is harder to log in on a machine where you do not want to access your emails; for example like this:
On the machine with no email access the site would have to show a qr code, and a phone where you are already logged in would have to scan it, to approve the login.
Is this any less secure, or is it just not feasible for average users to understand?
What am I missing?
Effective security is tailored to the situation: the app, the users, and the adversaries.
Login emails are slow and require multiple steps. The user must enter their email into the website, switch to their email client, wait for the email, open it, and click the link. If the user's email goes down, they cannot log in to the website. Some folks get distracted while waiting for the email. Sometimes a login email will get marked as spam. Sometimes a user permanently loses access to their email account. These things reduce user engagement and increase support costs, and the company makes less money.
There are many ways for attackers to obtain email: DNS, BGP, email server, email server backups, user device backups, malware, re-used passwords, and phishing.
There are only a handful of ways for an attacker to obtain passwords: malware, password re-use, and phishing. Notice that this is a subset of the attacks on email. And passwords have special mitigations. Some devices have password managers that resist malware. Security teams have various options for reducing password re-use.
Good authentication depends on something you know (password) and something you have. Password managers turn something you know (password) into something you have (device). Criminals rarely steal devices to gain access to online accounts. So in practice, something you have is just as good as something you know.
What I dont get is how having smaller attack surface for losing a password, and using a secure password manager mitigates the attack vector of getting access to my account with a password reset through my compromised email.
If I understand correctly you say that email is more vulnerable, so this only strenghtens my point I guess?
1. Extra security checks. For example, if you buy a new laptop and use a coffee shop's wifi try to reset your bank password, they will lock your account. You will have to call and talk to a person and give extra personal information to get it unlocked.
2. Notify the user about the password reset. Use email, text, phone call, and postal mail.
3. Automatically lock the account if suspicious activity occurs in a time period after password reset. Examples:
- Orders over $100 shipped to new addresses.
- Risky transactions: buying gift cards, buying plane tickets in foreign countries, changing the delivery address of a shipment.
- Using a known device (with cookies/fingerprint) and the old password.
4. Require extra confirmation for transactions. Examples: re-enter credit card numbers, security codes, and personal id numbers (SSN in USA).5. Preserve user data so it can be restored to the state before the password reset.
These mitigations work well enough for protecting accounts from fraudulent password resets.
Doesn't this answer your own question? (ideally email password reset should also require MFA)
As another, non-security point, occasionally it can take a good few minutes for emails to arrive in your inbox. Though to be fair, that's sometimes the case for SMS too.
If you can log in with a password, you have 1 way to get hacked (lose the pw).
If you can also log in through a pass reset, then you have 2 ways to get hacked.
MFA helps, but if I remember correctly Troy shared disappointing statistics about it’s usage by the general public.
The distinction between encryption and hashing can never get too much education, both for the end users and the more technical developers/sysadmins.
This is correct, but I am going out on a limb and guessing that legal counsel had something to do with the wording here (which is perplexing because I tend to expect legal definitions of terms to be more specific).
I was at an organization that also had a data breach, and legal counsel advised us to write a similar email when disclosing publicly that the breach occurred. I was personally on multiple phone calls with legal counsel about this, and it was quite frustrating to try and explain the difference between encryption and hashing, or stay on point with the fact that our passwords were not encrypted, trying to get people to stop using that word on phone calls. Early on, they'd ask questions like, "But aren't your passwords encrypted?!" And you'd have to explain, no, they're not, they're hashed, which is most likely better than encrypted (although I'm open to being proven wrong on that).
They were, also, mostly useless on explaining what their perspective of encryption was. I never got an explanation from counsel, and at best, I was linked to a blog post that suggested some security best practices (not a legal definition of anything we were liable for).
The sad thing is, with a data breach like that, you probably do (and should) feel terrible for your customers, anyone who trusted you with their emails, passwords, etc. But the laws surrounding it are confusing enough to make it easy for some people to push this out of their mind and just focus on, "What is the best thing we can do to legally cover our asses?" Even if that means saying factually incorrect or misleading things like, "Your passwords were encrypted."
A password hash is a representation of your password that can't be reversed, but the original password may still be determined if someone hashes it again and gets the same result.
Compare to:
A hash is like a fingerprint of your password. Your fingerprint tells me very little about you. You might be a man or a woman, tall or short, young or old. But if you show up, I can tell that you still have the same fingerprint. Likewise a hash doesn't tell me your password, but if my computer keeps guessing them, it can know when it is right. And my computer guesses really, really fast.
For the record I just asked my teenage son who doesn't know what a hash is whether he understood either explanation. He understood mine, but not Troy's. And he's a smart kid. If he doesn't understand an explanation, I'm pretty sure most adults won't either.
> > but if my computer keeps guessing them, it can know when it is right. And my computer guesses really, really fast.
And as far as operational security is concerned, this fixates on just that one threat that the author talks about at the end, which depends on weak password.
Wonder which one your teenage son likes better? Of course the answer can be skewed one way or the other knowing which one was written by his parent :-)
A good hashing algorithm today could be useless down the road if computation becomes orders of magnitudes faster, or RSA becomes trivial to reverse, etc. Similar to how MD5 was initially designed as a cryptographic hash function, but isn't considered one today.
I think the idea "Well my password was encrypted, so why should I have to change it?" seems a bit silly.
I want to log in everywhere with my iPhone. My iPhone has my FaceID stored locally, so in order to log in somewhere with my account someone has to be in possession of my iPhone first. That's the 1st factor.
Secondly they have to be me, or at least somehow fake my face so that my iPhone can match my FaceID. That's the second factor.
That is already a super convenient two factor authentication scheme. Why can't websites not send a request which invokes my iPhones two factor auth model to log in?
Passwords AND password managers should be made redundant.
Your face is only authenticating you to your device because that's what you chose. If you don't want that (e.g. your identical twin sister loves pranking you) you can just use a different authenticator. The remote web site deliberately has no idea your face was involved, it just knows your identity was verified on its behalf by the hardware storing your private key.
I can have a near infinite number of passwords, but I only have 1 face, or 10 fingers. When all of my fingerprints are compromised, and the system only allows fingerprint login, now what do I do ?
'Who you are' is your username. 'Are you allowed into this system' is your password.
Why should they be expected to know? They are receiving an email from a professional IT specialist who couldn't even figure out how this stuff works.
It's the vendor's job to get it right, and lawyers and activists's role to hold them accountable.
The only thing that bothers me here (not sure why) is something about the fact that if the user changes their email you get a pass change as well and that might signal an account take over if your system is analyzing behavior stuff like that. Could be wrong on my gut feeling here.
The email is the salt. It's different for every hash which is all that's needed from a salt.
So just generate and store a random salt instead.
> Making a password hash gives you a scrambled text that nobody can turn back into your password but that anybody can use to check if a password guess is your real password.
This uses the folk understanding of entropy to be more memorable in a non-misleading way. You can't un-scramble an egg hash.
It's good that they suggested changing passwords, though. I have a feeling that if you call them out they're going to go back to "the passwords are secure because they were encrypted".
So naively i understand that a non-salted hash for "password" is a terrible idea, since two peoples hashes for "password" will be the same..
but i still struggle with the practical safety this gives in db breaches where the salt is in the breach..
Troy seems to say that this makes the cracking process slower, which think i see...
but is it fair to think that the KEY ISSUE is the uniqueness of the hashing function for any given input string?
They are just trying to avoid a quick lookup in a pre-computed table. Adding a salt means they have to start from scratch.
Uniqueness is not really a factor, reversibility is. Given a hash will be fixed-length, and passwords can be an arbitrary length, you get a very large number of passwords mapping to each hash. But the key is to make them hard to find.
So for the server it's good to have a strong (which often means slow to compute) and non-broken scheme. Something like MD5 is just too fast to compute, if someone is targeting you in particular (and not the entire breach) you might have a bad time anyway. Some schemes have a work factor meaning the computer basically repeats calculations a lot to waste time, which a cracker would also have to do. This factor can be updated to keep up with computing power over time.
On the client the best you can do is not reuse passwords, make them long, and try not to overlap with any known wordlists (dictionaries, past breaches, etc).
Having a salt means that the universe of password:hash correlations is different for each password entry.
So am i still in the right mindset to think that the "uniqueness" of every hash/ lack of collisions is still a valid area?
ie that the hash function is really unlikely to produce the same hash twice....
> Take, for example, the following password:
> P@ssw0rd
> This is a good password because it has lowercase, uppercase, numeric and non-alphanumeric values plus is 8 characters long.
Calling it a good password, even with the later caveat that "hackers have worked [character substitution] out", does not seem to make sense:
It's Time to Kill Your Eight-Character Password https://www.tomsguide.com/us/8-character-password-dead,news-... "Any eight-character password hashed using Microsoft's widely used NTLM algorithm can now be cracked in two and a half hours."
> The hackers have worked this out too which is why arbitrary composition rules on websites are useless.
Either you stopped reading 1 sentence too early, or you are posting in bad faith to try and smear Troy.
FWIW there are ASICs now that will get orders of magnitude faster hash throughput than your servers.
Edit: I think TFA might be being facitious in the claim "This is a good password because it has lowercase, uppercase, numeric and non-alphanumeric values plus is 8 characters long.", although it doesn't communicate that very clearly.
The immediate answer is that Microsoft built the systems this is discussing last century and at the time this wasn't highlighted. Both the LANMAN and NT schemes are from the era when Microsoft was just getting into stuff like remote authentication that we now take for granted as a baseline.
Even though it's probably true this is an unsatisfying answer because the Unix password hash (at least a decade older) is stronger, using 12-bit salt and a deliberately pessimized hash algorithm.
A further (and longer lived) excuse for Microsoft is that they strongly favour backwards compatibility which has seen their company be very successful over a long period. Having accepted this poor scheme in the 1990s it was hard to give it up and annoy millions of users.
One of the grave mistakes Microsoft made a little later is that they began relying upon these password hashes as secrets themselves, and that's where it starts to get interesting, because that's a sign that key people at Microsoft didn't know that they didn't know what they were doing. That is, not only did Microsoft not have people who were competent to do this properly, they didn't even have people who knew they needed those people.
User PC gets owned, attacker elevates to admin, now has access to IT Support hashes cached locally which can be sent to other devices directly to authenticate.
Obligatory xkcd comic link: https://xkcd.com/936/
Since GDPR I tend to encrypt all not searchable data (address, sometimes even names) in an encrypted JSON, including the password hash.
Someone accessing my database will just have an integer ID, a hashed login and an encrypted field.
Not sure if it’s enough, but it seems ok to me.
It lead to this XCKD comic:
If we use MD5(password) then brute force of a 14 character random password (say using a 64 symbol character set) isn't really viable because you need to try about 2^84 values. MD5 isn't an acceptable password hash, but using a strong random password was enough to save us.
But if we use LMhash(password) that same password can be brute forced in just 2^43 operations. This design is so bad that there's no way for the user to protect themselves.
This popularized Rainbow Tables. You may use a time-space tradeoff for any hashing scheme that doesn't have salt, or doesn't have enough salt compared to how much it's used, but for most schemes a strong random password overwhelms the power of the time-space tradeoff anyway. Rainbow Tables tilt this tradeoff so that it's more favourable in exchange for a modest reduction in effectiveness† and for LANMAN they're enough to turn it from "If you had a super computer and hundreds of gigabytes of disk space you could crack any Windows password hash near instantly" to "If you have a mid-range PC with 5GB of hard disk space and download this software you can crack 99.9% of Windows password hashes in a few minutes".
†For a lot of pre-computation effort you can get all the effectiveness back. But that's not important here.
There were other lessons too, but that was the main one.
I've found about scrypt and LZ-String, but not sure what would be best practice here.
I don't know why you are base64 encoding things before sending them to the DB. Just use a binary blob.
scrypt is a hashing algorithm, not an encryption algorithm. So that doesn't seem like what you want.
LZ-String is a compression algorithm, that's trivially reversible.
The problem you'll run into is that the "right" encryption algorithm is constantly changing. Probably the best thing to do would be to not do it yourself, instead, rely on encryption capabilities of your DB if provided. If you opt to doing your own encryption, then be prepared to constantly maintain and update it. Pushing that responsibility onto the DB makes that burden a simple "make sure your DB is up to date" Which you should be doing anyways.
If you use scrypt, you won't be able to get the file back out ever again.
If you use lzma, it's compressed, not encrypted, and anyone who gets the compressed data can trivially decompress it.
Consider using an nacl secretbox if you need to encrypt it.
Consider very carefully where you'll store the password.
Does the user input it each time they access the file (in which case use a key-derivation-function on their password)? Do you encrypt it with an application key? Per-user key stored in vault? Do you have a hardware encryption tool available (an HSM) or something like aws KMS?
Your encryption is only as secure as you keep the encryption keys.
See also [0] for some suggestions.
[0]: https://latacora.micro.blog/2018/04/03/cryptographic-right-a...
For now I'm most worried about db being leaked so would look into db encryption and prob I will go with application-key
scrypt is a popular KDF, i think you'll be fine with that.
If that makes sense...
Why is the auth database a part of the application to begin with? Why is it not externalized away behind a single service with a bare minimum "set-password/is-this-my-password/trigger-x" endpoints exposed to the application with per route/per source/per question rate limiting? This is 2020, not 2001.
It's not just because the decade counter changed that everyone must rewrite their systems using the latest fad.
The comments of this blog post have some really really good suggestions how someone can much easier explain a hash that even children would understand:
> A hash is like a fingerprint of your password. Your fingerprint tells me very little about you. You might be a man or a woman, tall or short, young or old. But if you show up, I can tell that you still have the same fingerprint. Likewise a hash doesn't tell me your password, but if my computer keeps guessing them, it can know when it is right. And my computer guesses really, really fast.
Troy completely dismisses this because it's not 100% scientifically correct in the analogy. IMHO it's good enough for the layman to understand though which is the point of his blog post no?
It strikes me that he's unable to admit that someone might have done something slightly better than him, or just give credit where credit due.
Reminds me of so many other blog posts where this happened as well and his infamous claim that HTTPS is faster than HTTP and when people call him up on it he argued that HTTP2 is faster than HTTP1 and going in circles...
Arrogance annoys me so much that I actually dislike reading his posts...
The author thinks passwords are not encrypted on Wattpad, because they ask you to change passwords on other sites where you have used the same password. The reason is more likely that Wattpad uses a common encryption algorithm. The hackers chance of gaining access to your other accounts using the same password is now much higher, especially if you use a relatively easy to guess string. Because using a fast computer they can run through common encryption algorithms with each guess of your password at their leisure... Once they have a match, they can login to your other sites.
Also hashing is nothing like encryption. To clarify hashing, is used to map very large data types to far smaller ones of just a few dozen (or few thousand) character strings, for the sake of speedy lookups. Hashing algorithms are not one way, you can determine the possible input values used to generate the hash. In the case of (relatively speaking) very small input data types like passwords, there is likely a 1:1 ratio of input password to hash, making it effectively a plain text password. So why would anyone use it? What evidence is there to suggest Wattpad would use an obviously ineffective method for encrypting passwords?
So the statement, "a password hash is a representation of your password that can't be reversed" and other statements about the security of hashing, is just incorrect - for passwords. I agree that hashing is statistically 1-way for large inputs like big strings or images, since then the possible inputs that match to a particular hash is very very large. It is not so for small ones, like passwords, where the data type is smaller/similar in size to the hash range.
Cryptographic hash functions are one-way in the sense that (unless they are shown to be broken) it is not believed that there is a computationally tractable way of recovering the unhashed input from the hash. You can always brute force it, but even "just" for passwords, the input space is way too big for that, especially if you use a salt - unless you use a very common password, of course (even if limited to 26 letters and 8 characters that's over 200 billion different passwords).
So, most of your comment is just wrong, except for the part about how Wattpad stores passwords, which is just very likely wrong, since I can't prove it.
Of course, if you're using a fast cryptographic hash function then someone with a good GPU can throw a surprising amount of brute force at the problem. A Tesla M60, which is five years old, can do about 1.4 billion SHA-256 hashes per second; Amazon will rent you a server with one of these for $0.75/hour, and cracking a single 8-character lowercase alphabetic password should take about 2.5 minutes at most. Half that on average.
(Functions like bcrypt help with this by being designed for slowness, and newer ones like scrypt also try to use large amounts of memory with unpredictable access patterns so they're harder to accelerate with GPU/FPGA/ASIC hardware.)
In real-life situations, the input space is much larger still (if you account for longer passwords, case sensitivity, special characters etc.), as long as your passwords are truly unguessable. And at some point, even a very fast hashing algorithm won't be able to keep up. I don't know the exact calculations, but I would expect MD5 to still be hard to break for truly strong passwords (say, 20 random characters). The problem is more that people don't actually choose strong passwords most of the time.
Because once you salt it (use a different salt for each hash, which solved your collision issue) and purposely slow it down (through multiple rounds,etc) it effectively ruins precomputing the hashes because of how many permutations there are.
Of course this depends on which hashing algorithm you use. Md5? You can do millions a second. Bcrypt? You can make one hash take 100ms, that’s 10a second. They also use a random salt for each hash - so precomputed hashes will only work for that hash.
The issues you highlighted are very real for md5, but there’s a reason md5 is not recommended for passwords.