Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14484 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54803 invoked by uid 1010); 1 Feb 2005 23:21:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54788 invoked from network); 1 Feb 2005 23:21:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2005 23:21:22 -0000 X-Host-Fingerprint: 66.198.51.121 lerdorf.com Linux 2.4/2.6 Received: from ([66.198.51.121:59661] helo=colo.lerdorf.com) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id 19/A6-00705-1FE00024 for ; Tue, 01 Feb 2005 18:21:21 -0500 Received: from [207.126.233.18] (rasmus2.corp.yahoo.com [207.126.233.18]) (authenticated bits=0) by colo.lerdorf.com (8.13.3/8.13.3/Debian-4) with ESMTP id j11NLD7M002302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 1 Feb 2005 15:21:13 -0800 Message-ID: <42000EE8.2000104@lerdorf.com> Date: Tue, 01 Feb 2005 15:21:12 -0800 User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christian Schneider CC: internals@lists.php.net References: <5.1.0.14.2.20050201111730.0299da70@localhost> <5.1.0.14.2.20050201111730.0299da70@localhost> <5.1.0.14.2.20050201142816.026d21c0@localhost> <420005A3.8050605@lerdorf.com> <42000CA3.5020705@cschneid.com> In-Reply-To: <42000CA3.5020705@cschneid.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 5.1 From: rasmus@lerdorf.com (Rasmus Lerdorf) Christian Schneider wrote: > Rasmus Lerdorf wrote: > >> But the general idea is to provide an optional filter that people can >> enable in their ini file. This will strip out any XSS, quotes, braces, > > > I assume this will include PHP functions to do the filtering as well? > (Forgive me if we already have this now, I haven't looked at 5.0 enough > yet :-)) Right,a function to filter user data through any of the filters will be provided as well. >> $age = pfilter(POST, 'age', FILTER_DIGITS); >> $addr = pfilter(POST, 'addr', FILTER_ALNUM); >> $body = pfilter(REQUEST, 'body', FILTER_TAGS); >> $raw = pfilter(COOKIE,'cook', FILTER_RAW); > > > Sounds like a good idea (even though the name pfilter reminds me too > much of packet filter :-)). A catch-all could be handy too, e.g. > pfilter(REQUEST, DEFAULT, FILTER_TAGS); I just made up the pfilter name. I really don't care what it is called. Figured filter() was a bit too generic and likely to step on existing user-space functions out there. > which filters anything not handled before. Surely you can come up with a > better interface but I hope you get the idea. Being able to define a > default filter but still override it for certain variables is what I > mean. (Also important would be that FILTER_TAGS is more robust than > strip_tags which has some loopholes IIRC) strip_tags only has loopholes if you allow some tags through. But yes, this would be a very strict get rid of all tags filter and it needs to be charset aware. > A bit off-topic: I'm sure variable tainting has been discussed before, > can some give the final opinion, was it found unsuitable/too much > work/too inefficient or was it just post-poned (maybe indefinitely)? It is really hard to do this correctly. Most user data in a web app is multi-purpose in the sense that it is often both displayed and inserted into a database, for example. The untaint rules are vastly different for these two purposes. Throw in a few more and you have a mess on your hands. Just because you untainted it for one purpose doesn't mean it is safe for another, so I don't really see how a single taint flag can be all that effective. I would rather see context-specific access function that retrieves the data for a specific purpose. In this case implemented by calling pfilter with a given filter. And just to clarify, since I added the hook to do this long ago, there aren't actually any PHP changes needed. It can be completely handled in a pecl extension. It just becomes a matter of whether/when to include it with PHP. -Rasmus