Wrong/insecure configuration of PHP module

Bug #358703 reported by imagine
4
Affects Status Importance Assigned to Milestone
php5 (Debian)
Fix Released
Unknown
php5 (Ubuntu)
Fix Released
Wishlist
Unassigned

Bug Description

Binary package hint: libapache2-mod-php5

The Apache directives inside /etc/apache2/mods-available/php5.conf are both wrong and insecure. The relevant lines are:
---
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
---

1. 'AddType' is an Apache directive to configure the mime-type of files for the CLIENT side. However PHP is executed at the SERVER side, hence 'AddHandler' or 'SetHandler' must be used instead.

2. In my experience users running Apache with mod_php expect that only files ending with .php, .phtml or .php3 will be processed by the PHP interpreter. However the 'AddType' directives above will enable PHP for all files CONTAINING .php, .phtml or .php3. For example also 'file.php.something' will be executed on the server as long as it contains PHP code [1].

Upstream has updated its documentation [2] some months ago to correct those problems and now states:
---
Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse .php files as PHP. Instead of only using the Apache AddType directive, we want to avoid potentially dangerous uploads and created files such as exploit.php.jpg from being executed as PHP. Using this example, you could have any extension(s) parse as PHP by simply adding them. We'll add .phtml to demonstrate.
<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>
[...]
---

Please change /etc/apache2/mods-available/php5.conf accordingly. As far as I know this bug exists in all versions of libapache2-mod-php5 and is therefore true for all Ubuntu versions.

[1] http://httpd.apache.org/docs/2.2/en/mod/mod_mime.html#multipleext
[2] http://www.php.net/manual/en/install.unix.apache2.php

Revision history for this message
Chuck Short (zulcss) wrote :

Thanks for the bug report.

Regards
chuck

Changed in php5 (Ubuntu):
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
imagine (imagine-de) wrote :

Im not using Lucid yet, but as far as I see this bug was fixed in Debian (bug #491928 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491928) for version 5.2.11.dfsg.1-2, which is now also in Lucid. So I guess this bug report may be closed.

Revision history for this message
Andreas Olsson (andol) wrote :

Yes, this is fixed in Lucid as of (at least) 5.2.11.dfsg.1-2ubuntu2

Changed in php5 (Ubuntu):
status: Triaged → Fix Released
Changed in php5 (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.