# Scoped apptokens can be changed by that very apptoken

A filesystem-scoped app token could PUT to the authtokens endpoint to widen its own scope, gaining full file access.

- Payout: $1,000
- Severity: high
- Program: Nextcloud
- Found by: rtod
- Disclosed: 2021-07-15
- CVE: CVE-2021-32688
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1193321
- Library page: https://bugbountylibrary.com/r/h1%3A1193321
- Tags: area:web domain:web impact:data-leak impact:privesc kind:bounty platform:hackerone sev:high tech:rest vuln:access-control vuln:auth-bypass vuln:privilege-escalation

**Target:** Nextcloud server /settings/personal/authtokens/{id} endpoint
**Root cause:** The authtoken modification endpoint authorized any valid app token, including the token being modified, without requiring a real password+2FA login session or preventing self-modification.
**Steps:**
1. Create app token at `/settings/user/security`
2. Edit token scope to disallow filesystem access
3. Log out, authenticate to `/remote.php/dav` with username+apptoken
4. Visit `/settings/user/security`, grab CSRF token
5. Brute-force token ID (no rate limiting) and send `PUT /settings/personal/authtokens/ID` with widened scope
6. Token now has filesystem access
**How found:** Noticed scoped-token feature, hypothesized the token itself could reach the token-management endpoint, tested self-modification via PUT after DAV login.
**Exploitation:** Attacker holding a scoped token logs in via DAV, obtains CSRF token from settings page, iterates token IDs (no throttling) and PUTs a scope change to its own token, escalating to full filesystem access; can also delete other tokens of the same user.
**Escalation:** Scope escalation from filesystem-restricted token to full data access; also enables deletion of other apptokens of the same user.
**Insight:** When a product introduces scoped/limited credentials, test whether the limited credential can still reach the credential-management API to widen its own scope—self-modification of permissions is a common blind spot.

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

**PUT request changing apptoken scope**

```
Send a PUT request to `https://server/settings/personal/authtokens/ID` chaging the scope

Now the ID you do not know. However even on a decent sized system it is not hard to iterate this as there is no rate limiting or throttling at all.
```

