Skip to content

fix(encryption): keep the encrypted version the copy was written with - #64378

Open
susnux wants to merge 1 commit into
masterfrom
fix/encryption-copy-encrypted-version
Open

susnux wants to merge 1 commit into
masterfrom
fix/encryption-copy-encrypted-version

Conversation

@susnux

@susnux susnux commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

A copy re-encrypts the target, so the signature of its blocks is keyed on the version of the target - the version of the file it overwrites plus one - and not on the version of the source. Two writers overwrite that value after the stream recorded it: updateEncryptedVersion() resets it to 1 for every copy, and Cache::copyFromCache() then puts the source's version on the target. Reading the copy back fails with "Bad Signature" whenever those differ, which is the case for every copy of a file that was written more than once and for every copy onto an existing file.

Take the version the stream recorded for the target instead of resetting it, and let it win over the source's version when the cache entry of the copy is written.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@susnux
susnux added this pull request to stack #64379 September 15, 2026 17:25
@susnux susnux added this to the Nextcloud 36 milestone Sep 15, 2026
@susnux

susnux commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable35

@susnux

susnux commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable34

@susnux

susnux commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/backport to stable33

@susnux
susnux marked this pull request as ready for review September 15, 2026 17:36
@susnux
susnux requested a review from a team as a code owner September 15, 2026 17:36
@susnux
susnux requested review from a team, Altahrim, CarlSchwan, GhassenKefi, come-nc and salmart-dev and removed request for a team September 15, 2026 17:36
Base automatically changed from fix/encryption-signature-desync to master September 17, 2026 12:44
A copy re-encrypts the target, so the signature of its blocks is keyed on
the version of the target - the version of the file it overwrites plus one -
and not on the version of the source. Two writers overwrite that value after
the stream recorded it: updateEncryptedVersion() resets it to 1 for every
copy, and Cache::copyFromCache() then puts the source's version on the
target. Reading the copy back fails with "Bad Signature" whenever those
differ, which is the case for every copy of a file that was written more
than once and for every copy onto an existing file.

Take the version the stream recorded for the target instead of resetting it,
and let it win over the source's version when the cache entry of the copy is
written.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux
susnux force-pushed the fix/encryption-copy-encrypted-version branch from cfdf323 to 9c6c55b Compare September 17, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants