Skip to content
Access control Disclosed report Intermediate CVE-2021-32688

Scoped apptokens can be changed by that very apptoken

An app token that was deliberately restricted from accessing the filesystem could still be used to change its own scope through the token settings endpoint. An attacker holding a leaked, scoped token could widen it to full filesystem access, or delete the user's other tokens.

rtod Follow

Originally disclosed on HackerOne

Bounty$1,000 High 8.7 View original
  • Triaged in under an hour
  • Fixed in 7 days
  • Paid in 7 days
  • Disclosed after 2 months

I noticed that there is the possibility to limit apptokens to not be able to access the filesystem.

  1. Create a new apptoken in https://server/settings/user/security
  2. Click the .. of your new apptoken and make it not allowed to access the filesystem
  3. Log out
  4. Navigate to https://server/remote.php/dav and login with your username + apptoken
  5. Navigate again to https://server/settings/user/security
  6. You won't be able to access the apptoken data
  7. Obtain the CSRF token
  8. 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. 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.

  1. Only allow tokens that result from a real login (so user+pass+2fa) to modify/delete tokens
  2. Do not allow the current token in use to edit itself

The original report as published on HackerOne, by rtod. 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

Likely the token-management endpoint authorised any valid session, including one created from an app token, so a token could modify its own scope.

Impact

A leaked scoped token could be escalated to full access to all the user's data, and other tokens of the same user could be removed; the token ID must be guessed, but the text says there is no rate limiting to stop iteration.

What the attacker needed

A valid app token for the account; token ID guessed by iteration; no rate limiting on the endpoint

The fix

Only tokens created by a real login with password and second factor should be able to modify or delete tokens, and a token should not be able to edit itself.

How it was found

  1. Create a new app token in the user security settings.
  2. Edit the token so filesystem access is not allowed.
  3. Log out.
  4. Log in to the WebDAV endpoint using the username and the app token.
  5. Open the security settings again and obtain the CSRF token.
  6. Send a PUT request to the auth tokens endpoint with the token ID to change its scope.

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.

An app token is a password-like string an app uses to log in on your behalf, and it can be limited so it only does certain things. Here a limited token was still allowed to edit its own limits, so anyone who stole it could remove the limits and reach everything. The report suggests only a full login with password and second factor should be able to change tokens.

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 rtod

View all

33 more disclosed reports, 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.