Skip to content
Access control Disclosed report Intermediate CVE-2023-28645

Secure view trivial to bypass

Nextcloud's 'secure view' feature, which is meant to prevent downloading files, can be bypassed when the richdocuments (Collabora) app is installed. A user can read the WebSocket request in their browser, extract the WOPI access token, and use it to fetch the file contents directly without watermarks.

rullzer Follow

Originally disclosed on HackerOne

Bounty$150 Medium 5.7 View original
  • Triaged in under an hour
  • Fixed in 4 months
  • Paid in 5 months
  • Disclosed after 6 months

Summary by the program

Advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-95j6-p5cj-5hh5

The report

While messing with https://hackerone.com/reports/1724016 I also noticed that it is even easier to bypass secure view. Especially in NC 25 where you explicitly name the checkbox download a user will assume that downloading is thus not allowed or possible.

However if richdocuments is installed and properly configured. A user can still easily fetch those files.

All they have to do is open their browser and see the request that is like

ws://127.0.0.1:9980/cool/http%3A%2F%2F127.0.0.1%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F149_oc13vsnxh17n%3Faccess_token%3Dr7v1y7DI6gcgvzcG85fJE0TCa0IJXvnQ%26access_token_ttl%3D1665034074000/ws?WOPISrc=http%3A%2F%2F127.0.0.1%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F149_oc13vsnxh17n&compat=/ws

Now we extract out the internal part

http%3A%2F%2F127.0.0.1%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F149_oc13vsnxh17n%3Faccess_token%3Dr7v1y7DI6gcgvzcG85fJE0TCa0IJXvnQ%26access_token_ttl%3D1665034074000

We url decode it

http://127.0.0.1/index.php/apps/richdocuments/wopi/files/149_oc13vsnxh17n?access_token=r7v1y7DI6gcgvzcG85fJE0TCa0IJXvnQ&access_token_ttl=1665034074000

Now lets add a /contents to the url

http://127.0.0.1/index.php/apps/richdocuments/wopi/files/149_oc13vsnxh17n/conents?access_token=r7v1y7DI6gcgvzcG85fJE0TCa0IJXvnQ&access_token_ttl=1665034074000

And there you have it. Downloaded without watermarks.

Impact

The checkbox as is misleads users into assuming that the file can't be downloaded. However getting it is easy for anybody that tries.

A solution here would be to agree on some kind of public key cryptography or at the very least a shared secret between collabora and the Nextcloud instance. This could for example be passed via a header when doing calls. ensuring that only collabora can actually retrieve the file info, documents etc.

The original report as published on HackerOne, by rullzer. 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 WOPI access token issued to the document editor is exposed to the client and is not bound to the editor, so it can be reused by the user to call the file contents endpoint directly.

Impact

A user who is only supposed to view a file can download it without watermarks, defeating the secure view restriction.

What the attacker needed

Richdocuments app installed and configured; a user account able to open the file

The fix

The reporter suggests using public key cryptography or at least a shared secret between Collabora and Nextcloud, for example passed in a header, so only Collabora can retrieve file information.

How it was found

  1. Open the document in the browser with the richdocuments app active.
  2. Inspect the WebSocket request to find the encoded WOPI URL containing the access token.
  3. URL-decode the extracted URL.
  4. Append the contents path to the decoded URL.
  5. Request the resulting URL to download the file without watermarks.

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.

Nextcloud has a 'secure view' option that is supposed to stop people downloading a file, for example to stop them saving a confidential document. The report shows that when the online document editor is installed, the browser reveals a secret token in a network request, and anyone can reuse that token to download the file directly. So the protection is only a visual hint, not a real restriction.

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 rullzer

View all

9 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.