Mimetypes coming from package mime-support cannot be removed

Bug #225105 reported by magkes
256
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Hi!

Explanation from httpd.apache.org (http://httpd.apache.org/docs/2.2/mod/mod_mime.html#multipleext):
Files can have more than one extension, and the order of the extensions is normally irrelevant. For example, if the file welcome.html.fr maps onto content type text/html and language French then the file welcome.fr.html will map onto exactly the same information. If more than one extension is given that maps onto the same type of meta-information, then the one to the right will be used, except for languages and content encodings. For example, if .gif maps to the MIME-type image/gif and .html maps to the MIME-type text/html, then the file welcome.gif.html will be associated with the MIME-type text/html.

On several PHP-based web-applications file(-upload) filtering is based on the last file-extension. If you want to prevent php processing for malicious files one could use a pattern like
\.php[45]?$

But as Apache supports "Multiple Extensions", also files like index.php.abc will be handed over to PHP preprocessor. If you would prefer only the last dot-separated part of the filename to be mapped to a particular piece of meta-data, apache suggests to use "SetHandler". A PHP solution would be
<FilesMatch \.php[45]?$>
                SetHandler application/x-httpd-php
</FilesMatch>

As apache2.2-common depends on mime-support it is already aware of php mime-types. Btw. this makes it totally useless to register these mime-types with file php5.conf in package libapache2-mod-php5 again.

Because of the already registered mime types in /etc/mime.types you have to unregister these to only map files based on the last dot-separated part of the filename. To get rid of them you should be able to place
 RemoveHandler .php .php4 .php5 .phps .pht .phtml
 RemoveType .php .php4 .php5 .phps .pht .phtml
somewhere in apache2.conf or php5.conf. Unfortunately this does not work!! Apache then still knows what do do with index.php.anydamnextension!

I'm unsure what package to blame; "mime-support" for listing php mime types or "apache2.2-common" for not being able to unregister them.

magkes (marcus-krause)
description: updated
Kees Cook (kees)
Changed in apache2:
status: New → Confirmed
Changed in apache2 (Ubuntu):
importance: Undecided → Low
Revision history for this message
Seth (bugs-sehe) wrote :

is there a workaround? I'm really stuck with my mirrored website and I don't want to hand-edit all pages to rename the dang file...

Revision history for this message
Stefan Fritsch (sf-sfritsch) wrote :

Since 2.2.14-2, RemoveType also works for types coming from /etc/mime.types

Changed in apache2 (Ubuntu):
status: Confirmed → Fix Committed
Chuck Short (zulcss)
Changed in apache2 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

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