Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96020 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96208 invoked from network); 16 Sep 2016 13:30:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2016 13:30:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=scott@paragonie.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=scott@paragonie.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain paragonie.com designates 209.85.218.53 as permitted sender) X-PHP-List-Original-Sender: scott@paragonie.com X-Host-Fingerprint: 209.85.218.53 mail-oi0-f53.google.com Received: from [209.85.218.53] ([209.85.218.53:34068] helo=mail-oi0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A9/7C-09226-0E3FBD75 for ; Fri, 16 Sep 2016 09:30:10 -0400 Received: by mail-oi0-f53.google.com with SMTP id m11so111596917oif.1 for ; Fri, 16 Sep 2016 06:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragonie-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QVFIpwhzVymYT5WdYZG1+eAr4jPot78xCSDoNfcTlws=; b=dwEe7uCn8FPtSF08EM08cR0XetsjMT9o2LHbSpiS8FjrwNByPoTlc8nS5DuNrfxqE9 uf9vcfnJ3MrW5/7SZGx7M0BdeEmBZfK7Hy+haBjvtFCMBBnH+lXjdc5UBsS6ixoihNNg B1acRDrWuyWaNDeWexWv2RBuHwqcf1ZThP80IaNY2vU/gpDzS65qBrLADnzqEZ+mNKNg ZRBGBuBL7p9At/Gjo/jVXqDyV+8JBjenwBD/ZolAP+KBxeUaaxupCrS9s6k8Tu46hGXh YuT+OuWFFqYdg+bAJDDKhZzxtynuPEGCAp755CiO9rWKxAgd1dEcyFqBk4MJ/KLCRC/z gsug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QVFIpwhzVymYT5WdYZG1+eAr4jPot78xCSDoNfcTlws=; b=DSfc8KlhwrWHCWnAmH6H7d6nqFVNOsB91dn/FRQDJC6Xqq6CQ2N2NrDsnk9t++BvFT 4sLPpXiOZpUFnLUYVTpN5QoVubfW3X416CwX4iRtP5n+Cb/nnBHernfEorusTGPV3aCE IiVYKwth4U9LcS3tBxBWpNfS88bLfGKZY2mal2W+s/j9QUHjuDh2ripEibibmy+PmKBM /aJzwkdHamV1ONxsPbcKAz4wzH0cVCwjC6K3i2mVhBEl8AGhyvutxet35xrdyMO7bzop PFdea9wL2cwx2YTCt1J4koDqjhdbxwuSca4LG/1aqD8+weLpYnUXybwOMgPkdWpJM8AK qjIw== X-Gm-Message-State: AE9vXwPNVAPmobO1x//86c9Wmb5ztph+x055nHSQ7I0ClTG0vOFzuvBDZlPUmPRtWpRjDzIZZvOzmQ/pd9gWrw== X-Received: by 10.157.46.209 with SMTP id w75mr11366452ota.170.1474032606463; Fri, 16 Sep 2016 06:30:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.25.135 with HTTP; Fri, 16 Sep 2016 06:30:05 -0700 (PDT) In-Reply-To: <7d5727ba-da33-e3c5-1d1f-318c45d81616@cubiclesoft.com> References: <7d5727ba-da33-e3c5-1d1f-318c45d81616@cubiclesoft.com> Date: Fri, 16 Sep 2016 09:30:05 -0400 Message-ID: To: Thomas Hruska Cc: Stanislav Malyshev , PHP Internals Content-Type: multipart/alternative; boundary=001a1142ff74e55e31053c9ff504 Subject: Re: [PHP-DEV] HashDoS From: scott@paragonie.com (Scott Arciszewski) --001a1142ff74e55e31053c9ff504 Content-Type: text/plain; charset=UTF-8 Significant degradation? SipHash 1-3 is almost as fast as HashDoS-vulnerable hash functions: https://github.com/funny-falcon/funny_hash Scott Arciszewski Chief Development Officer Paragon Initiative Enterprises On Fri, Sep 16, 2016 at 1:59 AM, Thomas Hruska wrote: > On 9/15/2016 5:20 PM, Stanislav Malyshev wrote: > >> Hi! >> >> On 9/15/16 11:48 AM, Scott Arciszewski wrote: >> >>> Would the Internals team be open to discussing mitigating HashDoS in a >>> future version of PHP? i.e. everywhere, even for json_decode() and >>> friends, >>> by fixing the problem rather than capping the maximum number of input >>> parameters and hoping it's good enough. >>> >>> I'd propose SipHash (and/or a derivative): >>> https://www.131002.net/siphash/ >>> >> >> I am worries about performance. Base hash structure has to be *very* >> fast. I have doubts that cryptographic function can perform at these >> levels. Did you test what is performance of this function compared to >> existing hash function? >> > > If anyone wants a VERY rough estimate of relative performance degradation > as a result of switching to SipHash, here's a somewhat naive C++ > implementation of a similar data structure to that found in PHP: > > https://github.com/cubiclesoft/cross-platform-cpp > > (See the "Hash performance benchmark" results at the above link.) > > In short, there's a significant degradation just switching from djb2 to > SipHash depending on key type. A similar effect would probably be seen in > PHP. > > Randomizing the starting hash value for djb2 during the core startup > sequence *could* also be effective for mitigating HashDoS. Extensive > testing would have to be done to determine how collision performance plays > out with randomized starting hash values. I can't find any arguments > anywhere against using randomized starting hash values for djb2. Also of > note, the 33 multiplier seems more critical than anything else for mixing > bits together. > > -- > Thomas Hruska > CubicleSoft President > > I've got great, time saving software that you will find useful. > > http://cubiclesoft.com/ > --001a1142ff74e55e31053c9ff504--