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
Comment #1
hass commentedNot to forget about modules like http://drupal.org/project/imce that allow authenticated users to read this folders.
Comment #2
berdirThe 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.
Comment #3
hass commentedSecurity through obscurity is no real security. Once the name is leaked you are lost.
Comment #4
berdirYes. 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.
Comment #5
hass commentedI 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).
Comment #6
gddWe 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.
Comment #7
hass commentedHow 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:
Comment #8
alexpottThe documentation is in default.settings.php
So it might be nice if this issue provides the patch to resolve the @todo :)
Comment #9
gddThe 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.
Comment #10
lotyrin commented@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.
Comment #11
hass commented@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.
Comment #12
gddThen 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?
Comment #13
hass commentedI guess you mean file_scan_directory() that need to care about this.
'nomask'does not remove theconfig_*folder.Comment #14
hass commentedOpened #1914914: file_scan_directory() does not exclude config folder by default
Comment #15
hass commentedWe need to write documentation about a a recommended installation file structure. So it's clear what is absolutely secure and what not.
Example:
/srv/www/webX/html/srv/www/webX/files/srv/www/webX/configuration/config_*/activethat is ouside of private and public folder and not accessible by any site user.Comment #16
hass commentedOpened #1914932: Config staging directory needs a .htaccess file.
Comment #17
arlinsandbulte commentedThere is no such thing as a 100% secure ANYTHING. 100% secure does not exist.
Comment #18
hass commentedI'm correcting myself: Not highjackable by just entering a public URL. This means 100% insecure.
Comment #19
David_Rothstein commentedRefreshing 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:
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).
Comment #20
catchComment #21
sun#1917778: Use the private filesystem for config directories, and expose a private filesystem path setting in the installer
Comment #22
djdevinTagging for issue summary update.
https://drupal.org/issue-summaries
Comment #23
hass commentedSee #0
Comment #24
xjmActually, the summary of the issue does not reflect the current thread of discussion, so let's get that discussion in here.
Comment #24.0
xjmUpdated issue summary.
Comment #25
mtiftClosed because of #2161591: Change default active config from file storage to DB storage
Comment #26
hass commentedImoprt/export folders are still public. Issue is not fixed.
Comment #27
mtiftOK, let's make it not fixed.
Comment #28
adammaloneWith 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?
Comment #29
fgmAs 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.
Comment #30
fgm(typo in issue title)
Comment #44
smustgrave commentedThank 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!
Comment #45
fgmThings 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)/webthese 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.Comment #46
smustgrave commented@fgm so think this issue should be re-scoped?
Comment #47
fgmProbably, 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.
Comment #49
smustgrave commentedAlready tagged summary update.