nextcloud / nextcloud/server

Support for rotating rotating master key used for server-side encryption

Open
#2,964 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement feature: encryption (server-side) help wanted
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Hi,

It would be great if the master key used for encryption could be replaced, e.g. in case the key has been compromised. This has actually been discussed with @schiessle some time ago in an old ownCloud issue which is rotting in the backlog, so let's continue this here and hopefully make it come true :D

To refresh memory, here an essential comment by @schiessle copied from the old discussion which helps to kickstart:

[..], the master key is encrypted with the secret stored in config.php. You can't change this secret easily because it is also used in other places. So if we want to be able to replace the master key with a new one and also want a new password we need to introduce a new config.php option to store the master key password. If it is set we use this password, if not we fall back to the "secret" for backward compatibility.

The hard part of replacing the master key is not to generate a new one and set a new password somehow but to re-encrypt all files with the new key! Therefore we would need a occ call similar to "encrypt-/decrypt-all" and some extended logic to place a "read-key" and a "write-key" in the session. By default this would be the same keys. But in case of a "change master key call" we could add the old key as "read-key" and the new key as "write-key" and then read all existing files and writing them to new ones. So this involved quite some work as you can see if you look at the encrypt-all and decrypt-all commands.

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 by reading the existing encrypt-all and decrypt-all occ commands and the server-side encryption handling described in the issue. Trace how the master key is protected by config.php's secret, then determine the required read-key/write-key flow for re-encrypting existing files. Done means a supported master-key rotation can preserve access to existing files while writing new encryption with the replacement key.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.