Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89510 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28976 invoked from network); 1 Dec 2015 12:08:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2015 12:08:54 -0000 Authentication-Results: pb1.pair.com header.from=t.carnage@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=t.carnage@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: t.carnage@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:34544] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/C6-13465-5DD8D565 for ; Tue, 01 Dec 2015 07:08:53 -0500 Received: by wmvv187 with SMTP id v187so203328790wmv.1 for ; Tue, 01 Dec 2015 04:08:50 -0800 (PST) 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=dejMW7ddEPRR2lk+Enhf5Akq8aLed8MrR9E5T5CvW5c=; b=Wt2iCql1/juVwAl+kzRaHCHFHG1/CdDvQJebq3NBEh6lvwdaXlTjo2st4X9QEMXrQc qejUo5SXZH6zuvMsTvFkIC0vzqFIcRmczED+DaWJfoabrVHQhiOSQEGVRwJx2TzAkqud MqcwjfpE6U9+x0QjsoEESJNKuU+dltdJCqI3dzahxYZkBJzwDZHmToxyWsJL6NeuXGSG WLyAjsneumT7sFwURccSB0bftM0eWNZyCKvJ8BXgz+K//DTtuUD51Y8yBrFFOGFGLMSJ yr15KPg2mja9e+g7AwXUIH9Kj01Qn4c0kkQZVIe0Ut7fCr0INp6uZDzsmqeAFv6c24b1 sAJg== MIME-Version: 1.0 X-Received: by 10.194.201.134 with SMTP id ka6mr14188017wjc.116.1448971730653; Tue, 01 Dec 2015 04:08:50 -0800 (PST) Received: by 10.194.115.67 with HTTP; Tue, 1 Dec 2015 04:08:50 -0800 (PST) In-Reply-To: References: Date: Tue, 1 Dec 2015 12:08:50 +0000 Message-ID: To: Dmitry Stogov Cc: Nikita Popov , PHP internals , Anatol Belski , Remi Collet Content-Type: multipart/alternative; boundary=047d7ba97e644ba1a30525d50522 Subject: Re: [PHP-DEV] HashDos protection From: t.carnage@gmail.com (Chris Riley) --047d7ba97e644ba1a30525d50522 Content-Type: text/plain; charset=UTF-8 On 1 December 2015 at 09:50, Dmitry Stogov wrote: > Hi Nikita, > > few notes: > > It looks like the patch messes the attempt of catching the problem (few > lines related to zend_hash_find_bucket changes) with optimization to > compensate collision check overhead (everything else). I think it's better > to separate these parts. > > Introduction of zend_hash_add_or_return() in 7.0.1 is going to make forward > incompatibility with 7.0.0. However, we may reserve it for internal usage > removing ZEND_API. > > I don't think PHP should prevent user from construction of arrays he likes, > because of internal problems (like in your example). > > > $s = 1 << 16; $a = []; > > for ($i = 0; count($a) < $s; $i += $s) { $a[$i] = 0; } > > It makes performance problem, but it doesn't mean we should kill it. > We have "max_execution_time" to catch them all. > > I think only big arrays coming from external sources should be checked. > > Your solution is incomplete, anyway, because of crafting a single list with > 10000 collisions, attacker will able to use N lists with 1000 collisions. > > Thanks. Dmitry. This is a good point but bear in mind to get the same effect as for 10000 collisions, you'd need 100 lists not 10 --047d7ba97e644ba1a30525d50522--