review(security/sync): below-cut lifecycle & robustness nits #301

Open
opened 2026-07-04 06:48:21 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-04 06:48:21 +00:00 (Migrated from github.com)

Phase-3 review — below-the-cut LOW findings (Backlog):

  • SendWorker.kt:71: runCatching{…}.fold swallows CancellationException (routes it to onFailure); rethrow it (mirror sendOutlook).
  • DatabaseProvisioner.kt:117+AccountDatabaseModule.kt:48: opening the plaintext AccountDatabase awaits the full cache-encryption+app-lock passphrase sequence it doesn't need — latent pre-auth coupling; split so accounts-open awaits only wipe+migrator.
  • DatabaseKeyStore.kt:68: resolvePassphrase(MASTER) ignores appLockEnabled — if seal-state and the app-lock setting diverge, cache opens without auth while EncryptedCacheGuard disagrees; add a defense-in-depth assertion/log.
  • MailRepositoryImpl.copyAttachments (:456): swallows copy failures → message can send missing an attachment silently; fail/flag the enqueue instead.
  • MailSyncer.kt:115: empty fetchRecent deletes the whole folder cache (incl. backfilled history); require corroboration (server EXISTS==0) before whole-folder delete.
  • AesGcmKeystoreCipher.kt:86: truncated/invalid-Base64 ciphertext throws unwrapped IOoB/IllegalArgument instead of GeneralSecurityException; length/format-guard + wrap.
  • DatabaseEncryption.kt:42/DatabaseFiles.kt:39: stale .migrate temp file not removed by the wipe path; delete it in DatabaseFiles.clear.
  • MailRepositoryImpl.inlineImages/ensureAttachmentFile: large inline images/attachments fully materialized in memory (OOM risk); stream/cap.
Phase-3 review — below-the-cut LOW findings (Backlog): - `SendWorker.kt:71`: `runCatching{…}.fold` swallows `CancellationException` (routes it to onFailure); rethrow it (mirror `sendOutlook`). - `DatabaseProvisioner.kt:117`+`AccountDatabaseModule.kt:48`: opening the plaintext AccountDatabase awaits the full cache-encryption+app-lock passphrase sequence it doesn't need — latent pre-auth coupling; split so accounts-open awaits only wipe+migrator. - `DatabaseKeyStore.kt:68`: `resolvePassphrase(MASTER)` ignores `appLockEnabled` — if seal-state and the app-lock setting diverge, cache opens without auth while `EncryptedCacheGuard` disagrees; add a defense-in-depth assertion/log. - `MailRepositoryImpl.copyAttachments` (:456): swallows copy failures → message can send missing an attachment silently; fail/flag the enqueue instead. - `MailSyncer.kt:115`: empty `fetchRecent` deletes the whole folder cache (incl. backfilled history); require corroboration (server EXISTS==0) before whole-folder delete. - `AesGcmKeystoreCipher.kt:86`: truncated/invalid-Base64 ciphertext throws unwrapped IOoB/IllegalArgument instead of `GeneralSecurityException`; length/format-guard + wrap. - `DatabaseEncryption.kt:42`/`DatabaseFiles.kt:39`: stale `.migrate` temp file not removed by the wipe path; delete it in `DatabaseFiles.clear`. - `MailRepositoryImpl.inlineImages`/`ensureAttachmentFile`: large inline images/attachments fully materialized in memory (OOM risk); stream/cap.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#301