Skip to content

fix(e2ee): keep a saved lock token until unlock succeeds - #11440

Open
xO-ox-ai wants to merge 2 commits into
nextcloud:masterfrom
xO-ox-ai:fix/e2ee-confirm-unlock-before-clear
Open

xO-ox-ai wants to merge 2 commits into
nextcloud:masterfrom
xO-ox-ai:fix/e2ee-confirm-unlock-before-clear

Conversation

@xO-ox-ai

Copy link
Copy Markdown

An unsuccessful unlock could clear the saved token. Keep it until the server confirms the unlock and the journal deletion succeeds. Start a replacement lock only after recovery succeeds. The new tests cover error responses and local journal failure.

Fixes #11436. Split from #11438.

Build and focused regression suite E2eeLockRecoveryTest passed in the Qt 6 CI image.

AI assistance: Codex assisted with the implementation and tests.

Refs: nextcloud#11436.

Assisted-by: Codex:GPT-6
Signed-off-by: O.O <caeser222000@163.com>
@camilasan

Copy link
Copy Markdown
Member

@xO-ox-ai e2ee is not my expertise, so you can judge if the points made make sense:

Must fix

  • A 404 from the unlock endpoint means the lock is already gone (for example, it expired on the server). With this change the token is kept, so every later LockEncryptFolderApiJob tries to unlock first, fails, and the folder can never be locked again by this client. Please treat 404 as "lock gone": delete the token row and continue with the lock. The http404 test currently asserts the opposite.
  • syncengine.cpp:518 has the same base64 bug this PR fixes: it passes *folderToken without QByteArray::fromBase64(). Before this PR the row was deleted on any response, which hid the bug. Now the row stays and the startup unlock fails on every sync.
  • A saved token that can no longer be decrypted (after a key reset or a new certificate) now blocks the folder permanently. Please drop the row or provide some other recovery.

Optional

  • Use one helper that loads, decrypts and decodes the saved token for both call sites.
  • retCode == 200 ? 0 : retCode and the extra reply()->error() check on 200 add noise without changing behaviour in practice.
  • Pre-existing issue, better as a separate PR: on decrypt failure, the return in syncengine.cpp:515 skips the rest of startSync().

Assisted-by: Claude:claude-opus-5-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop sync can lose the recovery token for an encrypted folder lock

2 participants