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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | not_fully_protected.png | 12.13 KB | rfmarcelino |
Issue fork drupal-3010106
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
Comment #2
akalata commentedI'm in the same boat, I usually ignore these messages, but it's a bit weird to be unable to remove this status error.
Comment #3
rfmarcelino commentedComment #4
cilefen commentedComment #5
cilefen commentedComment #6
valthebaldTagging. Also - what's the right link?
Comment #7
louisnagtegaal commentedI'm working on it on DrupalCon Amsterdam2019
Comment #8
iliendo commentedI'm working on it on DrupalCon Amsterdam2019 with @louisnagtegaal
Comment #9
pandaski commentedThe origin issue is here https://www.drupal.org/project/drupal/issues/2140433
Comment #10
louisnagtegaal commentedNeeds to be fixed in 8.9.x first
Comment #11
louisnagtegaal commentedThe 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.
Comment #12
gal magrisso commentedUpdate - 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)Comment #13
cilefen commented@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?
Comment #14
edorsini@mit.edu commentedThanks @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_003I had another value instead:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006Comment #16
Rkumar commentedAs an opinion, we can update the URL to https://www.drupal.org/docs/8/core/modules/file/overview wrt to D8 and D9
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.
Comment #17
Rkumar commentedMoving it to `Needs review` for more suggestions/thoughts
Comment #19
nsnoblin commentedThanks, @edorsini, that worked for me too.
Comment #20
mradcliffeI 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.
Comment #21
mpotter commentedI 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_006in 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
htaccessPreventExecutionin 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?Comment #23
nishat ahmad commentedI Resovle these issue to add the following line into .htaccess file in path (\sites\default\files)
Comment #25
ridefree commented#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?
Comment #26
delacosta456 commentedhi
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)
Comment #27
anacolautti commentedThank you @delacosta456
Your solution worked for me too.
Comment #30
EliaMelfior commentedThe issue was solved through the proposed solutions
Comment #31
btown commentedThank you! This solution worked for me too. I'm using Drupal 9.4.5
Comment #34
quietone commentedComment #36
quietone commentedI 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.