Skip to content

fix/DAV_permissions_single_read_only_file#54460

Open
tmorgumich wants to merge 10 commits intonextcloud:masterfrom
tmorgumich:feature/add-can-rename-move-props
Open

fix/DAV_permissions_single_read_only_file#54460
tmorgumich wants to merge 10 commits intonextcloud:masterfrom
tmorgumich:feature/add-can-rename-move-props

Conversation

@tmorgumich
Copy link

Summary

I implemented a three line check in lib/private/Files/View.php which aimed at addressing an issue where if Alice shares a file with Bob and sets his permissions to read-only, he is able to go beyond his permissions to the file, which are SGD, missing NV flags:<[oc:permissions]>SGD</oc:permissions>

autotest.sh passes with my added test to ViewTest.php, which creates a recipient and asserts that they are not able to move the file. The style passes tests as well.

@tmorgumich tmorgumich requested review from a team as code owners August 16, 2025 03:41
@tmorgumich tmorgumich requested review from come-nc, sorbaugh, susnux, szaimen and yemkareems and removed request for a team August 16, 2025 03:41
@szaimen szaimen removed their request for review August 16, 2025 07:23
Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request, but I think there is a misunderstanding.
In Nextcloud a user share is not the original file but a mount point, meaning e.g. for files you can set permissions like READ or UPDATE but they belong to the content of the file.
The mount point can still be freely renamed by the share receiver - its not the covered by the permissions of the share as those operations are covered by the parent folder permissions - similar to how local filesystems work.

"require-dev": {
"bamarni/composer-bin-plugin": "^1.4"
"bamarni/composer-bin-plugin": "^1.4",
"phpunit/phpunit": "^10.5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This is already in vendor-bin/phpunit

Copy link
Author

@tmorgumich tmorgumich Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to get phpunit to use the right version, as the autotest.sh was specifying lib/composer/bin/phpunit which I hadn't set up properly(?) and I couldn't run autotest

@@ -732,6 +732,11 @@ public function rename($source, $target, array $options = []) {
if ($source == null || $target == null) {
return false;
}
$sourceInfo = $this->getFileInfo($source);
if ($sourceInfo && !($sourceInfo->getPermissions() & \OCP\Constants::PERMISSION_UPDATE)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update permission is only for changing the content of a file, moving / copy is set by DELETE / WRITE of the containing folder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, thanks for clarifying.

Comment on lines +331 to +340
$propFind->handle(self::CAN_RENAME_PROPERTYNAME, function () use (
$node) {
return $this->computeCanRename($node) ? 'true' : 'false';
});

$propFind->handle(self::CAN_MOVE_PROPERTYNAME, function () use (
$node) {
return $this->computeCanMove($node) ? 'true' : 'false';
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why new properties? We already have the permissions which are assigned on the parent folder.
For copy the node needs READ and the parent needs CREATE permissions.
For move its like copy but with additional parent DELETE permission.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I definitely misunderstood the issue. I had began to work on a change to FilesPlugin.php which I thought could resolve the misunderstood non-real issue of a recipient being improperly able to move/rename a shared read-only file

@come-nc
Copy link
Contributor

come-nc commented Aug 18, 2025

So if I understand correctly this was a misunderstanding and can be closed?

@skjnldsv skjnldsv added bug 2. developing Work in progress labels Aug 19, 2025
@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants