Problem/Motivation

The commit from #140 of #1269780: Remove symlinks option from .htaccess made changes to the vendor/.htaccess and auto-generated .htaccess files (such as the one in sites/default/files). Drupal 8.0.0 is now explicitly setting Options -MultiViews in these .htaccess files, which is not allowed in some configurations without "AllowOverride MultiViews" in the VirtualHost. The commonly set "AllowOverride All" does not actually include MultiViews, which can cause further confusion.

Affected Apache configurations will be able to install Drupal but will return 500 Server Errors for any content inside the files directory, which includes CSS aggregation files and theme files such as the site logo.

However the problem is that multiviews is a possible security issue - see https://hackerone.com/reports/25382

Proposed resolution

  • Remove Options -MultiViews from the offending .htaccess files, since neither directory it appears in uses Clean URLs or RewriteRules.
  • Enable Options -MultiViews in the root .htaccess with a large comment about pitfalls
  • Comment on some systems needing to set a Options +FollowSymLinks or Options + SymLinksIfOwnerMatch

Remaining tasks

Confirm rationale in #5
Test patch in #5
Document fix for users who have already installed.

User interface changes

None

API changes

None

Data model changes

None

Original report by @w1nz0r

hi,

i've made a fresh install with php 5.6.13 and after successful installation there is no theme used for any sites. Even setting the seven theme as default or changing back to the bartik theme doesn't work. All i see is a unformatted list of all titles and links on white background.

Any ideas how to fix this?

regards

w1nz0r

Comments

Anonymous’s picture

w1Nz0r created an issue. See original summary.

morenstrat’s picture

Same here on a fresh install. Does not happen with upgraded versions. I have to turn off css aggregation and then bartik and seven look nice.

The requests for the aggregated css files create a 500 Internal Server error:

Apache Error Log:

sites/default/files/.htaccess: Option MultiViews not allowed here

The .htaccess in the public files directory generated by earlier D8 versions was different. It contained

Options None
Options +FollowSymLinks

instead of

Options -Indexes -ExecCGI -Includes -MultiViews

catch’s picture

Title: theme problem » AllowOverride All does not always include MultiViews
Component: theme system » base system
Priority: Normal » Major
Issue tags: +Needs issue summary update

This looks like we ran into it once before:

#919596: -MultiViews in .htaccess requires odd AllowOverride Options=All,MultiViews.

If you're experiencing the error please indicate Apache version/platform,

catch’s picture

Also the issue title indicates the workaround if you're affected, https://mathiasbynens.be/notes/apache-allowoverride-all has more detail too.

damien_vancouver’s picture

Title: AllowOverride All does not always include MultiViews » Disabling -MultiViews in .htaccess can cause 500 errors
Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs issue summary update
Related issues: +#1269780: Remove symlinks option from .htaccess
StatusFileSize
new3.31 KB

I think there's an easy solution here. Can anyone think of a negative implication from NOT defining Options -MultiViews in the files directory?

MultiViews can cause problems with clean URLs (or so says the Clean URL documentation guide), and that is why we avoid them.

But files directory and vendor directory files are never accessed via Clean URLs. They get called with a direct URL, and there are no RewriteRules in the .htaccess files in either of those directories for MultiViews to fight with.

So, since that directive isn't doing anything for us, an easy fix would be to just remove the -MultiViews from the generated .htaccess files and the vendor .htaccess file. Patch attached.

catch’s picture

Took a while but found the php docs for this:
http://httpd.apache.org/docs/current/content-negotiation.html#multiviews

So it's documented that All doesn't cover multiviews.

@Damien_Vancouver what about image derivatives? That needs to be a route with the same path as the files directory.

damien_vancouver’s picture

Hi @catch,

I did some image derivative testing and it doesn't seem that leaving MultiViews enabled causes any serious problems... other than the fact it allows insecure viewing of already existing derivative images via a crafted MultiViews URL.

Here was what I tested:

- applied patch from #5 and did a clean install of latest 8.0.x
- Ensured that Options +MultiViews is set in the VirtualHost and tested it in a test directory to confirm it was working.
- created an article with a large image (image.jpg).
- Accessed the image file directly via the MultiViews Map URL (ie. went directly to its URL path at sites/default/files/2015-11/image, omitting the file extension). Apache shows the image, as is expected to happen with mod_negotiation enabled and Options +MultiViews set.
- Viewed the article in Drupal, which shows a thumbnail of the image using the "medium" style. Clicked to view the article in full mode. Both the "medium" and "large" styles worked as expected.
- Took one of the derivative URLs and removed everything after the file extension (ie. the .jpg?itok=XXXXXXX). The image derivative displayed as one would expect with MultiViews on. (This is a security side effect of MultiViews)
- Deleted the image derivative files from both style directories and verified that they are regenerated and load correctly when going to their direct URLs or refreshing the page in Drupal. (mod_rewrite rules from the top level .htaccess firing for a nonexistant file or directory and running as expected).
- Removed the image derivative files again and tested that the files would not load with the full URL and the token missing (sites/default/files/styles/large/public/2015-11/image.jpg). I received access denied as expected.
- With the derivative file still removed, I tried accessing its filename using a constructed MultiViews URL (the filename with no extension or token). I also received an Access Denied on this request..

