nextcloud / nextcloud/server

Nested sharing could only lower the access rights

Open
#19,012 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement feature: sharing
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Mostly I wonder is it a bug or feature? Is there any special reason Nextcloud work like that? And are there any changes in next releases?

Steps to reproduce
  1. Create folder1 and test.txt in it;
  2. Give some user read-only permissions to folder;
  3. Give the same user write prmissions to test.txt;
Expected behaviour

User should be able to write into file. The closest sharing option should be selected.

Actual behaviour

User has read-only access to file.

Cause

In Cache.php of files_sharing application there is an entry:

if (isset($entry['permissions'])) {
    $entry['permissions'] &= $sharePermissions;
} else {
    $entry['permissions'] = $sharePermissions;
}

If you change AND (&=) to OR (|=), you'll not be able to forbid user something inside the shared folder.
Is there any reason why we can't use $entry['permissions'] to the file?

Nextcloud version: 16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Cache.php in the files_sharing application and trace how permissions from nested shares are combined. Reproduce the folder and file sharing steps, then establish whether the closest share should grant write access without allowing nested restrictions to be bypassed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authorization, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.