Skip to content
Access control Disclosed report Intermediate

Delete permission can be added on reshare

A user who receives a shared folder can reshare it with another user and add the delete permission, even though the original share did not include delete rights. This allows the recipient (or the resharer themselves via a group) to delete files owned by the original sharer.

phil-davis Follow

Originally disclosed on HackerOne

  • Triaged in 17 hours
  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 2 months

user0 creates folder /test user0 creates file /test/file.txt user0 shares folder /test with user1 with read+share permissions (17) user1 receives the folder /test and can read-download /test/file.txt but not delete - good user1 uses the sharing API to share folder /test with user2, and specifies read(1)+reshare(16)+delete(8)=permissions 25 e.g.

curl --user user1:user1 "http://172.17.0.1:8081/ocs/v1.php/apps/files_sharing/api/v1/shares" -H "OCS-APIRequest: true" -X POST --data 'path=/test&shareType=0&shareWith=user2&permissions=25'

user2 deletes /test/file.txt

curl --user user2:user2 "http://172.17.0.1:8081/remote.php/dav/files/user2/test/file.txt" -H "OCS-APIRequest: true" -X DELETE

or with the webUI.

This seems to be a side-effect of https://github.com/nextcloud/server/blob/master/lib/private/Files/View.php#L1389

			if ($mount instanceof MoveableMount && $internalPath === '') {
				$data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
			}

which seems to be there so that a user that receives a share gets "implied delete" access to the share "root" so that they can unshare. (They cannot really delete the whole received share, when they "delete" they are actually just "unsharing". But when they reshare on to user2 then this "implied delete" is able to be passed on.

The problem also happens if user1 shares with a group, and adds the delete permission. Users in the group can delete files. user1 can share with a group that they are already a member of. That gives user1 delete access to the files in the folder.

Impact

A malicious user can reshare any received share, adding the delete permission to the reshare. Thus giving themselves (if they are in the group) or the end-user the ability to delete files of the first user.

The scenario works with current server master. I guess it will work with 16.* release...

The original report as published on HackerOne, by phil-davis. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code automatically adds delete permission to the root of a received share so the recipient can unshare it, but this implied permission is not stripped when the share is reshared, allowing it to be passed on.

Impact

A malicious user can reshare a received share with delete permission, allowing themselves (if in the group) or the end-user to delete files of the original sharer.

What the attacker needed

Attacker has a user account; victim shares a folder with attacker; attacker has reshare permission

How it was found

  1. user0 creates a folder and a file inside it.
  2. user0 shares the folder with user1, giving read and share permissions but not delete.
  3. user1 uses the sharing API to reshare the folder with user2, specifying read, reshare, and delete permissions.
  4. user2 deletes the file using the API or web interface.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you share a folder, you can choose what the other person is allowed to do, such as read or delete. The system had a flaw: someone you shared with could pass the folder on to someone else and secretly give them permission to delete your files, even if you never allowed that. This means your files could be deleted without your consent.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by phil-davis

View all

1 more disclosed report, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.