matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.68k stars 2.62k forks source link

Allow moving all files apart from assets out of web root #19505

Open Findus23 opened 2 years ago

Findus23 commented 2 years ago

this is a bit of a continuation of #8120

At the moment, Matomo can only be used by settings the web root to the directory all Matomo files are in. This means additional web server configuration and precisely crafted rules are required so that security-relevant files (especially tmp/ and config/) are not publicly accessible. But as web server configurations vary widely and as the recent "private directories" system check shows, there are a lot of people for who these configurations don't work (most commonly because AllowOverride is disabled (#17819) and therefore the .htaccess files created by Matomo do nothing). And the system check that tries to access the URLs that should be private makes some people aware of this, but often confuses people (#18693) or creates new issues (#18182, #17589, #18967, #19149) either because the failing requests trigger things like fail2ban or because it exposes broken cacert-setups. And that is completely ignoring the question of people who don't use apache and then have to find out themselves that they need to block some file requests or their Matomo setup is insecure.

To get to the point: I feel like offering a Matomo install which works similar to this (and how most modern PHP/laravel applications work) would solve a lot of complexity which gaining a lot of security:

Also this would be an optional feature as there are still people who don't know what a web root is (even though a lot of PHP FOSS applications don't offer any other way to be used).

In summary, I think this would make it a lot harder for people to accidentally shoot themselves into the foot in regard to security (it's not like I haven't noticed in the past that I had some important Matomo files accidentally public), but it also has the disadvantage of offering "one more way" to install Matomo.

heurteph-ei commented 1 year ago

@Findus23 , you write:

  • JS/CSS assets would work out of the box as they use index.php

Do you mean Matomo tracker JS file and MTM containers? If yes, this will then prevent the easy publication of MTM containers through CDN for example...

Findus23 commented 1 year ago

Do you mean Matomo tracker JS file and MTM containers? If yes, this will then prevent the easy publication of MTM containers through CDN for example...

When I wrote this, I didn't think of those. I just mean the JS and the CSS that is used by the Matomo Backend. It's true that matomo.js (and all variants of those) and the MTM containers would need to be inside the public root. But that should not be more complex to solve than the rest of this issue.

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/how-to-harden-a-matomo-installation/49765/6

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/impossible-to-install-the-wordpress-plugin-on-elementor/49767/4

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/required-private-directories-recommended-private-directories/50193/2

randy-innocraft commented 1 week ago

Hi @Findus23 , Thank you for bringing this to our attention and for your valuable input. Your suggestion seems like a valuable enhancement to our product. We will forward this to our Product team for review and future consideration. If you have any additional details or questions, please feel free to share them here.