I'm new to Drupal and somewhat new to the Linux file system.
I vaguely understand file permissions, and I'm not sure what I need to do to pass
the file permission test of the Security Review block.
After running the report,
I received "Some files and directories in your install are writable by the server."
It is recommended that the following files or directories be corrected.
A long list of files in a few directories were listed.
/phpbb3/ directories (I have a PHPBB3 forum on my site)
/modules directory
/sites/all/modules directory and subdirectory

I would appreciate some direction. Thanks

Comments

coltrane’s picture

Status: Active » Postponed (maintainer needs more info)

You should review the file ownership and permissions of those files as compared to the users and webserver user of your host. For example, if your webuser is "www-user" and those files and directories are owned and writeable by that user then that could allow an attacker to write arbitrary files or code to those locations. To fix you might chmod or chown those file or directories. You may also need to review your host's documentation on webroot file and directories for details on how to change the permissions.

Setting this issue to "postponed" for more questions.

gandro_spam’s picture

techman-1’s picture

Coltrain, I appreciate your response.
I went through some of those files, did a ls -l command
and found that the root user is shown as the owner and the root user is also show as the group that owns this file.
I'm not sure what other commands I need to execute to determine if my web server (web user) has permission
to write to these files.

mgifford’s picture

Find out the apache user or <?php echo shell_exec('whoami'); ?>.

This should be fine as in CentOS apache is run by nobody and needs write access to the files/ directory for caching and file uploads. Drupal.org recommends something like:

$ ls -la sites/default | grep files
drwxrwx--- 9 nobody example-group 4096 Jul 19 14:18 files/

In debian/ubuntu www-user would the the user that should own the directory.

Now this isn't what youd' get from:
chmod 2775 sites/default/files

But that's not going to give you the permissions described in the drupal.org page listed above.

What specifically is Security Review looking for? Some write permissions are usually required for Drupal sites, for caching if nothing else.

Would be good if the error message was clearer indicating exactly what should be done to improve the security of the files directory.

coltrane’s picture

Here is what this check is doing http://drupalcode.org/project/security_review.git/blob/refs/heads/7.x-1.... and specifically http://drupalcode.org/project/security_review.git/blob/refs/heads/7.x-1..... In brief, it's looking for all files and directories that are writable with the exception of Drupal's files and private files directory and many VCS directories.

I do believe the messaging could be more clear, but it's difficult to write out what exactly should be done because those steps vary depending on the specifics of the web server. I welcome review of the current documentation and ideas to make it more helpful to more people.

mgifford’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new7.99 KB

Here's a patch to at least take a hack at being much more explicit in the failure messages.

Definitely a challenge with Windows/Linux. But really, the default is Linux, so I don't see why we can't give a chmod and include a link to the docs for more information.

Feel free to rip up the proposal. I did it quickly and it definitely needs to be cleaned up and standardized.

Status: Needs review » Needs work

The last submitted patch, documentation-1955974-6.patch, failed testing.

coltrane’s picture

Status: Needs work » Needs review
StatusFileSize
new4.24 KB

Thanks @mgifford! I think the tests failed only because the success/fail text is tested for, so the .test file would have been updated.

I feel strongly that mitigation recommendations are best explained on the individual help pages rather than within the failure strings. For some checks it's necessary to set some context and expectations before suggesting one course of action or another. I do think the text of the help pages could use work and even the individual success/failure strings could be improved, but I'd like to keep the result separate from the action of fixing. What do you think of that?

Here's a new patch which adds some of your text to the security_review_check_file_perms_help() function and holds onto the text added within the module writtten files.

mgifford’s picture

Looks good to me. Thanks!

coltrane’s picture

Version: 7.x-1.0 » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

  • coltrane committed d00f853 on 8.x-1.x
    Issue #1955974 by mgifford, coltrane: Improve text of file permissions...
smustgrave’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)

As Drupal6 has been EOL https://www.drupal.org/about/drupal6-eol closing as outdated