By Samat Jain on
From the Drupal 4.6.7/4.7.1 release announcement and security advisory:
Make sure you have a .htaccess in your "files" dir and it contains this line:
SetHandler This_is_a_Drupal_security_line_do_not_remove
Pardon me for not going through the mailing lists, but what is this for and how is this supposed to work?
Comments
I don't use .htaccess files
I don't use .htaccess files .
Do I fix this problem by adding the following in my http.conf inside the:
Is there a way to verify ?
Thanks,
C
Should be fine
That should work fine, and is also how I probably will setup this directive. I like to turn off .htaccess parsing on my Drupal directories.
But my question is, how/why does this work?
__
Personal home page | Rhombic Networks: Drupal-friendly web hosting
How it works
I'm not an Apache guru either, but from the documentation, SetHandler defines how a file is interpreted by the Apache server. By default, files with certain extensions are handled by certain handlers, e.g. a .php file is handled by mod_php, which means it gets executed. Some servers (like my Ubuntu server) apparently also execute .cgi-script files as CGI scripts. The directive SetHandler changes this, and by setting a nonexistant handler you prevent the files from being executed. Anyone requesting that file will simply get the file itself, without any interpretation or execution on the server side. For the files directory, this is exactly what you want.
Note that this only works if the Apache configuration allows overriding the SetHandler directive from .htaccess files. For me, this wasn't the case, meaning that just adding the .htaccess file didn't solve the problem for me. I had to add a /etc/apache2/conf.d/drupal file containing
to make my system secure.
Yes
That's indeed the right thing todo when you can access httpd.conf and do not use .htaccess. Verify by putting a .php file in your files directory, then access the file with a URL.
--
When your problem is solved, please post a follow-up to the thread you started.
symbolic links/virtual hosts
if you are using a multi-site drupal configuration with each site's document root symbolicly linked to your drupal directories, you will need to add the above directory statement to each virtual host definition and specify the path/to/files for each different doc root.
Error 500 if Apache does not allow SetHandler in .htaccess
I had to comment out the SetHandler directive because I got error 500, end in the error log there was:
[Fri Dec 29 10:09:56 2006] [alert] [client 192.168.102.200] ****/htdocs/files/.htaccess: SetHandler not allowed here
Only administrators can upload files in my installation, therefore it shouldn't be a issue.
LDS