If you are running Drupal version 8.6.2, and Drupal detects something wrong with your .htaccess file in your public files/ directory, it gives this error in Reports > Status Report:

Public files directory
Not fully protected
See https://www.drupal.org/SA-CORE-2013-003 for information about the recommended .htaccess file which should be added to the /.../files directory to help protect against arbitrary code execution.

However, the page linked to, https://www.drupal.org/forum/newsletters/security-advisories-for-drupal-..., lists this security notice as applying to Drupal versions 6.x and 7.x, and contains no information specifically indicated as instructions for version 8.x.

This is ambiguous and confusing.

CommentFileSizeAuthor
#3 not_fully_protected.png12.13 KBrfmarcelino

Issue fork drupal-3010106

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

slefevre@ccad.edu created an issue. See original summary.

akalata’s picture

I'm in the same boat, I usually ignore these messages, but it's a bit weird to be unable to remove this status error.

rfmarcelino’s picture

StatusFileSize
new12.13 KB

Screenshot of the message

cilefen’s picture

Component: other » base system
cilefen’s picture

Issue tags: +Documentation
valthebald’s picture

Tagging. Also - what's the right link?

louisnagtegaal’s picture

I'm working on it on DrupalCon Amsterdam2019

iliendo’s picture

I'm working on it on DrupalCon Amsterdam2019 with @louisnagtegaal

pandaski’s picture

louisnagtegaal’s picture

Version: 8.7.x-dev » 8.9.x-dev

Needs to be fixed in 8.9.x first

louisnagtegaal’s picture

Status: Active » Postponed (maintainer needs more info)

The issue title mentions the 'public'-files directory but the attached screenshot shows a message about the 'private'-files directory

It is unclear if this issue is about the message shown or the documentation on the page the message links to.

In Drupal 8.9.x the message is only shown if the .htaccess in the folder is edited. If the .htaccess is missing it is (re-) created so the documentation the message links to seems to be correct because Drupal 8.x is not affected by the original SA.

So it seems this issue is no longer relevant in Drupal 8.9.x. If the OP thinks it is still a problem the issue could be reopened.

gal magrisso’s picture

Update - non relevant, I checked the wrong link.

I downloaded 8.7 dev version in the file core/modules/system/system.install I see the link leasd to https://www.drupal.org/SA-CORE-2013-00 which doesn't exist (404)

cilefen’s picture

Status: Postponed (maintainer needs more info) » Active

@louisnagtegaal:

HtaccessWriter::defaultProtectedDirs specifies the default directories as public, private and temporary. The issue occurs when a .htaccess file is discovered that does not contain the string "Drupal_Security_Do_Not_Remove_See_SA_2013_003". Drupal 8 was two years away from release at the time the SA was written.

Is there documentation that Drupal 8.x is unaffected by the SA?

edorsini@mit.edu’s picture

Thanks @cilefen.

Adding the following in the .htaccess file of my public directory worked to get rid of the error in the status report page:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003

I had another value instead:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Rkumar’s picture

As an opinion, we can update the URL to https://www.drupal.org/docs/8/core/modules/file/overview wrt to D8 and D9

if (!file_exists($htaccess_file) || !($contents = @file_get_contents($htaccess_file)) || strpos($contents, 'Drupal_Security_Do_Not_Remove_See_SA_2013_003') === FALSE) {
        $url = 'https://www.drupal.org/SA-CORE-2013-003';

With respect to drupal 8 and 9, https://www.drupal.org/docs/8/core/modules/file/overview and https://www.drupal.org/node/244924 give all the related information.

Rkumar’s picture

Status: Active » Needs review

Moving it to `Needs review` for more suggestions/thoughts

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

nsnoblin’s picture

Thanks, @edorsini, that worked for me too.

mradcliffe’s picture

Status: Needs review » Active
Issue tags: +Europe2020

I performed Novice Triage on this issue. I am leaving the Novice tag on this issue because I think that thanks to @Rkumar working on the issue there is some direction for updating the issue summary. We should update the issue summary with the issue summary template adding in the current proposed resolution. Then write and upload a patch.

Additionally, I changed from Needs review to Active because Needs review signifies that there is a patch or code to review.

mpotter’s picture

I also ran into this today and #14 solved my problem. But my question is how this incorrect `.htaccess` file got created in the first place. I don't think this file is created by Drupal scaffold. Since the `sites/default/files` folder isn't committed to a code repo, that folder should get created during Drupal install time, but I don't see any code in Drupal core that would set this to the single line with SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 in it.

I'm not really sure what the root cause of this problem was. This site was originally installed with Drupal 8.8 a while back (now it's on 9.0.10) so maybe something changed in the meantime. Maybe there was a missing update hook to change this?

I see a function htaccessPreventExecution in the FileSecurity.php core code and this matches the `.htaccess` files I have in my config/sync folders. Wonder if this is also the fully correct version of what the `.htaccess` in the Files folder should look like?

AJV009 made their first commit to this issue’s fork.

nishat ahmad’s picture

I Resovle these issue to add the following line into .htaccess file in path (\sites\default\files)

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ridefree’s picture

#14 worked as well but share some concerns with @mpotter.
I'm also wondering about committing this .htaccess file as the files dir is in my .gitignore
Seems harmless here, though maybe not?

delacosta456’s picture

hi
i was also facing this issue and the solution for me was

1- delete the .htaccess file in the public folder
2- at admin/config/media/file-system hit the save configuration button (this will generate a new .htaccess file and status will stop reporting error)

anacolautti’s picture

Thank you @delacosta456
Your solution worked for me too.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now 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.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.

EliaMelfior’s picture

The issue was solved through the proposed solutions

btown’s picture

Thank you! This solution worked for me too. I'm using Drupal 9.4.5

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Component: base system » documentation

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.

quietone’s picture

Status: Active » Closed (duplicate)
Issue tags: -Documentation, -Novice +Bug Smash Initiative

I thought there was more than one issue about this.

This is a duplicate of an older issue #2906490: Link to useful information about .htaccess and directory protection. There is an MR over there as well.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.