# Attacker can obtain write access to any federated share/public link

Anonymous POST to /index.php/ocm/notifications with a leaked sharedSecret and providerId let an attacker grant themselves write/share on any federated share or public link.

- Payout: $4,000
- Severity: high
- Program: Nextcloud
- Found by: rtod
- Disclosed: 2021-06-10
- CVE: CVE-2021-32654
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1170024
- Library page: https://bugbountylibrary.com/r/h1%3A1170024
- Tags: area:web domain:web impact:integrity impact:privesc kind:bounty platform:hackerone sev:high tech:php technique:source-review vuln:access-control vuln:auth-bypass vuln:business-logic

**Target:** Nextcloud server OCM federation endpoint /index.php/ocm/notifications
**Root cause:** The OCM notification handler processes RESHARE_CHANGE_PERMISSION without authenticating the sender or verifying the notification originates from the legitimate share owner; the sharedSecret from oc_share_external is treated as sufficient authorization.
**Steps:**
1. Obtain a read-only public link or federated share.
2. Use 'Add to my Nextcloud' to create a federated share to attacker instance and accept it.
3. Read `remote id` and `token` (sharedSecret) from attacker's `oc_share_external` table.
4. Send `curl -X POST http://victim/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'`
5. Access the share with read+write+update+create+share permissions.
**How found:** Noticed public links could be added as federated shares, then inspected the local oc_share_external table for the remote id and token, hypothesizing the OCM notification endpoint trusted these values without sender authentication.
**Exploitation:** Attacker needs only a public link or existing federated share. By accepting the share on their own instance they learn the sharedSecret and providerId, then anonymously POST a forged RESHARE_CHANGE_PERMISSION notification to the victim's OCM endpoint to escalate permissions and overwrite/add files.
**Escalation:** Applies to any federated share, not just public links, so any share recipient can escalate to write/share.
**Insight:** Federation/OCM notification endpoints often trust sharedSecret as bearer auth; enumerate oc_share_external-style tables on your own instance to harvest tokens and replay forged permission-change notifications against the remote.

## Proof of concept (copied exactly from the original report)

**Anonymous POST to ocm/notifications elevating share permissions**

```
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'
```

