If I am running an NGINX webserver with a fully writeable files directory, Security Review will complain that "The .htaccess file is writeable which poses a risk should a malious user find a way to execute PHP code they could alter the htaccess file to allow further PHP code execution.".
As NGINX doesn't process the .htaccess file, might it be appropriate to use a variable like $_SERVER["SERVER_SOFTWARE"] to restrict this check to Apache?
Alternatively, maybe the module can add a test file to the files directory to see if code execution is possible. After all, even if .htaccess says the right things the web server's configuration may be problematic.
Comments
Comment #1
populist commentedComment #2
david strauss> After all, even if .htaccess says the right things the web server's configuration may be problematic.
Or the web server configuration may restrict it regardless of what htaccess says.
Comment #3
coltrane"Alternatively, maybe the module can add a test file to the files directory to see if code execution is possible."
That happens in check security_review_check_file_perms() http://cgit.drupalcode.org/security_review/tree/security_review.inc#n218 and also in security_review_check_executable_php() http://cgit.drupalcode.org/security_review/tree/security_review.inc#n614.
But yes this check could be improved to not always fail in other environments. I'm not sure I'll get to this soon so any support you can provide is welcome.
Comment #4
Sakhmed commentedHi guys!
I am running NGINX webserver as well and getting same warning on Security Review Check.
Is this warning dangerous for my site? What can I do to git rid of this warning?
Please let me know
Comment #5
serundeputy commentedHere is a patch to exclude the
.htaccesscheck for nginx webserver.Still works for apache, however there is a code comment on line 655 (with the patch applied); that says:
but in my testing I needed to modify
$resultSo we need someone(s) to check this on nginx and someone to verify if modifying
$resultfor theis_writable()condition is the correct course of action?thanks,
~Geoff
Comment #6
serundeputy commentedugh; #5 doesn't work; i'll try to get back to it next weekend :(
Comment #7
serundeputy commentedneeds to be checked on nginx.
Comment #9
serundeputy commentedre-rolling patch so it can apply.
Comment #10
serundeputy commentedComment #11
serundeputy commentedforward port to drupal 8
@banviktor , @coltrane
would this be better put in : https://www.drupal.org/node/2375303 ?
thanks,
~Geoff
Comment #13
serundeputy commentedoh; because it is trying to apply the D8 patch on the `7.x-1.x-dev` branch.
this needs patch https://www.drupal.org/files/issues/security_review-bypass-htaccess-chec... for `7.x-1.x-dev`
and patch https://www.drupal.org/files/issues/D8-security_review-false-neg-for-ngi... for the `8.x-1.x-dev` branch.
sorry,
~Geoff
Comment #14
serundeputy commentedsetting to 8.x to test current patch then back port to 7.x
Comment #15
serundeputy commentedComment #17
hugovk commentedHere's a re-roll of the Drupal 8 patch from #11.
As before, it wraps that code block with:
Comment #18
davisbenHere is a re-roll against the latest dev.
Comment #19
smustgrave commented#18 works for me.
Comment #20
segi commentedI have used patch from #18 but I got a php error:
Undefined array key "SERVER_SOFTWARE" ExecutablePhp.php:82
I fixed in this new patch.
Comment #21
nattsWill this ever be included in a release? :-)
Comment #22
smustgrave commentedCommitted in https://git.drupalcode.org/project/security_review/-/commit/282208f013dd...
Comment #24
emjayess commentedI'm here because of a search for similar behavior in Drupal core's status report. First I thought I'd stumbled into just the right issue, then was scratching my head because of the closed status and note about this landing in a commit... yes, it took me a minute or three to realize I was in the issues for Security Review module, instead of drupal proper.
So the question is) does anyone have any insights as to whether any similar detection of web server has been proposed for Drupal core? Because if I'm not using Apache, I would much rather NOT have this warning about `.htaccess` always staring at me (or my clients) in the status report.
Comment #25
greggles@emjayess thanks for the followup. Can you post a screenshot of the message in the status report?
Comment #26
emjayess commentedCertainly, attached. Thanks for taking interest.. although I'm sure this is not the best place to take up the issue.
If it matters, this is a site currently running Drupal 10.4.0, which had recently been upgraded from version 8, then version 9, etc. And it is running on Pantheon; my local/dev environment also uses nginx (valet).
Comment #27
greggles@emjayess that error message comes from core's system.install.
Here's an issue that I think is relevant to your goal of making it more appropriate for nginx users #3117665: Only show the error “Public files directory Not fully protected” for Apache servers
Comment #28
emjayess commented🙏🏼 Thank you for the direction @greggles!