Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScriptHandler.php creates settings.php file with too loose of permissions #390

Closed
ryan-hovland opened this issue May 2, 2018 · 3 comments

Comments

@ryan-hovland
Copy link

The settings.php file contains sensitive information (salt, database connection credentials) and should not be read/write by everyone (especially on shared hosting). In order to assist the less security minded users the default permissions should be changed.

File: drupal-project/scripts/composer/ScriptHandler.php

Line: 50

$fs->chmod($drupalRoot . '/sites/default/settings.php', 0666);

Suggest changing to

$fs->chmod($drupalRoot . '/sites/default/settings.php', 0660);
@weitzman
Copy link
Contributor

weitzman commented May 3, 2018

FYI settings.php best practice is to put sensitive info in env variables. See https://github.com/drupal-composer/drupal-project/blob/8.x/.env.example

Still, the proposal looks good.

@webflo
Copy link
Member

webflo commented May 4, 2018

The settings.php should be writable after the initial setup for the Drupal installer later. The Drupal installer or bootstrap will change the permissions after the file has been updated.

This code is located in system_install() around line 450.

    foreach (['settings.php', 'settings.local.php', 'services.yml'] as $conf_file) {
      $full_path = $site_path . '/' . $conf_file;
      if (file_exists($full_path) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($full_path, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE))) {
        $conf_errors[] = t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", ['%file' => $full_path]);
      }
    }

@webflo
Copy link
Member

webflo commented May 4, 2018

Please join the discussion in #200

@webflo webflo closed this as completed May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants