fix: check for the identifier alias for the storage backend#41538
fix: check for the identifier alias for the storage backend#41538jvillafanez wants to merge 6 commits into
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
DeepDiver1975
left a comment
There was a problem hiding this comment.
- can you add unit tests?
- please add changelog items
fa639a3 to
5080fc6
Compare
ec4554e to
88fcb18
Compare
DeepDiver1975
left a comment
There was a problem hiding this comment.
- I miss tests where local storage mounting is allowed.files_external_allow_create_new_local => true
- did you double check if the http status code change 422 -> 403 has any impact on the frontend. technically this is a breaking change to the api
I don't think it's possible to trigger the behavior from the web UI. If the backend isn't visible, it won't show up in the frontend and it won't be selectable. The change in the HTTP code should match the previous behavior: it returns a 403 if the user tries to create or update a backend that he isn't allowed to use. It also makes more sense to return a 403 error in those circumstances.
They should be covered. For the global / user storage controllers, the tests have the flag enabled by default, so all those tests run with that setting. The only exception are the "new" |
looking at the changeset - I see files_external_allow_create_new_local only being removed from the code - is this setting actually still be checked anywhere? |
I prefer 'are' over 'should' - assertion over assumption |
It's used in the settings page. The flag is in an awkward position... it doesn't allow the creation of the local storage from the frontend, but the admin can still create the local storage via API. Regular users won't be able to setup local storages anyway. I'll try to add an |
just to be sure: the backend has to verify everything - ignore frontend beahavior. |
Without the visibility, the admin won't be able to create local storages, and the previously created local mounts will be hidden and inaccessible
7039820 to
45ffc86
Compare
|
There might be slightly changes in the behavior with the PR because the checks have been moved to visibility. If the backend isn't visible for someone, this means that the mount point (if any) will be hidden and won't appear (it won't be accessible), and creating or updating new mounts with the backend won't be possible. To remark, if the backend becomes visible at a later date, previously existing hidden mounts will reappear. Specifically, for the local storage, it will be blacklisted for regular users and it will never have the visibility for regular users. Admins will require the |
Code ReviewOverviewThe PR fixes a security bypass: the original code checked What's Good
Issues1. Missing test cases for the allowed path (also raised by @DeepDiver1975) There are no tests where 2. The new controller tests may not exercise the right code path The old controller check ran at request time. The new check runs at registration time ( 3. Breaking HTTP status code change: 422 → 403
4. Type annotation inconsistency in /** @var IConfig */
private IConfig $config; // typed property (PHP 7.4+)
/** @var bool */
private $allowUserMounting = null; // @var says bool, initialized to null
/** @var array */
private $userMountingBackends = null; // @var says array, initialized to nullTyped property syntax is mixed with old docblock-only style. The 5.
6. Hardcoded blacklist in $blacklistedBackendsForUsers = ['\OC\Files\Storage\Local'];This in-method local variable carries no documentation. A short comment explaining why local storage is always blacklisted for users regardless of 7. Changelog grammar (also noted by @phil-davis)
SummaryThe security fix itself is sound and well-targeted. Main blockers before merge: (a) missing "allowed" happy-path test cases, (b) confirming the new controller tests actually exercise the intended code path, and (c) verifying the 422→403 change doesn't break frontend error handling. The type annotation issues, missing cache, and undocumented blacklist are minor but worth a cleanup pass. |
Description
Prevent local storage to be used as external if it isn't explicitly allowed.
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Notes:
This is likely the minimum change possible at the moment. There are no plans to add or modify the backend's aliases
or identifiers at the moment, but it could become unmanageable quickly.
We should consider to move and improve the check at some point.