News for hackers. Stuff that matters.
Re:Simply Secure PHP Cryptography by stephenr on Thursday July 13, 2017 @02:41PM (#14763957)
> use hashing for password storage

As opposed to...?

Re:Simply Secure PHP Cryptography by aruggirello on Thursday July 13, 2017 @03:04PM (#14764179)
PHP has had a dedicated password hashing function since version 5.5: it's password_hash().

But at least, if you want to roll your own password hashing, do it right: use hmac, salting, stretching and a decent hash function - or use bcrypt/scrypt and save yourself a few headaches.

Re:Simply Secure PHP Cryptography by stephenr on Thursday July 13, 2017 @03:08PM (#14764215)
I'm well aware of that. The original comment suggested that password hashing is bad, I was trying to identify what the poster thought should be used instead.
Re:Simply Secure PHP Cryptography by idlewords on Thursday July 13, 2017 @03:22PM (#14764327)
Re:Simply Secure PHP Cryptography by CiPHPerCoder on Thursday July 13, 2017 @02:43PM (#14763970)
I assume they meant the use of a cryptographic hash function (which is wrong) instead of a password hash function (which, as the name implies, is suitable for password storage).

For example, I see a lot of this construction in proprietary code:

    $passwordHash = md5(md5($password) . md5($salt));
    if ($storedHash == $passwordHash) {
        // Authenticated successfully
    }
I'm quick to find these offending snippets and migrate our clients to use password_hash() and password_verify().
Re:Simply Secure PHP Cryptography by duskwuff on Thursday July 13, 2017 @02:48PM (#14764010)
Or, for that matter...

    SELECT * FROM user WHERE username = '$username' AND password_hash = MD5('$password')
Re:Simply Secure PHP Cryptography by chx on Thursday July 13, 2017 @06:46PM (#14765967)
Surely not after all these years! Does this easy SQL injection still exist...?
Re:Simply Secure PHP Cryptography by bitexploder on Thursday July 13, 2017 @08:13PM (#14766446)
Yes. Even in places where people use prepared statement and things like LINQ to build queries, somewhere someone will end up wanting or needing a query that is hard to express so they will start string building a raw SQL query and forget or not know to use prepared statements. We see this /all/ the time on our assessment of our customer's software.

It is markedly less common, but still quite common, if not pervasive like it used to be. PHP apps are dramatically more likely to have security vulnerabilities of any sort. It is a running joke we have that one of our recommendations to remediate security issues with PHP is to "rewrite in a different language". For whatever reason PHP has a history of encouraging vulnerable code. Even in good shops. PHP itself isn't really to blame (it is, of course much less likely for an experienced shop to write crappy PHP... but they probably wouldn't pick PHP to begin with).

Re:Simply Secure PHP Cryptography by duskwuff on Thursday July 13, 2017 @09:25PM (#14766750)
What deserves a lot of the blame is the awful mysql_* API, which didn't support query placeholders. (The mysqli and PDO APIs weren't available until much later, and weren't reliably available on many web hosts for even longer.) This forced PHP developers to become comfortable with constructing SQL queries as strings -- a habit which proved hard to break for many of them.
Re:Simply Secure PHP Cryptography by zaphar on Thursday July 13, 2017 @08:01PM (#14766378)
If you only knew the horrors I've seen. This week no less...
Re:Simply Secure PHP Cryptography by yjftsjthsd-h on Thursday July 13, 2017 @02:46PM (#14763992)
Perhaps no salt?
Re:Simply Secure PHP Cryptography by owenmarshall on Thursday July 13, 2017 @02:54PM (#14764077)
Salts don't save you from an attacker who can calculate millions of hashes per second on a GPU.

Using bcrypt/scrypt/Argon2id does.

Re:Simply Secure PHP Cryptography by wongarsu on Thursday July 13, 2017 @07:19PM (#14766122)
Salting is incredibly effective. Without salting, the entire power of the attacker can be used against all password hashes at once. With salting, those millions of hashes per second translates to only being able to crack simple passwords, or only the passwords of a few users.
Re:Simply Secure PHP Cryptography by tedunangst on Thursday July 13, 2017 @08:24PM (#14766492)
Except in the case of MD5, it's billions, many billions, of hashes per second, which translates to cracking lots of users' passwords.
Re:Simply Secure PHP Cryptography by TheRealPomax on Thursday July 13, 2017 @05:08PM (#14765264)
Salt is not intended to save you, just to make unhashing the next user's password just as much work as the one you just cracked.