Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83706 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71832 invoked from network); 24 Feb 2015 22:25:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 22:25:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.51 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.51 mail-qa0-f51.google.com Received: from [209.85.216.51] ([209.85.216.51:36332] helo=mail-qa0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/B8-24698-B4AFCE45 for ; Tue, 24 Feb 2015 17:25:15 -0500 Received: by mail-qa0-f51.google.com with SMTP id i13so29426307qae.10 for ; Tue, 24 Feb 2015 14:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=sIZXEDuEiEK96sJZJ9WItRsQIeGQIDDvnb0klMz/2Mk=; b=G5/q8panMWpVmnOmLLQZKhgD1dOHxDAWyhQBuiejlIVUnnEEjLysaZQDDlk4Xo9ju5 d7zFlGrs0yXnxIPvDIDuHL4mFX1SOwrEYGvUozFnodD4RWmb3JehMfZqebRyKs24hC9D z663ZbxKpirTF77FFKuGy/vERQLiWSxc0+O6EUjzbmzsGIxWIxSJ9XEhIT3QCYuRGv88 x2le52uW0QoWJVE1wVyDFxv6eTk7woJ++C63X4MPOJkYFqxtDbZsCIG9UuB9AQ8LXTmJ a3HaO01XAv4zgyD4y3ky+fzIV4Q3gq480ImtRvWFxh3EVWUFIOIm3WiXTAAUsboi6kON tqwg== X-Received: by 10.140.102.19 with SMTP id v19mr462575qge.32.1424816712351; Tue, 24 Feb 2015 14:25:12 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.198.8 with HTTP; Tue, 24 Feb 2015 14:24:31 -0800 (PST) In-Reply-To: <54ECF605.7030506@gmail.com> References: <54ECD4E3.9040705@gmail.com> <54ECF605.7030506@gmail.com> Date: Wed, 25 Feb 2015 07:24:31 +0900 X-Google-Sender-Auth: cUd0LZOVC67c7D_mo6KTWoZfJaM Message-ID: To: Stanislav Malyshev Cc: =?UTF-8?Q?P=C3=A1draic_Brady?= , Dmitry Stogov , "internals@lists.php.net" , Nikita Popov Content-Type: multipart/alternative; boundary=001a11c1640002861d050fdcfece Subject: Re: [PHP-DEV] [RFC] Script only include/require From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c1640002861d050fdcfece Content-Type: text/plain; charset=UTF-8 Hi Stas, On Wed, Feb 25, 2015 at 7:07 AM, Stanislav Malyshev wrote: > > They'd need to upload with a matching file type. Instead of any file > > Not sure what you mean by that. phar can read tars, etc. AFAIK, can't > it? Also, phar archive has no requirement of being named something.phar, > afaik can be also named cuteponies.gif. E.g., I just did this: > > 1. Created file chump.php: > > > include $argv[1]; > > This is an idealized vulnerable script. > > 2. Created file pwnd.php > > echo "pwnd!"; > > This is an idealized exploit. > > 3. Put it into an archive: > tar cvzf cuteponies.gif pwnd.php > > 4. Run this: > > php -dallow_url_include=0 chump.php phar://cuteponies.gif/pwnd.php > > The output is: > > pwnd! > > I'm not sure how this measure would protect from such scenario. Am I > missing something here? I think he means matching file "extension". File extension should represent file type, though. The new RFC check filename extensions. It allows only ".php", ".phar" as PHP script and move_uploaded_file() restricts moving PHP scripts by default. (Old idea was to detect PHP script by contents. New RFC is to restrict PHP script file extension.) Since "pwnd.php" has ".php" extension, move_uploaded_file() refuses to move it to upload dir by default. As long as user uses default and move_uploaded_file(), they are free from script upload attacks including embedded script. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c1640002861d050fdcfece--