fix(files): Prevent corruption of files when moving from encrypted to unencrypted folders within the same object storage - #62364
Conversation
|
/backport to stable34 |
|
/backport to stable33 |
|
/backport to stable32 |
… unencrypted folders within the same object storage Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
54078e2 to
672542f
Compare
|
/backport! to stable32 |
come-nc
left a comment
There was a problem hiding this comment.
The explanation makes sense but I’m unsure about the performance cost here.
I’m also unsure I understand the change in Common.php
ping @icewind1991 could you review this?
|
@come-nc : The performance cost isn't small, as it needs to pull the file from storage, encrypt it and push it unencrypted. But I don't see any other way to handle that case honestly... It also happens on other storage backends already, so...
That change is necessary as there would be duplicate files otherwise (the original one and the copied/moved one), as it tries to use the same |
This comment was marked as outdated.
This comment was marked as outdated.
|
/backport to stable32 |
Summary
When using server-side encryption (SSE), not all folders are encrypted by default. For example, when using
groupfolders, the encryption must be enabled separately. This is described in the admin manual, but might not always being recognized by the administrators. This can then lead to situations where the personal folders are encrypted, but group folders might not.This will lead to a bug when both folders are inside the same object storage (since #47986). In this case, the current code will try to speed up things by only copying the metadata in the filecache. This breaks the encryption, as the encryption key depends on the path of the file and isn't being moved in this case, nor any re-encryption happens for the new path. Before #62255, the user might be even served the raw file with the ciphertext in some cases.
To fix the issue, I'll let the global functions handle those cases rather then try to duplicate any logic into the object storage overwrite.
Checklist
3. to review, feature component)stable32)AI (if applicable)