From f537f098535228a5c800092feff68dd58ff0d363 Mon Sep 17 00:00:00 2001 From: Wasabules <39313803+Wasabules@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:50:58 +0100 Subject: [PATCH] fix(encryption): a database left in the clear by a killed session asks 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. --- app_sealed.go | 1 + docs/USER_GUIDE.md | 5 + frontend/src/components/UnlockScreen.svelte | 14 +- frontend/src/lib/api.ts | 1 + frontend/src/lib/i18n/de.json | 1 + frontend/src/lib/i18n/en.json | 1 + frontend/src/lib/i18n/es.json | 1 + frontend/src/lib/i18n/fr.json | 1 + frontend/src/lib/i18n/it.json | 1 + frontend/src/lib/i18n/ja.json | 1 + frontend/src/lib/i18n/pt.json | 1 + frontend/src/lib/i18n/zh.json | 1 + frontend/wailsjs/go/main/App.d.ts | 2 + frontend/wailsjs/go/main/App.js | 4 + internal/engine/encryption.go | 15 +++ internal/engine/leftclear_test.go | 136 ++++++++++++++++++++ internal/remote/backend.go | 1 + internal/remote/client_gen.go | 6 + internal/remote/switch_gen.go | 4 + internal/storage/logstore.go | 39 +++++- 20 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 internal/engine/leftclear_test.go diff --git a/app_sealed.go b/app_sealed.go index 730b2cf..42aa794 100644 --- a/app_sealed.go +++ b/app_sealed.go @@ -64,6 +64,7 @@ func (b sealedBackend) GetUnlockAttemptsRemaining() int { return b.store.GetUnlo func (b sealedBackend) GetUnlockLockoutSeconds() int { return b.store.GetUnlockLockoutSeconds() } func (b sealedBackend) IsEncryptionEnabled() bool { return b.store.IsEncryptionEnabled() } func (b sealedBackend) IsEncryptionLocked() bool { return b.store.IsEncryptionLocked() } +func (b sealedBackend) IsDatabaseLeftClear() bool { return b.store.IsDatabaseLeftClear() } func (b sealedBackend) UnlockDatabase(password string) error { return b.store.UnlockDatabase(password) } diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md index 1991b5f..1917199 100644 --- a/docs/USER_GUIDE.md +++ b/docs/USER_GUIDE.md @@ -490,6 +490,11 @@ destinations' credentials and the sealed inbox key. The password itself is never change of password, or the creation of a recovery key, replaces its key, which encrypts everything again once. - Once this version has written a database, versions before 1.8 can no longer open it. +- While SyslogStudio runs, the database it works on is decrypted; it is encrypted again when + SyslogStudio closes. If SyslogStudio stops without closing — a crash, a forced stop, a power cut — + the database is found unencrypted at the next start. SyslogStudio then says so on the unlock + screen and asks for the password as usual: the database opens as it was, and is encrypted again + when SyslogStudio closes. (Before 1.11, it was opened without the password and stayed unencrypted.) ### The recovery key diff --git a/frontend/src/components/UnlockScreen.svelte b/frontend/src/components/UnlockScreen.svelte index 54c9728..96c45b0 100644 --- a/frontend/src/components/UnlockScreen.svelte +++ b/frontend/src/components/UnlockScreen.svelte @@ -1,7 +1,7 @@