Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79855 invoked from network); 30 Apr 2015 04:30:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2015 04:30:05 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:35044] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 19/31-05379-ACFA1455 for ; Thu, 30 Apr 2015 00:30:03 -0400 Received: by widdi4 with SMTP id di4so4036140wid.0 for ; Wed, 29 Apr 2015 21:29:59 -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=S9r671TC6F96IxGTkUjZjmAqoH28QYEu/CzzJSa46Pc=; b=Y59ahQEgKWdg+jubFNBdw/gw8v0c06FemyBwn3J0h8CqzrcCXh0DASuYeonLgGI1GS 8j3qXmEHsB8tRqw4VKUpUA1NmB7q58WaMgrH4JccQ5JONDHg4dXPmgY9LecvUB/PVWSP Sb9eq5AswmCTpv01U/kBXA/28lN1aPWI8gpqWlFra9PxcQejECbWc+ILwd7I6+7kDJ7A NFMqcSl/CoIN1HonsEXlsOrm62fwIOD4TSnZNLTySD41vrZ48hDtlF74D+Lb5ZdKibUj z+xqPLxH/oHs124brdVU/gMsbt8pAKC1oSmTAnMDlfmOs5Eh1HHilbY/8w65cxJ5M1ax tRUA== MIME-Version: 1.0 X-Received: by 10.180.230.226 with SMTP id tb2mr1710907wic.64.1430368199356; Wed, 29 Apr 2015 21:29:59 -0700 (PDT) Received: by 10.28.7.196 with HTTP; Wed, 29 Apr 2015 21:29:59 -0700 (PDT) In-Reply-To: References: <55401F31.9030703@gmail.com> <55416849.9010808@gmail.com> <554176D6.2030007@gmx.de> <55418CBE.6050609@gmail.com> Date: Wed, 29 Apr 2015 22:29:59 -0600 Message-ID: To: Yasuo Ohgaki Cc: Rowan Collins , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113612bc6bb7220514e98c19 Subject: Re: [PHP-DEV] Adding "numeric" type hint From: derokorian@gmail.com (Ryan Pallas) --001a113612bc6bb7220514e98c19 Content-Type: text/plain; charset=UTF-8 On Wed, Apr 29, 2015 at 8:37 PM, Yasuo Ohgaki wrote: > Hi Rowan, > > On Thu, Apr 30, 2015 at 11:17 AM, Yasuo Ohgaki wrote: > > > > >> A fatal error wouldn't constitute a DoS vulnerability, would it? > >>>> > >>>> Attacker may inject huge ID value and/or they may simply access > >>> web sites to reach 2 billion limit, for example. > >>> > >> > >> That's not a DoS vector unless you've also done something else wrong, > >> it's just an embarassing error like many others. A lot of the time, the > DB > >> will overflow first anyway, because an SQL "int" is signed 32-bit. Hell, > >> YouTube had a 32-bit int for number of views until Gangnam Style > overflowed > >> it! > >> > > > > Not really. Primary key is out of user control almost always. However, > > suppose code allows to specify foreign key and code assumes that non > > existing foreign key results in search query failure. > > > > Current PHP: Search query failure. > > New PHP type hint: Fatal error because foreign key is out of PHP int > range. > How is this different than other languages with type hint? For example, Java or C# - if you type hint int you are limited to 32bit. These languages have long and bigint respectively to support 64bit, but type hinting int means you cannot have arbitrarily large numbers. To me it sounds like you're trying to solve an application problem but suggesting a change to the language. > > > If user are using type hints everywhere, it may be limited to attackers > > seeing fatal errors. If not, attacker can succeed system wide DoS attack > by > > simple operation. > > > > I should have mentioned that I'm supposing DBMS like SQLite here. > As we know, SQLite column accepts any value including value beyond 64 bit > int. > https://www.sqlite.org/datatype3.html > (Those who don't now "Type Affinity", please read the section) > > From your link " The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value." And take a look at http://jakegoulding.com/blog/2011/02/06/sqlite-64-bit-integers/ where numbers larger than the max are converted to real on storage sometimes, depending on the affinity of the storage type chosen but not on math. SQLite is the most used RDBMS in the world. > I would love to see some empirical data that supports this claim. > MySQL supports unsigned 64 bit integer also, BTW. > > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > --001a113612bc6bb7220514e98c19--