DuoKey
Resources
Article

Encrypted Co-Editing with Collabora Online: How a WOPI Gateway Works with Keys in an HSM

How several people co-edit an encrypted document in Collabora Online while Nextcloud stores only ciphertext: WOPI gateway, tokens, proof keys, locks and key release.

DuoKey Team··7 min read

In Nextcloud, collaborative editing in the browser and end-to-end encryption have so far been mutually exclusive: an editor such as Collabora Online needs the document in plaintext, and an end-to-end encrypted folder does not give it to the editor. This article shows a third way, implemented by DuoKey SecureFolder: a WOPI gateway that decrypts the document only in memory, while Nextcloud stores nothing but ciphertext and the master key stays in the organization's HSM.

It is written for architects, administrators and security officers in the Nextcloud and openDesk community who want to understand what happens technically and where the limits are.


Table of Contents

  1. WOPI in Two Minutes
  2. The Gateway as WOPI Host
  3. The Path of a Document, Step by Step
  4. Several Editors, One Session
  5. Security Decisions in Detail
  6. Two Independent Checks
  7. Limits and Residual Risks
  8. Compatibility
  9. Sources

WOPI in Two Minutes

WOPI (Web Application Open Platform Interface) is the protocol an online editor uses to fetch a file from storage and write it back. It has two roles:

  • The WOPI client is the editor: Collabora Online or OnlyOffice Docs.
  • The WOPI host serves the file: normally Nextcloud itself, with the Nextcloud Office app.

The editor essentially calls four operations on the host: CheckFileInfo (metadata and permissions), GetFile (read content), PutFile (write content) and the lock operations LOCK, UNLOCK, REFRESH_LOCK, GET_LOCK. The editor publishes the addresses it offers and the keys it signs its calls with in its discovery document.

The key point: whoever is the WOPI host sees the document in plaintext. In a standard installation, that is Nextcloud.


The Gateway as WOPI Host

The DuoKey gateway takes over the WOPI host role. Nextcloud remains the storage and permission manager, but sees only ciphertext.

DuoKey SecureFolder architecture: Nextcloud or openDesk as storage with encrypted DKSF files, editing zone with the DuoKey gateway and Collabora Online, DuoKey Cockpit with key release, customer HSM

Figure 1. Components and trust zones. On the server side, plaintext exists only in the editing zone, in memory.

The gateway is written in Rust and built from independent components: a storage connector (WebDAV for Nextcloud and openDesk), a key resolver (DuoKey Cockpit), a codec for the DKSF file format, sessions, sealed WOPI tokens, discovery and proof verification, locks and an access log. The same components serve any storage and any editor.


The Path of a Document, Step by Step

Sequence for opening, co-editing and saving a document from a protected folder, between the user, Nextcloud, the gateway, Collabora, Cockpit and the HSM

Figure 2. Opening, co-editing and saving a document from a protected folder.

  1. In Nextcloud, the user selects "Open with DuoKey".
  2. The user is redirected to the gateway and signs in with OpenID Connect, for example through openDesk's Keycloak.
  3. The gateway reads the encrypted file over WebDAV with the user's token, that is, with the user's own Nextcloud permissions.
  4. It asks Cockpit for the folder key for this user.
  5. Cockpit checks the right to the folder and whether the gateway is active.
  6. The folder key is decrypted in the HSM by the KEK.
  7. Cockpit seals it for the gateway, hybrid with P-256 and ML-KEM-768, and logs the release.
  8. The gateway decrypts the DKSF file in memory.
  9. The editor is opened with a sealed WOPI token.
  10. Collabora calls CheckFileInfo and GetFile, with signed calls.
  11. Every save is followed by PutFile.
  12. The gateway re-encrypts and writes back with If-Match.
  13. The events are sent in batches to the Cockpit access log.

Several Editors, One Session

Each person who opens a document gets their own WOPI token, bound to one file and one session, sealed and time-limited. Their permissions are checked individually. The file identifier in the WOPISrc is a keyed hash (HMAC) of the storage path: stable, so that all editors of the same file land in the same Collabora session, and not reversible, so that it does not reveal the path.