These last two tests show that the DoS protection for secure image derivatives is still functioning with MultiViews on. While an anonymous attacker can get around needing a token to view an image derivative file that already exists, (s)he cannot force image derivative generation for arbitrary files, which was the DoS vulnerability that secure image derivatives fixed.

So, as far as I can tell, the only problem with not having Options -MultiViews, is: if someone has MultiViews turned on, then they are effectively allowing an attacker who constructs MultiViews-style URLs to view already-generated image derivatives, despite not having the correct token.

Anonymous’s picture

Because of problems with the contextual module i also had to disable javascript aggregation as you can read here and here.

catch’s picture

@Damien_vancouver I'd expect to be able to view already generated files without the token already, so not sure even that is an issue?

damien_vancouver’s picture

@catch,

I'd expect to be able to view already generated files without the token already, so not sure even that is an issue?

You're right, I must have been trying to load it without the file present when I got the Access Denied. Already existing images are returned without a token.

catch’s picture

Tagging 8.0.1 target, it's not clear how many people are actually affected by this, or whether it's less or more than were affected by the original bug that was fixed, but would be good to get it fixed in the next patch release so we don't need to find out either way.

I think just removing this option is probably OK, my assumption is that the original -MultiViews when added to core was probably a copy/paste rather than in response to a specific vulnerability. However I'll try to find the history of the original issue that added it, and also we should add a note to drupal.org/requirements recommending that it's set in vhosts configuration, as well as a change record update to https://www.drupal.org/node/2608772 saying the same.

catch’s picture

Issue tags: -8.0.0 target +8.0.1 target
damien_vancouver’s picture

Issue summary: View changes
Issue tags: -Needs change record updates

I added mention of setting Options -MultiViews if it's enabled by default to https://www.drupal.org/requirements/webserver , and updated the change record at https://www.drupal.org/node/2608772.

There was a typo in the issue description so I've updated that as well.

desro’s picture

Hello.
I just installed 8.0.1 on my host server and I am having an issue in which css and js files are not loading and I'm getting a error code 500. It affects the toolbar and doesn't load enough css for me to properly access all of the administrative options when I'm logged in as the first user.
I don't have access to the Apache config files, so I was wondering if there was another way to fix the issue than the method prescribed by earlier comments or if a patch was in the works. The host I'm using is running PHP 5.6.16

cilefen’s picture

Version: 8.0.0 » 8.1.x-dev
Issue tags: -8.0.1 target
hswong3i’s picture

Patch update with latest 8.1.x-dev

Status: Needs review » Needs work

The last submitted patch, 17: drupal-do_not_disable_MultiViews_htaccess-2619250-17.patch, failed testing.

mayurjadhav’s picture

Status: Needs work » Needs review
StatusFileSize
new3.32 KB

Patch with latest 8.1.x-dev drupal version.

Status: Needs review » Needs work

The last submitted patch, 19: drupal-do_not_disable_MultiViews_htaccess-2619250-19.patch, failed testing.

mayurjadhav’s picture

Assigned: Unassigned » mayurjadhav
mayurjadhav’s picture

Assigned: mayurjadhav » Unassigned
Status: Needs work » Needs review
StatusFileSize
new2.9 KB

Agreed, why patch failed testing. Uploading patch with excluding vendor directory changes.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

hswong3i’s picture

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

alexpott’s picture

I think this issue needs an expanded scope. The problem we have is that it appears impossible to generate an .htaccess that offers the maximum security for everyone. The change that caused this issue to be created was #1269780: Remove symlinks option from .htaccess which we did because hosters where moving to the more secure module of only allowing symlink to be followed if the owners matched. If the webserver is configured to allow mutliviews we certainly don't want our files directory to behave the way that multiviews works. However it is a totally reasonable webserver configuration to not allow multiviews to be overridden. Also it appears that #1269780: Remove symlinks option from .htaccess broke OpenSuse.

