Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75055 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17464 invoked from network); 24 Jun 2014 08:07:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jun 2014 08:07:47 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.53 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.53 mail-qa0-f53.google.com Received: from [209.85.216.53] ([209.85.216.53:44077] helo=mail-qa0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/82-34096-0D139A35 for ; Tue, 24 Jun 2014 04:07:44 -0400 Received: by mail-qa0-f53.google.com with SMTP id j15so6718319qaq.12 for ; Tue, 24 Jun 2014 01:07:41 -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=RwPhEW59Ode1C76UTClivF5/sLGJlJ5p4sjQn0smy2E=; b=MKXgsujWf/9SahB/DDeiibuSJdclfTH57ACsRTSGrYKMqtNjR1wNv0s1TGEM1eLLhR GZOKNe4OAwf225g6Cy1/xDicAGDSvBeb6c/+Pwr2WjWrYcNx9B1xdDJzNxVS+55HuhfW CPCroqheocff+vosf83BWQVoOwdNbsuDK1WPGTT4YIcyWwHqfZejupnBbRQFj3/lxAcN 5Qm0nkjV0JvW5K8o7HPZsFYAeHuthkKf7cWPhyoVs/fu9kuatJ1hWSZXVlmiZA0XXZjD lMigmPbhn7PFm+0DWWqw1TYbU51H7iZ421qXR6gN1YTQ87Yd8oldtaKs0/HtZxCVDdHk Yh8w== MIME-Version: 1.0 X-Received: by 10.224.163.11 with SMTP id y11mr40968427qax.43.1403597261386; Tue, 24 Jun 2014 01:07:41 -0700 (PDT) Received: by 10.140.17.77 with HTTP; Tue, 24 Jun 2014 01:07:41 -0700 (PDT) In-Reply-To: <53A92B24.40706@fedoraproject.org> References: <53A1C722.9060501@fedoraproject.org> <53A21137.6010705@sugarcrm.com> <53A2A9BD.1070603@sugarcrm.com> <53A3874E.20704@sugarcrm.com> <53A65578.6000701@sugarcrm.com> <53A8626B.701@fedoraproject.org> <53A866B6.4060501@sugarcrm.com> <53A92B24.40706@fedoraproject.org> Date: Tue, 24 Jun 2014 10:07:41 +0200 Message-ID: To: Remi Collet Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e01538d502c3d1a04fc9074c0 Subject: Re: [PHP-DEV] Re: Bug 67072 resolution for 5.4/5.5 From: tyra3l@gmail.com (Ferenc Kovacs) --089e01538d502c3d1a04fc9074c0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Jun 24, 2014 at 9:39 AM, Remi Collet wrote= : > Le 23/06/2014 19:41, Stas Malyshev a =C3=A9crit : > > Hi! > > > >> Minimal reproducer: > >> > >> >> class FooFile extends SplFileInfo { > >> } > >> $str =3D 'O:7:"FooFile":0:{}'; > >> var_dump(unserialize($str)); > >> ?> > > > > I'm afraid here we can't do much - SplFileInfo is one of the classes > > that it is unsafe to instantiate this way. It's what original 67072 was > > about and I don't think it's safe to leave it this way, since at best i= t > > can crash any code that uses unserialize() on external data, at worst > > you got RCE. > > I think the segfault have to be fixed in spl. > We should fix those issues, sure, but if we consider unserialize($arbitraryUserInput) a relatively common thing, then continuing to allow the Serializable Internal classes to be unserialized with the O format will allow remote DOS or worse until we "fixed" all of those classes to support instanitation without a constructor call. I don't think we can wait for that with the 5.4/5.5 releases (and there are already other sec related fixes waiting to be released). > > And if we plan to allow newInstanceArgWithoutConstructor() for internal > classes this is mandatory. > I'm not so sure about that it is mandatory, as I mentioned the problem also exists with MyClass extends SomeInternalClass {public function __construct(){}} but what makes the difference between newInstanceArgWithoutConstructor/extending the class is that it requires deliberate action, explicitly written code, vs the arbitrary unserialize call. > > See attached patch (quickly written, just for test) > > So we can allow "O:.." (perhaps only for empty data used in the > phpunit/doctrine hack, =3D> strlen(*p)<=3D1) > > > Running: > echo > > unserialize('O:13:"SplFileObject":1:{s:9:"*filename";s:15:"/home/flag/fla= g";}'); > echo unserialize('O:13:"SplFileObject":0:{}'); > > > Warning: Erroneous data format for unserializing 'SplFileObject' ... > Fatal error: SplFileObject::__toString(): Object not initialized ... > > Would be nice if others could also comment, because I think we are starting to argue in circles. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --089e01538d502c3d1a04fc9074c0--