Major Security issue with Local External Storage

Because Nextcloud is run as ā€˜apacheā€™ or whatever web server user youā€™re using, and that user must have ownership of the NC installation files / webroot, itā€™s possible for any user that has been given ā€œLocalā€ mount permissions to mount the NC root, and be able to bring up the ~/nextcloud/config/config.php file, giving them access to things like the database credentials, password salt, redis credentials, etc.

I know that Iā€™m going to get answers like, donā€™t give local mount access, or use a secondary admin with fewer rights but these are bandaids for a glaring security issue. There are lots of reasons why you want to allow local mounts by your users, and there are also lots of scenarios where the admin user of Nextcloud should potentially be restricted from certain paths in the filesystem.

Is there a configuration option to completely lock out certain filesystem paths from the app configuration file, or the system configuration? (read: NOT FROM THE WEB CONSOLE, which defeats the purpose since the admin user would still be able to remove those locks).

If not, Iā€™d like to propose a two-way config option that would create either an allow-list, or a deny-list, something like thisā€¦

<?php
$CONFIG = array (
  'external_storage' => array (
      'paths_allow' => array (
          '/mnt/',
          '/home/%CURRENT_USER%/'
      ),
      'paths_deny' => array (
          '/mnt/not_this_folder/',
          '/var/www/nextcloud/'
      ),
   )
)

I know that in the example above, the block of the /var/www/nextcloud/ is not applicable in the context of whatā€™s allowed, but I would suggest that paths_allow and paths_deny are not mutually exclusiveā€¦ you wouldnā€™t have to use both, but you can if you need such as the case of /mnt/ where the a path is allowed but a specific sub-folder is denied.

If there is a facility to do this already, thatā€™s great, please point it out, but if not, I would be willing to put time into a pull request to add this functionality to the app, and would appreciate suggestions.

Thanks,
Kevin.

1 Like

Hi,

In general please submit things you think are issues to hackerone.com/nextcloud

Yes giving user local mount permissions creates all kind of issues. For example you have write permissions to other folders your webserver has access to as well etc. Hence this is not recommended.

What you describe it not there. But a PR would be welcome.

Cheers,
ā€“Roeland

1 Like

Thanks @rullzer, wasnā€™t aware of hackerone, will use that going forward.

Cheers,
Kevin.

2 Likes