Nextcloud · Report #1193321
Scoped apptokens can be changed by that very apptoken
Validstatus
highseverity
$1,000bounty
39upvotes
15 Jul 2021disclosed
How it was found
I noticed that there is the possibility to limit apptokens to not be able to access the filesystem.
- Create a new apptoken in
https://server/settings/user/security - Click the .. of your new apptoken and make it not allowed to access the filesystem
- Log out
- Navigate to
https://server/remote.php/davand login with your username + apptoken - Navigate again to
https://server/settings/user/security - You won't be able to access the apptoken data
- Obtain the CSRF token
- Send a PUT request to
https://server/settings/personal/authtokens/IDchaging 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. And voila. You have filesystem access.
You could also remove other apptokens of the same user (if you'd want).
Impact
Leaked scoped tokens could be used to gain full access to all your data. Defeating the whole purpose of scoped tokens.
I recommend.
- Only allow tokens that result from a real login (so user+pass+2fa) to modify/delete tokens
- Do not allow the current token in use to edit itself