Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16621 invoked from network); 11 Aug 2015 23:28:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Aug 2015 23:28:00 -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.160.180 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.180 mail-yk0-f180.google.com Received: from [209.85.160.180] ([209.85.160.180:35068] helo=mail-yk0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/60-12494-FF48AC55 for ; Tue, 11 Aug 2015 19:27:59 -0400 Received: by ykdz80 with SMTP id z80so632409ykd.2 for ; Tue, 11 Aug 2015 16:27:57 -0700 (PDT) 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=rybimh9gyxdzwM9sF8mkhCRjXarv71uW8JbiXnz2kjg=; b=hrRFLCsMxAcz+JieWcAQyFoiBuDKfhUb4CJ0aLYGfPgjPGS8CnuFX+9Ij6LIgJpc98 TzOYKnZ9F5Tz3tDfoTmEOAKseQVeGSlXvTw90rpMGE79fTsga+Q96Muw6m1kViwfsdsd Yt6kVzbayUo1G48qPcujPiodWOcO6SxDeVyWU1CVpoMkegsqyWL4rQvCTgH1WtgK5OfB VU2KhSUdlG3Q8s4dvO4XR66dWEJL3nZ/o6kVV4aG/Y9HjdjjzafO4soAIavrEZZF3Sqw dKeEB2hnT7+M6oJwBmBSQHoSXCrlM59qmbTUxe+aZDXk2pBP4oJSafYKyhaPCZaSfaie 2tJQ== X-Received: by 10.13.225.66 with SMTP id k63mr12466720ywe.148.1439335677189; Tue, 11 Aug 2015 16:27:57 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.129.81.87 with HTTP; Tue, 11 Aug 2015 16:27:17 -0700 (PDT) In-Reply-To: <882D42B0-3554-4CAC-9EB9-09A0F00A35E8@craigfrancis.co.uk> References: <882D42B0-3554-4CAC-9EB9-09A0F00A35E8@craigfrancis.co.uk> Date: Wed, 12 Aug 2015 08:27:17 +0900 X-Google-Sender-Auth: f2fRKf6BqAQfsf-J5ZTLSDko1ks Message-ID: To: Craig Francis Cc: Anthony Ferrara , Julien Pauli , Matt Tait , PHP Internals Content-Type: multipart/alternative; boundary=94eb2c076e8ec07fd6051d11736d Subject: Re: [PHP-DEV] [RFC] Block requests to builtin SQL functions where PHP can prove the call is vulnerable to a potential SQL-injection attack From: yohgaki@ohgaki.net (Yasuo Ohgaki) --94eb2c076e8ec07fd6051d11736d Content-Type: text/plain; charset=UTF-8 Hi all, On Mon, Aug 10, 2015 at 6:57 PM, Craig Francis wrote: > I have been reading your conversation with great interest. > > But I would urge you to see Matts suggestion as a simple addition to the > language (it's simpler than my suggestion), where his RFC seems to have > already addressed your concerns (and he seems to have a working proof of > concept). > > Personally I would like to see any one of these solutions being added to > the core language, as there are far too many PHP programmers making > ridiculous mistakes that the core language can be (and should be) > identifying. That said, I am still biased to my suggestion, which also > tries to consider other problems like XSS. > > But anyway... > > Take the code below, it is obviously wrong, but it executes without any > complaints, and unless someone is checking every line of code that is > written (note: PHP is doing so already), then the developer will just move > on without thinking anything is wrong: > > > http://php.net/manual/en/pdo.exec.php > $dbh->exec("DELETE FROM fruit WHERE colour = '{$_GET['colour']}'"); > This is awful... It seems someone already fixed the doc. > > > Over the years I've heard many people say things like "use static > analysis" or "prepared statements fix everything", but I don't think these > are enough. > I fully agree "prepared statements fix everything" is simply wrong. To be secure truly, secure API must split command and all others completely _and_ command part must be programmer supplied constant/static/validated string. (i.e. Perfectly secure API must prohibit command injections at all) Prepared statement does not satisfy both conditions. Many APIs, that are considered secure API, are not perfectly secure because "command part must be programmer supplied constant/static/validated string" condition is not checked. It's left to developers. e.g. execl/execv splits command and arguments, only single command is allowed, but if "command" is user parameter, it cannot be secure. You only have to skim read things like the second comment (with 27 up > votes) on the PDO prepare page to see that these problems are happening all > the time: > > > http://php.net/manual/en/pdo.prepare.php#111458 > SELECT * FROM users WHERE $search=:email > > > So accept that education alone is not enough, and that the basic building > blocks like prepared statements or ORMs are not enough, and look at these > proposals and see how they will make the language better... because I can > assure you, having a simple tainting system that can be switched on to show > your mistakes, is considerably better than what we have today (i.e. > nothing... or maybe using some half baked / expensive static analysis tool). > > Or are you scared that this will highlight the mistakes you have made in > your own (probably over-complicated) code? as this is why I want this > feature, because I know I have made mistakes, and with OOP, it is very easy > todo so (abstractions like ORMs have a tendency to allow for these mistakes > to creep in extremely easily). > I don't think the proposal is useless nor ineffective. Taint system is nice to have, but the proposal does not seem preferable resolution. Don't get me wrong. I agree with your discussion overall. I tend to dislike all or nothing choice for security related issues especially, nonetheless "nothing" is my choice this time... Regards, P.S. There are many outputs other than SQL. Context aware automatic escaping/use of secure API/validation for various outputs would be nice to have. This would be new API and wouldn't help users shooting their own foot, though. I don't have concrete idea now, but PHP may have features help it. -- Yasuo Ohgaki yohgaki@ohgaki.net --94eb2c076e8ec07fd6051d11736d--