Problem/Motivation

When checking if the files and temporary files directory are fully protected against arbitrary code execution it is only considered whether or not the string "Drupal_Security_Do_Not_Remove_See_SA_2013_003" is included in an .htaccess file, this is not actually checking that arbitrary code execution is prevented.

For example I have the following in my Nginx config that achieves the same goal:

# Prevent PHP execution in files directory
location ~ ^/sites/.*/files/.*\.(php|php5)$ {
  deny all;
}

But this is not recognised by system.install, so I still get error messages appearing on my status report.

Steps to reproduce

  • Install Drupal on nginx
  • Remove .htaccess file with rm -f sites/default/files/.htaccess
  • Remove write access to files dir with chmod -w sites/default/files
  • Visit status report

Proposed resolution

Suggested resolution is to actually attempt to execute some code rather than simply rely on a string in a file.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

mustanggb’s picture

Issue summary: View changes
Andrew Udvare’s picture

Confirming here. nginx typical install, security measures like the one mentioned are in place (in my install, only very specific pages ending in .php get to execute).

We should not have to put what is a useless file for us (or files) in our sites just to make this warning go away.

mustanggb’s picture

Version: 7.24 » 7.x-dev
seanr’s picture

Version: 7.x-dev » 9.1.x-dev

This is still an issue seven years later. It's readily visible on sites hosted on Pantheon, and while functionally meaningless, it is annoying and invites potential questions from clients requiring difficult technical explanations. Can we not simply check to make sure we're on an Apache server before running this check?

chris matthews’s picture

I posed this question myself to Pantheon support today and received the below response:

Regarding the Public files directory Not fully protected, it is not actually an issue with Pantheon but just a notice in Drupal.

Drupal checks for arbitrary code execution prevention by looking for a specific string in the .htaccess file. Since Pantheon uses NGINX and ignores .htaccess files, this message can be safely ignored. Read more at https://pantheon.io/docs/platform-considerations#drupal-false-positive

But as a workaround to remove the notice, please add the following code in your .htaccess in /files via SFTP in all environments (Dev, Test and Live)
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mstrelan’s picture

Issue summary: View changes

Updated the issue summary with the template and steps to reproduce. Note this issue is about updating the status report to detect the protection, rather than having Drupal provide protection for other servers.

mstrelan’s picture

I'm not sure about the proposed resolution. It could work for public files directory but since private and temp are usually outside of the web root I don't think we can't really test them.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.