I've seen D8 places it's configuration files under drupal8\sites\default\files\config_*\active. This is an insecure location if .htaccess is not available or broken. All the config files may contains very critical information to hack a site and prying eyes will be happy to see this details e.g. file system paths, site e-mail address, chmod settings and other settings. Maybe the encryption keys are also saved there, but I have not found them yet.

We have never made to to care about security here in past as this was all hidden in variables table, but once this stuff goes into the file system prying eyes are able to see this if something goes minimal wrong.

This folder need to be moved outside of the folders that are public e.g. private folder

Comments

hass’s picture

Issue tags: +Security

Not to forget about modules like http://drupal.org/project/imce that allow authenticated users to read this folders.

berdir’s picture

The important thing is the * in "files\config_*\active", which is a random string that you're going to have a hard time guessing from the outside. That has been discussed a lot and wouldn't have gotten in 8.x if it were not safe enough. We're also writing php files into the public files folder in similar ways.

I'm not sure how that plays together with modules like IMCE but that AFAIK already requires a special permission to have access to all files and not just a personal subfolder.

hass’s picture

Security through obscurity is no real security. Once the name is leaked you are lost.

berdir’s picture

Status: Active » Closed (won't fix)

Yes. Once your uid 1 password is leaked, your are lost as well. No difference?

The path is configurable. You can move it outside of the public directory if you have a possibility to do so. But not all hosts provide that possibility so we do the most secure thing possible.

hass’s picture

Status: Closed (won't fix) » Active

I cannot configure this in setup. At very minimum this need to be inside private folder. We cannot compare this with uid1 password. You may do not have htaccess support in webservers. Therefore you have zero security and a random string is not secure. Uid1 password is hashed in database (one way password).

gdd’s picture

Status: Active » Closed (won't fix)

We went through very extensive discussions about this in the early days of architecting the system which I am not going to re-open. For more background, see the discussions at

http://groups.drupal.org/node/155559#comment-524484

This solution was actually suggested by a member of the security team, and several others have said it is acceptable to ship with this configuration. This matter is closed, if you don't want your configuration in this location you can quite easily move it somewhere else, even out of webroot.

hass’s picture

Status: Closed (won't fix) » Active

How can I move this folders? Where is the documentation for this?

Thanks for the link. The discusion over there in the groups has not finally discussed the problem that htaccess may not *available* or ICME or a similar modules are active. Therefore the folder name needs no longer guessing. It is "known" by every user and therefore public. This undermine this non-existing security concept. I'm sorry, but this is not acceptable from security side.

Situation again:

  • .htaccess is not available (e.g IIS) on the server and cannot activated (non-clean url situation, too)
  • Random hashed folder is known by all users and therefore public
  • Everyone can read the config files
alexpott’s picture

The documentation is in default.settings.php

/**
 * Location of the site configuration files.
 *
 * By default, Drupal configuration files are stored in a randomly named
 * directory under the default public files path. On install the
 * named directory is created in the default files directory. For enhanced
 * security, you may set this variable to a location outside your docroot.
 *
 * @todo Flesh this out, provide more details, etc.
 *
 * Example:
 * @code
 *   $config_directories = array(
 *     CONFIG_ACTIVE_DIRECTORY => array(
 *       'path' => '/some/directory/outside/webroot',
 *       'absolute' => TRUE,
 *     ),
 *     CONFIG_STAGING_DIRECTORY => array(
 *       'path' => '/another/directory/outside/webroot',
 *       'absolute' => TRUE,
 *     ),
 *   );
 * @endcode
 */
$config_directories = array();

So it might be nice if this issue provides the patch to resolve the @todo :)

gdd’s picture

Status: Active » Closed (won't fix)

The ability to change the location of the config directory is documented in settings.php starting at line 236. Making this configurable through the UI is not necessary.

The discussion about .htaccess was in fact discussed in an earlier thread. It doesn't change anything. You still need to know the name of the directory in order to view it. This is actually no different than any other places where we use .htaccess to protect against security issues (such as the default .htaccess in the public files directory.) I don't understand what you're on about with IMCE.

Again, this has been discussed and accepted long long ago. Please do not change the issue status again.

lotyrin’s picture

@hass

We support good-enough brain-dead solutions for people that are running on LAMP shared hosts with .htaccess, and we suggest actual solutions for people able to move things out of the webroot. Is there anything more we can possibly do here?

Propose something actionable before reopening, please.

hass’s picture

@heyrocker: see ICME project home. You will see the poblic folder and are able to browse it like explorer. Every user is able to browse the folder including being able to read these files. There is no protection. They could also delete the config files or edit / replace them. ICME runsunder the server apache account. I wonder how security team can have missed this. Can we get them into this case here for further discussion.

Why is this random folder not located in private folder?

Don't close this case until you have 100% secure solutions to all this issues, please. The settings.php setting may be fine, but may not work for everyone and I guess we do not plan to release drupal insecure out of the box.

gdd’s picture

Then IMCE module will have to address this, it is *their* vulnerability that they choose to expose private information which they could easily strip from the display. It is very simple to simply not show the config directories in the browser. You get them from the api and strip them when displaying directories. Anyone choosing to expose this directory has a security hole in their module. This is not core's problem.

It can't be the private directory because we don't have that setup by default in a fresh install, and even if we did how would that help anything? It would have to be somewhere in sites/default/files anyways because Drupal can't assume access outside webroot on a fresh install. If you want private files to be secure you have to configure them by hand, just like you do for this.

What situations are there in which the settings.php solution will not work?

hass’s picture

I guess you mean file_scan_directory() that need to care about this.

$options += array(
  'nomask' => '/^CVS$/',
  'callback' => 0,
  'recurse' => TRUE,
  'key' => 'uri',
  'min_depth' => 0,
);

'nomask' does not remove the config_* folder.

hass’s picture

hass’s picture

We need to write documentation about a a recommended installation file structure. So it's clear what is absolutely secure and what not.

Example:

  • Install Drupal 8 into /srv/www/webX/html
  • Private files folder should reside in /srv/www/webX/files
  • Move your configuration files from public folder to /srv/www/webX/configuration/config_*/active that is ouside of private and public folder and not accessible by any site user.
hass’s picture

arlinsandbulte’s picture

Don't close this case until you have 100% secure solutions to all this issues, please.

There is no such thing as a 100% secure ANYTHING. 100% secure does not exist.

hass’s picture

I'm correcting myself: Not highjackable by just entering a public URL. This means 100% insecure.

David_Rothstein’s picture

Status: Closed (won't fix) » Active

Refreshing my memory on the previous discussions, this is actually the issue that was never resolved.

See for example #1444620-46: Remove file signing from configuration system and the comments that surround it. What we concluded there is that the name of a directory in a filesystem is inherently less secure than a hashed password. There are many ways it can be revealed (including some that exist in Drupal 8 core right now).

The security-by-obscurity aspect of it is still certainly helpful (it makes it impossible for script kiddies to hit the same URL on every Drupal site on the planet looking for holes) but we do have to assume that a determined attacker focusing on a particular site might be able to find out what it is.

Nonetheless, there is no security issue as long as your site is configured correctly. So I think this can be considered a configuration issue and the question is how to inform people of that.

Could we find a way to check if:

  1. The site's config directory is in a public location, and
  2. It's not protected by .htaccess or web.config?

If both of those are true, display an error in hook_requirements() (and also on every admin page load, same as Update Manager does when you have an insecure module).

A big question is how reliable of a check we could come up with... For #2 see also #1183044: Test whether htaccess protection works (although that's focused on checking a different .htaccess file).

catch’s picture

Title: Configuration files under security risk » hook_requirements() for un-proteced configuration directories
Category: bug » task
Priority: Critical » Major
djdevin’s picture

Tagging for issue summary update.

https://drupal.org/issue-summaries

hass’s picture

See #0

xjm’s picture

Priority: Major » Normal
Issue tags: +Needs issue summary update

Actually, the summary of the issue does not reflect the current thread of discussion, so let's get that discussion in here.

xjm’s picture

Issue summary: View changes

Updated issue summary.

mtift’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)
hass’s picture

Imoprt/export folders are still public. Issue is not fixed.

mtift’s picture

Status: Closed (won't fix) » Active

OK, let's make it not fixed.

adammalone’s picture

With config now in the database, how are we wanting to implement hook_requirements for the staging directory? Is it enough to bundle it in with a similar check to that done in system.install for settings.php and conf_path() to verify they're not world writeable or do we want to go further and warn if the staging directory exists under the public filesystem?

fgm’s picture

As mentioned in #2161591: Change default active config from file storage to DB storage, DB is only the default config storage, which can be overridden by setting $settings['bootstrap_config_storage'] to the file loader, so a check is in order if the configuration is not in the DB. Also, the fact that a non-active configuration is available in config_*/staging should probably trigger a warning too, as it can still contain information very much like the actual configuration.

fgm’s picture

Title: hook_requirements() for un-proteced configuration directories » hook_requirements() for un-protected configuration directories

(typo in issue title)

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.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.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.

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.

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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

fgm’s picture

Things changed since the last discussions on this: at the time, many projects were still having drupal at the project root, but with the usual scaffolds, Drupal is most often under (root)/web these days, so there is no longer really a good reason not to create the config outside, e.g. in (root)/config. The same actually applies to the private file system, logs, and temporary directories, I think : we could easily have more security by default by setting these instead of just documenting to users how to create them.

smustgrave’s picture

@fgm so think this issue should be re-scoped?

fgm’s picture

Probably, yes: the "files under webroot by default" situation which was true 12 years ago ceased to be with the recommended install, although it is still supported, so while the technical arguments in this discussion remain valid, their impact on actual deployments has changed.

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.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Needs work

Already tagged summary update.