I uploaded a logo to the site through the theme interface but it didn't show. After some experimentation, I discovered that adding the following line to the .htaccess the sites/example.com/files directory fixed it:

Options FollowSymLinks

So my complete files looks like this:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>

I'm clueless as to why it works and whether or not it introduces a new security hole. I'll let some apache configuration gure figure this out.

CommentFileSizeAuthor
#13 _67244htaccess.patch1004 bytesMorbus Iff
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Morbus Iff’s picture

It doesn't introduce any holes (at least, none that can be exploited easily through Drupal), but you're the second person to report this as a requirement to their .htaccess. I'm at a loss why as well.

rbowen’s picture

Could you please provide Apache error log entries associated with "It didn't show". This will give insight into what is actually meant, from Apache's perspective, by "it didn't show."

Thanks.

rbowen’s picture

After further thought, what I expect to see in the logs is "RewriteEngine not permitted here". Due to security considerations that I'll go into in more detail if anybody cares, Rewrite* directives are only permitted if Options FollowSymlinks is enabled. For most folks, Options FollowSymlinks is enabled everywhere, so this is a non-issue, but if you happen to disable it, you'd have to re-enable it here. Which is itself problematic, since most folks won't have 'AllowOverride Options' enabled.

Further experimentation is required to verify these theories. I haven't tested this yet.

Morbus Iff’s picture

Eh oh, DrB. Per the apache mailing list thread you had pointed us to, we had added Options None in an attempt to satisfy the "turn off MultiViews" requirement (it being, certainly, "stronger" than just Options -MultiViews). While I was unable to reproduce it on my own server, we did get one report from our testers of a server error which complained about RewriteRules - which, in this case, were being inherited from the parent .htaccess and complaining as you surmise - that FollowSymLinks or SymLinksIfOwnersMatch weren't enabled (due to our None) and thus RewriteRule wasn't allowed. I had him add a set of IfModules for mod_rewrite, with RewriteEngine off, and the problem went away. That's the .htaccess we're currently shipping.

Heine’s picture

I second the request for logs. We're switching off the Rewrite engine because we set Options None. Since it's off, you shouldn't get the error.

Would you mind testing the following .htaccess:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
RewriteEngine off
Steve Dondley’s picture

Error log:

[Sun Jun  4 16:16:22 2006] [error] [client **.***.***.***] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /home/site/sites/site.org/files/dc_logo.jpg

Heine, I tried you suggestion (took out the if statement) and still got the above error.

Daniel55’s picture

Component: theme system » update system

After updating from 4.7.1 to 4.7.2 no pictures are shown on my Drupal site anymore. If I try a direct call of a picture-URL I get the error: "Forbidden You don't have permission to access /files/xyz.jpg on this server."

With the new line "Options +FollowSymLinks", the problem is fixed.

profix898’s picture

I can confirm this issue. For me its exactly as for Daniel55. All my images from /files/siteX/... were broken after update (my Drupal's .htaccess is in /files/siteX/...) even those of gallery2, which are located at /files/gallery/... in a parellel directory. After adding "Options +FollowSymLinks" (or zero-out of htaccess of course) all works as expected.

jo1ene’s picture

I am experiencing this specifically for logos. The obnoxious thing about it is that I figured it had something to do with the new .htacess, but I couldn't delete it. It kept reappearing so I couldn't really test it thouroughly. I have the code in #5 in my htacess. I can't call images directly from http either.

Heine’s picture

@jo1ene, you can empty .htaccess or add the Options Followsymlinks as Steve describes.

Can you tell a bit more about the site(s) setup? For example; are these all multi-site installation?

jo1ene’s picture

I found the solution. My server didn't like any reference to options at all and it wanted the .htacess file itself to be 644 permissions. It had spawned itself at 600. Basically, I have an empty file now with 644 permissions and it's working.

sin’s picture

I have the same issue in single site 4.7.2 with files and images, uploaded to "files" dir by upload module or FTP.
"Options FollowSymLinks" in "files/.htaccess" fixes my problem, thanks Steve.

Morbus Iff’s picture

Assigned: Unassigned » Morbus Iff
Priority: Normal » Critical
Status: Active » Needs review
FileSize
1004 bytes
killes@www.drop.org’s picture

Version: 4.7.2 » x.y.z
Status: Needs review » Reviewed & tested by the community

according to the principle that Mobus knows more about apache than myself, this is good to go.

beginner’s picture

What happens to those who already have a .htaccess? The existing one won't get modified.

Morbus Iff’s picture

Irrelevant, I'd say. The bug is quite noticable - all your uploads won't work, including logos, user avatars, and so forth. People affected either are a) already working around it by manually adding the line this patch does or b) using a zero byte file, also as recommended by this issue. For those who don't have the particular set of Apache configurations that cause this bug, the newly revised .htaccess is unnecessary, and affords no extra, or less, protection.

beginner’s picture

ok, thanks for the explanation. :)

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

On dealing with upgrades- I'm not sure this is enough since the solution (which i think is rm files/.htaccess and let it be recreated automatically) is not actually obvious. I'll mark this as fixed, but someone should reopen if they have any plans for making this more obvious.

killes@www.drop.org’s picture

backported to 4.7

TheoRichel’s picture

I have the same problem, but I do not understand what is said here. I understand the problem is fixed, but I am completely at a loss about what I should do.

Olafski’s picture

Version: x.y.z » 4.7.3

I've got the described problem. Unfortunately none of the above mentioned suggestions does help me - except the one to empty the .htaccess file. I don't understand if that workaroung fixes the problem without getting into trouble because of security risks.

(Not running a server by my own I'm no expert in Apache logs, I guess I can't even see them, can I? However: single site in a subdirectory, .htaccess in "[subdirectory]/files"; do you need more info?)

Anonymous’s picture

Status: Fixed » Closed (fixed)