Anyone who has only a read right on the key or only a read share in Nextcloud opens the editor in read-only mode; their saves and locks are rejected.


Security Decisions in Detail

TopicDecision
WOPI token in the URLThe protocol requires it. The token is sealed with AES-256-GCM, reveals neither the user nor the path, is bound to one file and one session, and expires (after 4 hours by default). It never contains the storage credentials; those stay in the server-side session.
Editor signaturesProof signatures (X-WOPI-Proof, X-WOPI-ProofOld) are mandatory by default, with key rotation. A stolen token alone is not enough to call the WOPI routes.
No silent overwritesSaves use If-Match with the last ETag read. If a desktop sync has changed the file in the meantime, the gateway responds with 409 instead of overwriting.
LocksWOPI locks per file, with a 30-minute expiry.
PlaintextExists only in memory, for the duration of a request, and is zeroed when released.
Outbound connectionsNo redirects, size limits, destination addresses set by the administrator.
Leak controlsExport, printing, copying and downloading blocked in the editor; named watermark.
Access logOpens, saves, encrypted uploads and denials are reported to Cockpit, never the file content. Logging never blocks a WOPI call.

Two Independent Checks

Two independent checks before opening: the share in Nextcloud and the right to the folder key in DuoKey Cockpit

Figure 3. Two independent checks before a document is opened.

The storage applies its own permissions, because the gateway calls it with the user's token and does not use a service account that could read every file. In addition, Cockpit must release the key to exactly this user. If either check fails, the document stays closed. Revoking the right in Cockpit takes effect immediately for new releases; the gateway discards keys held in memory within a few minutes at most.


Limits and Residual Risks

An honest picture includes the following:

  • The editing zone sees plaintext. The gateway and Collabora decrypt in memory. If this zone is compromised, the documents opened during the compromise are affected, not the others. In on-premises or hybrid deployments, the organization runs the zone itself; in SaaS (planned), it runs per customer in an AMD SEV-SNP enclave, and Cockpit releases keys only to an attested gateway.
  • Metadata remains visible. Nextcloud sees the names, sizes, dates and shares of files. File name encryption is planned; protected folders have no previews and no search index.
  • Authorized users. Screenshots and photos of the screen cannot be prevented technically; watermarks and logging act as a deterrent.
  • Trust in the gateway. Today, the gateway names the user to Cockpit, restricted to its own namespace. The plan is for Cockpit to verify the user's OIDC token itself.

Compatibility

ComponentStatus
Collabora Online 26.04, Nextcloud 33Implemented and validated
Nextcloud app "Open with DuoKey"Implemented, Nextcloud 31 to 33
openDesk Community Edition v1.20.0Validated, without any change to openDesk
OnlyOffice DocsPartial: compatible protocol, full validation pending
Save as (PutRelativeFile) and renameNot yet supported

Collabora Online and OnlyOffice Docs publish the same discovery format and the same proof signatures, which is why the same gateway can serve both. For many formats, Collabora publishes only an edit action; a user with read rights then gets that address, and the editor opens in read-only mode because CheckFileInfo returns UserCanWrite: false.

The file format is the same as for the SecureFolder agent for Windows and macOS: a file encrypted on the desktop opens in the browser, and vice versa.


Sources

  1. Microsoft, WOPI protocol (Open Specifications): CheckFileInfo, GetFile, PutFile, locks and proof keys. learn.microsoft.com
  2. Collabora Online, integration documentation (WOPI). sdk.collaboraonline.com
  3. Nextcloud, Hub 10 and end-to-end encryption in the browser. help.nextcloud.com
  4. IETF, RFC 9334, Remote ATtestation procedureS (RATS) Architecture. rfc-editor.org
  5. AMD, Secure Encrypted Virtualization (SEV-SNP). amd.com

Share

Written by

DuoKey Team

Discuss the decisions that matter most to your security programme.

Tell us where control is difficult today. We will help you identify a practical next step.