News for hackers. Stuff that matters.
Re:Security Update by robomc on Thursday May 16, 2019 @10:42PM (#19935763)
They don't have to store them as plain text for it to be a problem.

If they're not salted it's trivial to crack the hashes, and if they are all uniquely salted, while it's time consuming, they can still gradually crack them.

Given that you could probably sift through the users to find particularly juicy targets (usernames of maintainers of top open source projects with github repos for example?) that could justify the work of a time consuming attack on the hashes.

Re:Security Update by jve on Friday May 17, 2019 @02:10AM (#19936732)
Of all the sites and people, I expect Jeff Atwood and Joel Spolsky to have followed best practices in storing user passwords.

Jeff wrote this in 2007:

> Do not invent your own "clever" password storage scheme

> Never store passwords as plaintext.

> Add a long, unique random salt to each password you store.

> Use a cryptographically secure hash. I think Thomas hates MD5 so very much it makes him seem a little crazier than he actually is. But he's right. MD5 is vulnerable. Why pick anything remotely vulnerable, when you don't have to? SHA-2 or Bcrypt would be a better choice.

https://blog.codinghorror.com/youre-probably-storing-passwor...

Another topic on passwords: https://blog.codinghorror.com/the-dirty-truth-about-web-pass...

Re:Security Update by dagenix on Friday May 17, 2019 @03:39AM (#19937241)
> SHA-2 or Bcrypt would be a better choice.

As the sibling comment points out, SHA-2 is worthless for storing passwords. A GPU can crank through an obscene number of SHA-2 hashes per second. Bcrypt is is intentionally much slower and harder to use a GPU to brute force. The two algorithms are almost totally unrelated and it's concerning they were mentioned together.

Re:Security Update by killjoywashere on Friday May 17, 2019 @04:03AM (#19937356)
To be fair, Jeff's post was written in 2007 ... this predates Khanna's PS3 clusters. CUDA was released the same year. So I'm not sure it would be obvious in 2007 that SHA-2 would be "worthless for storing passwords".
Re:Security Update by dagenix on Friday May 17, 2019 @08:42PM (#19944887)
PBKDF2 seems to have been specified in 2000 as part of RFC 2898 [1] and, IIRC, existed before then. Bcrypt is from 1999 [2]. Both of those algorithms were explicitly designed to be slow. My understanding is that PBKDF2 wasn't explicitly designed for password storage, but that it was recognized as being useful for that early on. Bcrypt was explicitly designed for password storage. The article referenced came out 7 years later. IMO: there was evidence that salted SHA-2 was not secure.

[1] - https://tools.ietf.org/html/rfc2898#section-5.2 [2] - https://en.wikipedia.org/wiki/Bcrypt

Re:Security Update by viraptor on Friday May 17, 2019 @07:24AM (#19938455)
> SHA-2 is worthless for storing passwords

It really depends on what the person means. Yes, single sha-2 hash is pretty useless. But that's often not what's really happening. For example libcrypt is used in many cases with the default $6$ format which uses thousands of rounds of sha512. That's still "password hashed with sha-2".

Re:Security Update by dagenix on Friday May 17, 2019 @08:35PM (#19944857)
If that were the case, his advice ought to have been something like "use libcrypt with SHA-2" or something like that. Just "use SHA-2" was kinda useless in 2007 and hasn't gotten more useful since then.
Re:Security Update by TeMPOraL on Friday May 17, 2019 @03:56AM (#19937326)
Sure. But that advice was written 12 years ago. I'd be surprised if they didn't update their password storage since then.
Re:Security Update by krzyk on Friday May 17, 2019 @05:14AM (#19937727)
How do you update password storage if you don't store the passwords only hashes?

You could upgrade it for new users, but for old ones? (e.g. I don't change passwords often)

Re:Security Update by EvilTerran on Friday May 17, 2019 @05:47AM (#19937914)
When a user whose password is hashed the old way logs in, after checking the password they just supplied against your stored old hash but before forgetting the plaintext, you can compute the new hash & update your records.

Of course, that only works for active users - it won't upgrade anyone that never logs in. Depending on just how weak the old hash is, you may want to eventually cut off any lingering un-upgraded accounts: just forget their old hash, requiring them to go through your password reset process should they ever come back. If you've left it long enough, those accounts will probably never be used again anyway, so that should be NBD.

Re:Security Update by ShinTakuya on Friday May 17, 2019 @05:37AM (#19937851)
I updated a DB from MD5 to BCrypt at my last job. Essentially on the next login I updated the password (since the password isn't hashed on the client end). So all active users got switched over. After a relatively short period I reset the remaining passwords and forced users to send password reset emails to login.
Re:Security Update by erpellan on Friday May 17, 2019 @05:45AM (#19937908)
Onion hash: hash the existing hash with the new algorithm.
Re:Security Update by hopscotch on Friday May 17, 2019 @06:08AM (#19938029)
That throws away entropy, but I suppose so long as very few hash collisions of a password are likely to be real passwords themselves it would be harmless.
Re:Security Update by Crinus on Friday May 17, 2019 @05:32AM (#19937828)
You could rehash the password the next time the user logs in.
Re:Security Update by TeMPOraL on Friday May 17, 2019 @05:31AM (#19937819)
You ask people to change their passwords, and when they do so, you store them with the new scheme. You can do that by e.g. requiring everyone to change their password on their next login/visit.
Re:Security Update by icebraining on Friday May 17, 2019 @10:08AM (#19939735)
You don't even need to ask people to change their passwords; when they login, you have a copy of the original password, so you can just store the new hash over the old.
Re:Security Update by bluedino on Friday May 17, 2019 @08:13AM (#19938738)
If they aren't salted, just generate your own rainbow table!
Re:Security Update by blowski on Friday May 17, 2019 @03:57AM (#19937330)
He wrote it in 2007.
Re:Security Update by dagenix on Friday May 17, 2019 @08:47PM (#19944898)
He said to use Bcrypt or SHA-2. One of those algorithms was explicitly designed for password storage, the other was not. They aren't really the same class of algorithm. As such, it doesn't really make sense to suggest one as an alternative to the other. Nobody ever suggests uses Bcrypt as the hash in a hashtable - even if it technically could be made to work. GPUs that could crank through trillions of hashes per second might not have existed, but, that doesn't make it good advice. Good advice would have been "use bcrypt or, if you can't, PBKDF2 (or maybe some other library that implements a variant of one of those)"
Re:Security Update by tgsovlerkhgsel on Friday May 17, 2019 @03:31AM (#19937193)
> MD5 is vulnerable. Why pick anything remotely vulnerable, when you don't have to? SHA-2

For the purpose of hashing passwords, there's no significant difference between MD5 and SHA-2. Both are awful choices.

Edit: Actually, SHA-2 may be worse because CPUs have hardware acceleration and thus the attacker may be able to crack it somewhat faster than MD5.

Re:Security Update by zenexer on Friday May 17, 2019 @09:31AM (#19939402)
It’s definitely not worse—MD5 is faster with GPUs—but plain SHA-2 isn’t much better, either.
Re:Security Update by bigiain on Thursday May 16, 2019 @10:59PM (#19935829)
Also "Some level of production access" could easily include the ability for the attacker to intercept and exfiltrate passwords as users log in.
Re:Security Update by adrianN on Friday May 17, 2019 @02:09AM (#19936728)
I haven't checked in a while, what's the cost of cracking a single salted password that is stored properly, e.g. with pbkdf2 or bcrypt or whatever is currently state of the art?
Re:Security Update by tialaramex on Friday May 17, 2019 @02:45AM (#19936902)
"Cracking" isn't a meaningful operation for these algorithms. You would need to try guessing, if you don't know anything about the password then you need to guess all possible passwords until you get the right one or a collision (the pigeon hole principle applies)

If my password is "password" you can probably guess that almost instantly no matter what scheme is used. If my password is 32 characters of random base64 output then it wouldn't matter if the scheme is MD5($password) you won't guess it.

Schemes like PBKDF2 and bcrypt trade something useful in the middle, if your password is mediocre they make it too hard to bother guessing. But you'd need to define how mediocre it is to get a meaningful estimate.

Re:Security Update by lucb1e on Friday May 17, 2019 @02:41AM (#19936876)
The cost? That depends on the password. How long does it take to crack 123456? That depends on the parameters.

In a good case, it takes 50ms per hash on a modern system, so that's 20 attempts per second (instead of 20 billion per second for a plain md5 or so). I don't really expect a popular site to do much more than that, so that's the best case. From experience, most sites will be more around the 20 billion mark than the 20 mark, but I expect stackoverflow to be on the good end.

The current state of the art is Argon2, with scrypt second and bcrypt/pbkdf2 tied for third. The first two have memory hardness, and the first one is the standard chosen in the password hashing algorithm competition. The third is still acceptable because most developers still go for a salted single hash like sha256. Somehow they got the salting method, but I'd rather they break all identical passwords at the same time (they weren't that strong anyway if they're shared between more than one person) than that they crack only a tiny percentage because of the cost. Slowness helps more than salting, yet as a pentester I see more of the latter than the former. So I'd rather recommend something available for their platform as a good third choice than them going "meh, effort" and not implementing the recommendation.

Re:Security Update by bmn__ on Friday May 17, 2019 @05:04AM (#19937676)
> The current state of the art is Argon2

Details for the interested implementer: there's a lot of bad software floating around out there, be careful and do your due diligence.

Use the argon2id function. If the language binding does not expose the argon2id function, but only argon2i and argon2d, then it's outdated, avoid. If the library has not been updated past 2016 (argon2 v1.3), it's vulnerable, avoid. (Some language bindings ship with an embedded library.)

Language bindings to the argon2 library do not document how to pick good parameters because language binding authors do not understand nor care about security, the suggestions in the synopses are laughably undervalued. Compare with the expert recommendations in https://password-hashing.net/argon2-specs.pdf chap. 6.4, 8, 9 and https://tools.ietf.org/html/draft-irtf-cfrg-argon2#section-4 .

Algorithm for picking the correct values on the target server hardware:

    const PASSPHRASE := 6 random words from dictionary
    const SALT := 16 bytes from urandom
    const DURATION := 0.5   ### or greater; this is the maximum amount
                            ### you are willing for your user to wait
    mut T_COST := 1
    mut M_FACTOR := concat(4096, 'M')
    const PARALLELISM := `nproc`
    const TAG_SIZE := 16    ### bytes, or 128 bits

    while {
        const TIMER := benchtime argon2id(
            PASSPHRASE, SALT, T_COST, M_FACTOR,
            PARALLELISM, TAG_SIZE
        )
        if TIMER > DURATION {
            if 1 === T_COST {
                reduce M_FACTOR     ### e.g. divide by a constant
                jump to top of while
            } else {
                jump out of while
            }
        }
        print T_COST, concat(M_FACTOR, 'M'), TIMER
        T_COST := T_COST + 1
    }