So what's the best way forward? I think:

  • We require AllowOverride All but as pointed out that doesn't include multiviews - so we need to remove this from the auto-generated htaccess files.
  • We should add something to .htaccess that disables multiviews and suggests commenting this out if you webserver doesn't allow this. The advantage of doing this is the site would brake the moment it is running on a server and not fail less obviously later. And no one loses any protection - there are numerous reports on the web about the vulnerabilities from having multiviews enabled... https://hackerone.com/reports/25382 -
    This behaviour can help an attacker to learn more about his target, for example, generate a list of base names, generate a list of interesting extensions, look for backup files and so on.
  • We should add something to .htaccess that documents how to fix the issue caused by the opensuse configuration - this might need to be a followup because https://www.drupal.org/docs/7/system-requirements/web-server is not exactly clear on what to do.

I'm not convinced this is a major because there is a workaround by updating your apache config, we are doing the secure thing for most people, and we haven't had reports of this affecting any major hosters. But that doesn't mean we shouldn't try to make life easier for more custom webserver configurations.

damien_vancouver’s picture

Regarding the OpenSUSE breakage,

@alexpott wrote

We should add something to .htaccess that documents how to fix the issue caused by the opensuse configuration - this might need to be a followup because https://www.drupal.org/docs/7/system-requirements/web-server is not exactly clear on what to do.

As a result of the reports in #1269780: Remove symlinks option from .htaccess , I filed a bug with SuSE explaining the problem with their configuration. The problem is not Drupal specific and can occur with any use of mod_rewrite if one don't explicitly set a Symlink option. https://bugzilla.suse.com/show_bug.cgi?id=955701 and as a result they modified their apache configuration file to have some hints on how to properly enable mod_rewrite: https://build.opensuse.org/request/show/347918 ("apache2-default-server.conf" changes).

That change should now be pushed to anyone running the stable Leap should have it from last November's 42.2 release. However, it's just two lines of text that could easily be overlooked - it has no mention of "Clean URLs":

# NOTE: For directories where RewriteRule is used, FollowSymLinks
# or SymLinksIfOwnerMatch needs to be set in Options directive.

Extra documentation in Drupal's .htaccess will definitely be helpful.

Here is a first draft of something short:

# For OpenSUSE and some other custom Apache configurations, one of
# the following directives must be set to use Clean URLs (mod_rewrite)
# Only enable one of the following two, and only if seeing a Server Error.
# Options +FollowSymLinks
# Options +SymLinksIfOwnerMatch

For the documentation page, Here is a draft of some new text to replace the existing "Symlinks" paragraph at https://www.drupal.org/docs/7/system-requirements/web-server.

SymLinks: Drupal versions prior to 8.0 set "Options +FollowSymLinks" in the .htaccess file. Some shared hosts require a different directive for security reasons: "Options +SymLinksIfOwnerMatch".
If the site shows a Server Error on every page, changing the "FollowSymLinks" to "SymLinksIfOwnerMatch" in .htaccess may fix the problem. In this case there will also be an entry in the Apache error log that says: ".htaccess: Option FollowSymLinks not allowed here"

Drupal 8.0 does not set either Symlink option, leaving the configuration up to the Apache webserver. This avoids the problem described above on shared hosts, but it can cause installation to fail on OpenSUSE distributions and some secured Apache configurations. The default OpenSuse configuration does not come with mod_rewrite enabled, which is required in order to use Clean URLs in Drupal. Due to OpenSUSE's secure default configuration, one of either "Options +FollowSymLinks" or "Options +SymLinksIfOwnerMatch" must also be explicitly added for mod_rewrite to work properly. Without that change, enabling mod_rewrite will cause a Server Error on every Drupal page, and the Apache error log will have an error similar to: "AH00670: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions : /srv/www/htdocs/drupal/core/install.php". To fix the problem, add either "Options +FollowSymLinks" or "Options +SymLinksIfOwnerMatch" to /etc/apache2/default-server.conf. If you cannot edit that file, you can also make the change to your site's .htaccess file.

Note: Editing .htaccess is the fastest way to quickly troubleshoot and fix these types of Apache configuration problems. But, if you edit the .htaccess file remember that you have to re-edit your changes each new Drupal version. That is because Drupal ships with a new .htaccess file which will overwrite your changes. It's therefore best to make the changes permanent by moving them to Apache's configuration instead once you have fixed the problem.

If that looks OK I can add it as a documentation edit. Anything missing? Too wordy?

The MultiViews stuff proposed in #26 seems sensible and safe as well.

alexpott’s picture

Title: Disabling -MultiViews in .htaccess can cause 500 errors » Make .htaccess usage work for the widest possible configurations without relaxing security and document pitfalls
Issue summary: View changes
Status: Needs review » Needs work

@damien_vancouver thanks for the information - that looks really good. I've updated the issue title and issue summary.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

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

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

hswong3i’s picture

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.

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.

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.

ao2’s picture

StatusFileSize
new3.48 KB

It looks like the reroll for 8.9.x in #35 is exactly the same as the one for 8.8.x and for me it didn't work, uploading a working version.

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.

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.

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.