Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B45D9545 for ; Tue, 24 Apr 2012 17:58:35 +0000 (UTC) Received: (qmail 25283 invoked by uid 500); 24 Apr 2012 17:58:30 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 25241 invoked by uid 500); 24 Apr 2012 17:58:30 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 25209 invoked by uid 99); 24 Apr 2012 17:58:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 17:58:29 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kbenson@corp.sonic.net designates 64.142.16.245 as permitted sender) Received: from [64.142.16.245] (HELO a.mail.sonic.net) (64.142.16.245) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Apr 2012 17:58:22 +0000 Received: from brinstar.noc.sonic.net (brinstar.noc.sonic.net [64.142.18.33]) (authenticated bits=0) by a.mail.sonic.net (8.13.8.Beta0-Sonic/8.13.7) with ESMTP id q3OHw1G4030820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 24 Apr 2012 10:58:01 -0700 Message-ID: <4F96E9A9.409@corp.sonic.net> Date: Tue, 24 Apr 2012 10:58:01 -0700 From: Kevan Benson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: users@httpd.apache.org X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Subject: [users@httpd] Community best practices WRT PHP processing I'm looking for some input on what the community best practices are with regard to specifying which files to apply PHP processing to. Historically, many distributions have used AddHandler to accomplish this, but depending on the environment where PHP is being used, this can lead to other unintended consequences, such as processing files as PHP source when they should not be (due to Apache's multiple file extension handling)[1]. PHP's solution to this seems to be to use a FilesMatch directive with SetHandler to ensure only files ending in ".php" are processed, and processed only as PHP files. Should this be considered the correct way to define files to process as PHP to work around this problem[2]? What are the performance implications of doing a FilesMatch for every request? Are there any other consequences of adopting this[3]? [1] A simple illustration of this is that file.php.txt or file.php.1 will be processed as PHP, not shown or offered for download. When combined with any sort of software that allows uploading to a web location (which may blacklist based on extension), if file.php.txt or file.php.pdf is uploaded, we may have an exploitable situation where arbitrary code can be executed on the server. [2] While the best solutionis probably a white list (at the server configuration level and/or at the web application level for uploads), the truth is that relying on others to do the right thing for your security is a failed model from the beginning. Additionally, this issue is clouded by the fact there may be two sets of best practices; what to do if you have full control over the web server configuration for your small set of applications it services, and what to do when running a hosting platform where what is served by Apache is constantly changing and can't be reasonably vetted by security conscious personnel. [3] One that comes to mind is how to handle the numerous locations where people have made naive backups of PHP files by adding extensions such .bak, .save, .old, etc to existing PHP files. Often these are configuration files, and exposing them to the public may constitute its own security implications. A second FilesMatch for \.php\. could be used to prevent these from display at all, possibly with a custom error message. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org