Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61896 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72346 invoked from network); 31 Jul 2012 16:21:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2012 16:21:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qc0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:44503] helo=mail-qc0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/8F-00342-E0608105 for ; Tue, 31 Jul 2012 12:21:34 -0400 Received: by qcmt36 with SMTP id t36so4494106qcm.29 for ; Tue, 31 Jul 2012 09:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Qf4RsE/ORmbbWQ9lXLFv80wDC7ZEYhLZhx6aIIQf7qM=; b=uvaVoSxOus76dGNRJ6GoTJB1Fvee7St1/e24Yx93nFhXokd7u0E6NdV02jLCF0gTFa oyqIdurEZ8YvnO8m6KlI2cBJFch6/Og8G3YqaIo06VoRs/kyfI9jwnp88nRWXNjW4ova SY4jf/dELMFnwwT7Yy136APjjXTDix7LM2oxfRaqUUPW+s2CtbZq/BgY0jI8eGL9299I kilhrO8SUWN3mOcIxS1qMZpMtDu1vPSUnqEFEdLpVByEBdV6f0qcIyTkACm19mLdi8ux 1C86zL2YerJt53kgxGDD55S4YI7Wiloj7NZuKHrPVVqNRcgyD040QzjY4WW5gdhkumGl BAFA== MIME-Version: 1.0 Received: by 10.229.136.130 with SMTP id r2mr7674417qct.132.1343751691836; Tue, 31 Jul 2012 09:21:31 -0700 (PDT) Received: by 10.229.182.4 with HTTP; Tue, 31 Jul 2012 09:21:31 -0700 (PDT) In-Reply-To: <00b701cd6f35$b2d621a0$188264e0$@com> References: <4FFF1831.8070902@sugarcrm.com> <005101cd6f18$9da38510$d8ea8f30$@com> <009401cd6f28$b71c69c0$25553d40$@com> <00b701cd6f35$b2d621a0$188264e0$@com> Date: Tue, 31 Jul 2012 12:21:31 -0400 Message-ID: To: Jonathan Bond-Caron Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=00248c768f92421c5404c62292bf Subject: Re: [PHP-DEV] [PROPOSED] password_hash RFC - Implementing simplified password hashing functions From: ircmaxell@gmail.com (Anthony Ferrara) --00248c768f92421c5404c62292bf Content-Type: text/plain; charset=ISO-8859-1 Jonathan, On Tue, Jul 31, 2012 at 12:01 PM, Jonathan Bond-Caron wrote: > On Tue Jul 31 10:54 AM, Anthony Ferrara wrote: > > > > On Tue, Jul 31, 2012 at 10:28 AM, Jonathan Bond-Caron > > > I strongly disagree with this, the 'pepper' IMHO is a best practice > > for web applications. > > > > Again, I have not seen this being said by any security or cryptography > > expert. > > > > Like I said IMHO, I'm not a security expect but I do think there needs to > be > modern discussion around 'web password hashing'. I'm not against discussion. I'm against core implementations (or recommendation) of non-vetted cryptographic processes... > > > > Ok. So I register an account before I get the database. Now the only > thing > that I need to crack is the pepper (since I know the salt, hash and > original > password for my sentinel account). > > Fair enough ;) > > It can still be a problem if the pepper is large + the crypt() salt > > > > With all of that said, if you really want a secret in there, don't > > hijack the hashing algorithm to do it. There are two somewhat decent > > alternatives: > > > > HMAC the password with the secret prior to passing it to > > password_hash()/crypt(). HMAC is secure and is designed for this > > exact purpose. > > > > Not so great: > password_hash_rfc( hash_hmac('md5', 'password', '1024-bytes secret') ) // > hmac is short (~ 160bits) > In that case, the HMAC would produce exactly 128 bits of output. Why would you use MD5 for that? Use SHA512. That gives you (in your case) a 128 character password (or 64 if you pass true to the third parameter, which you should). Also, be aware that BCrypt only uses the first 72 characters of the password field. So if you use a hex encoded sha512 output, a good deal of entropy would be lost (almost half of it)... > I guess you mean: > > hash_hmac('md5', password_hash_rfc('password'), '1024-bytes secret') > > But then there's no way to know all those crypt() parameters, salt, cost, > etc... > Absolutely not. That would make the hash unverifiable... > Maybe a new api? > password_hash_hmac($password, $secret, $options = array()); Again, implementing something in the core that's not verified and can't be implemented well by the vast majority of developers out there. So a big -1 from me... > > > > Encrypt the resulting hash with a secure encryption function > > (RIJNDAEL_128 + CBC) prior to inserting it in the database. That way, > > each component uses standard algorithms as they were designed to be used. > > > > That's fine, I feel this should be somewhat easier in php core (without the > need for openssl & al.) > > It also comes with a cost of decrypting the hashes / not so great > Huh? How is that not great? The encryption is actually quite fast... And you actually want to slow down password hashing (to make it more difficult to brute force), so I fail to see how this is an issue... > > But I want to stress something else. Properly managing secrets is VERY > > difficult. It's not even really possible in PHP, due to the way > > copy-on-write works, and how variables are removed. To implement this > > sort of a system correctly is not something even highly competent > > developers can typically do. It really is that difficult to get right. > > > > Sure managing keys properly can be hard, simple cases: > $secret = MY_KEY; > $secret = file_get_contents('/security/key.pem'); > Actually, that's not properly managing the key. It requires the web server user to be able to read the key. That allows anyone who gains permissions as the web server (even on a different vhost) to be able to get your key. Properly managing it would require either a dedicated cryptography server to handle it for you, or a dedicated piece of hardware to manage the key. Anything less is just security through obscurity... > Again I'm making the assumption that the attacking *does not* have access > to > the file system. Actually, you need to make the reverse assumption. You want to make the data secure *even if* the attacker gets access to the filesystem. Now obviously if they inject code into the stack they'll be able to view the raw password from the user. But that requires long term access (and write access). But the data stored should be protected even if the filesystem is compromised... --00248c768f92421c5404c62292bf--