nextcloud / nextcloud/richdocuments

Opening documents with per-user key encryption fails (Private Key missing for user)

Open
#2,484 16 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug integration: encryption (server-side)
Dominant language
JavaScript
Stars
453
Forks
147
Avg merge
14h 54m
Merged PRs (30d)
83

Description

Describe the bug
When per-user keys are enabled on the server, opening a new document fails with the error Private Key missing for user: please try to log-out and log-in again. If the new file is then manually shared, edit capabilities are enabled, and then accessed only from the shared link, the document then opens normally.

Based on existing bug reports and pull requests (https://github.com/nextcloud/richdocuments/pull/52, https://github.com/nextcloud/richdocuments/issues/1379, https://github.com/nextcloud/richdocuments/pull/1396), it's my understanding that this should be working. https://github.com/nextcloud/richdocuments/issues/1379 specifically explains that a new document should be shared and then fetched automatically upon creation. It also appears that this was working as of last year.

(Line numbers updated from original issue to match current code)

I believe I have everything configured correctly because I can open, edit, and save documents as long as I first manually share a new document, enable editing, and then access it only from the shared url. Even after sharing, attempting to open the file directly from my files list results in the same private key missing error in the logs. It only seems to work by copying and pasting the share url.

To Reproduce
Steps to reproduce the behavior:

  1. Enable per-user key encryption
  2. Create a new document using Collabora
  3. Open fails, see private key error in Nextcloud logs
  4. Manually share the file, enable edit, and access it from the shared link: Everything works fine.

Expected behavior
The new document should be auto shared with editing capabilities, and opened using those sharing credentials.

Client details:

  • OS: Arch Linux
  • Browser: Firefox
  • Version: Oct 3, 2022
  • Device: Desktop

Server details

Operating system: Ubuntu Server

Web server: Apache

Database: mysql

PHP version: 8.0.23

Nextcloud version: 24.0.4 via Snap

Version of the richdocuments app 6.2.0

Version of Collabora Online 22.05.6.3 via dockerhub image

Logs
Nextcloud log (data/nextcloud.log)
[richdocuments] Error: OCA\Encryption\Exceptions\PrivateKeyMissingException: Private Key missing for user: please try to log-out and log-in again at <<closure>>

 0. /snap/nextcloud/31571/htdocs/apps/encryption/lib/KeyManager.php line 475
    OCA\Encryption\Session->getPrivateKey()
 1. /snap/nextcloud/31571/htdocs/apps/encryption/lib/Crypto/Encryption.php line 203
    OCA\Encryption\KeyManager->getFileKey()
 2. /snap/nextcloud/31571/htdocs/lib/private/Files/Stream/Encryption.php line 286
    OCA\Encryption\Crypto\Encryption->begin()
 3. <<closure>>
    OC\Files\Stream\Encryption->stream_open()
 4. /snap/nextcloud/31571/htdocs/lib/private/Files/Stream/Encryption.php line 213
    fopen()
 5. /snap/nextcloud/31571/htdocs/lib/private/Files/Stream/Encryption.php line 188
    OC\Files\Stream\Encryption::wrapSource()
 6. /snap/nextcloud/31571/htdocs/lib/private/Files/Storage/Wrapper/Encryption.php line 470
    OC\Files\Stream\Encryption::wrap()
 7. /snap/nextcloud/31571/htdocs/lib/private/Files/Storage/Wrapper/Wrapper.php line 301
    OC\Files\Storage\Wrapper\Encryption->fopen()
 8. /snap/nextcloud/31571/htdocs/lib/private/Files/View.php line 1175
    OC\Files\Storage\Wrapper\Wrapper->fopen()
 9. /snap/nextcloud/31571/htdocs/lib/private/Files/View.php line 1010
    OC\Files\View->basicOperation()
10. /snap/nextcloud/31571/htdocs/lib/private/Files/Node/File.php line 114
    OC\Files\View->fopen()
11. /var/snap/nextcloud/31571/nextcloud/extra-apps/richdocuments/lib/Controller/WopiController.php line 425
    OC\Files\Node\File->fopen()
12. /snap/nextcloud/31571/htdocs/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\Richdocuments\Controller\WopiController->getFile()
13. /snap/nextcloud/31571/htdocs/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController()
14. /snap/nextcloud/31571/htdocs/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch()
15. /snap/nextcloud/31571/htdocs/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main()
16. /snap/nextcloud/31571/htdocs/lib/base.php line 1023
    OC\Route\Router->match()
17. /snap/nextcloud/31571/htdocs/index.php line 36
    OC::handleRequest()

GET /index.php/apps/richdocuments/wopi/files/231296_ociqqws2nu00/contents?access_token=IibwYTDxqPhfnN8t4VisjmXt3XnlQoaU&access_token_ttl=0&permission=edit
from 172.20.0.5 at 2022-10-03T13:25:17+00:00

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/Controller/DocumentController.php around the automatic public share and lib/Controller/WopiController.php around getFile and line 425. Reproduce with per-user key encryption enabled, then trace whether the share credentials and access token are used when opening from the files list. Done means a newly created document opens directly with editing enabled, without the private-key error, while the shared-link path continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
api, backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.