Skip to content

fix(attachments): on Linux, opened attachments are decrypted into XDG_RUNTIME_DIR, not onto disk - #43

Merged
Henner4746 merged 1 commit into
mainfrom
fix/klartext-nicht-auf-platte
Nov 30, 2026
Merged

Henner4746 merged 1 commit into
mainfrom
fix/klartext-nicht-auf-platte

Conversation

@Henner4746

Copy link
Copy Markdown
Owner

Addresses SEC-M2 from the external security assessment of 16–23 Nov 2026: "opened files remain as plaintext copies on Linux until next app start".

Confirmed

Opening a received attachment with another app decrypts it into <app support>/anhaenge/.klar/ (~/.local/share/com.bitdm.bitdm/...). Copies are removed on lock, dispose and the next start. Linux has no hook for closing the window (my_application.cc has no delete-event handler, AppState.dispose is never called), so after simply closing BitDM the plaintext stayed on disk until it was started again.

Fix

  • On Linux the copies go to $XDG_RUNTIME_DIR/bitdm-klar-<hash of the database path>. That is a tmpfs owned by the user (0700) and disappears at logout and reboot, so the plaintext never reaches the disk.
  • If the variable is missing, or the folder cannot be created there (a foreign or broken XDG_RUNTIME_DIR), it falls back to the old place, so opening never fails because of it.
  • Android and Windows are unchanged (Android needs files/anhaenge/ for the FileProvider).
  • Cleanup also empties the old anhaenge/.klar, for copies left by an older version, and wipe now removes the runtime folder too.

Tests

  • test/core/klartext_ordner_test.dart: with XDG_RUNTIME_DIR the folder is outside the profile; one folder per database, stable across starts; without a usable variable or outside Linux, the old place.
  • test/net/anhang_end_to_end_test.dart now checks that on Linux with XDG_RUNTIME_DIR the copy lies there.

Run in CT 107: flutter analyze shows only the 29 existing hints. With XDG_RUNTIME_DIR set: both files green, and no file left in the runtime folder afterwards. Without it: anhang_end_to_end_test, test/anhang, test/core 358 green. With an unusable XDG_RUNTIME_DIR (/proc/1) the app falls back as intended; the E2E check then fails, because it expects the runtime folder, which is a test-environment limitation.

Not changed

  • No window-close hook on Linux (would need a GTK delete-event handler).
  • Copies still live as long as the app session (lock, next start or logout removes them).

🤖 Generated with Claude Code

…_RUNTIME_DIR, not onto disk

A received attachment opened with another app was decrypted into the
profile folder (~/.local/share/.../anhaenge/.klar). Linux has no hook for
closing the window, so the plaintext copy stayed on disk until the next app
start (security assessment 2026-11-23, SEC-M2).

On Linux the copies now go to $XDG_RUNTIME_DIR/bitdm-klar-<hash of the
database path>: a tmpfs owned by the user (0700) that disappears at logout
and reboot. Without that variable, and on Android and Windows, the old place
stays (Android needs it for the FileProvider). Lock and wipe clean the new
folder as before, and wipe now also removes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@Henner4746
Henner4746 merged commit 21bb143 into main Nov 30, 2026
11 of 12 checks passed
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.

1 participant