Repository navigation
fix(encryption): a database left in the clear by a killed session asks for the password and is encrypted again - #103
Merged
Conversation
…s for the password and is encrypted again Unlocking decrypts the database to the file SQLite works on and deletes the encrypted one; closing encrypts it again. A session that stopped in between - a crash, a forced stop, a power cut - left only the clear file. The next start found no encrypted file and opened it as if encryption were off: without the password, and with no password to encrypt it with when closing, so it stayed in the clear for good. A database encryption is on for, found in the clear, now waits for the password like an encrypted one (LogStore.leftClear). Unlocking checks the password as usual - against the keyring, or, for an installation older than the keyring, against the other files it encrypts, since no encrypted database is there to fail on and a mistyped password would encrypt everything under it - then opens the database as it is, with nothing lost, and closing encrypts it again. The recovery key opens it too. The unlock screen says what happened (IsDatabaseLeftClear, on Backend; the window's own store when driving a sealing service), in the 8 languages, and so does the user guide. The test reproduces it: an encrypted database unlocked, its files copied while the session runs, the copy started: locked, a wrong password refused, the right one opens every message, closing leaves only the encrypted file, which opens at the next start as any does.
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Unlocking decrypts the database into the file SQLite works on, and deletes the encrypted file. Closing encrypts it again.
A session that stops in between (a crash, a forced stop, a power cut) leaves only the clear file. At the next start:
Encryption is still shown as on all that time. It happened on a real installation today: a dev session was killed while its database was unlocked.
The fix
LogStore.leftClear).readableWith).IsDatabaseLeftClear, onBackend, and on the window's own store when it drives a sealing service. The message is in the 8 locales, and the user guide's Encryption section explains it.Tests
internal/engine/leftclear_test.goreproduces it:Another test checks that a database never encrypted still opens without a password. The cross-version fixtures (v1.6.1, v1.7.1, vault v1) still pass.
Checked:
go vet(Windows, Linux),staticcheck,go test -race ./...,svelte-check --fail-on-warnings,npm test,npm run build.