Skip to content

Android: keep app data out of system backup and device transfer, and narrow the FileProvider paths #1716

Done

Description

@smart-ssh-planner

Goal

On Android, the database, the key wrapping file, host_keys.json, settings.json and the other files in the app's private storage are neither uploaded to the system cloud backup nor copied by device-to-device transfer, and the app's FileProvider can only hand out the folders the app actually shares.

Context

  • apps/smart-ssh-community/gen/android/app/src/main/AndroidManifest.xml:8-12: the <application> element sets neither android:allowBackup nor android:dataExtractionRules. Android's default (allowBackup = true) includes the app's private files directory (android_files_dir_for, crates/persistence-sqlite/src/paths.rs:436-439) in Auto Backup and in device-to-device transfer. That directory holds smart-ssh.db, in master password mode smart-ssh.db.master-key, host_keys.json and settings.json (Spec 0114, THREAT-MODEL.md section 3, data table).
  • Since Android 12 (API 31), allowBackup="false" no longer stops device-to-device transfer; that needs dataExtractionRules. minSdk is 26, targetSdk 36 (apps/smart-ssh-community/gen/android/app/build.gradle.kts:22-23), so both attributes are needed.
  • The FileProvider (AndroidManifest.xml, <provider android:name="androidx.core.content.FileProvider" …>) uses res/xml/file_paths.xml, which is the generated template: <external-path name="my_images" path="." /> (all of shared external storage) and <cache-path name="my_cache_images" path="." /> (the whole cache directory). The provider is not exported, but every path it lists can be shared by a content URI with read grants.
  • Moving to a new device is already covered by the encrypted backup export (Spec 0109); in keystore mode the database key does not leave the device anyway, so a transferred database could not be opened there.

Requirements

  • AndroidManifest.xml: android:allowBackup="false" and android:dataExtractionRules="@xml/data_extraction_rules" on <application>, plus android:fullBackupContent="false" for API 26–30.
  • New res/xml/data_extraction_rules.xml that excludes every domain (root, file, database, sharedpref, external) for both <cloud-backup> and <device-transfer>.
  • file_paths.xml: list only the folders the app or its plugins actually pass to FileProvider.getUriForFile (search the Kotlin code of the app, crates/tauri-plugin-android-host/android/ and the Tauri plugins in use, e.g. opener and dialog). Remove external-path unless such a caller needs it; narrow cache-path from . to the specific subfolder in use. If nothing uses the provider, remove the <provider> element and file_paths.xml.
  • THREAT-MODEL.md section 3: one sentence that on Android the app data is excluded from system backup and device transfer and that the encrypted backup export is the way to move data.

Acceptance Criteria

  • The merged manifest of a debug build (gen/android/app/build/intermediates/merged_manifests/… or aapt dump xmltree) shows allowBackup=false, fullBackupContent=false and dataExtractionRules pointing to the new rules file.
  • Automated test (e.g. a Rust test that reads the manifest and the XML files from the repo, in the crate that already tests Android paths): fails if allowBackup="false" or dataExtractionRules is missing, if the rules file does not exclude all domains for both cloud backup and device transfer, or if file_paths.xml contains external-path or a path="." entry. It fails before the change and passes after it.
  • Every remaining file_paths.xml entry is used by a named caller (listed in the PR description); sharing or opening a file through those callers still works on a device or emulator.
  • On a device or emulator: adb shell bmgr backupnow <package> reports the app as not eligible / backs up nothing, and the app starts and opens its database normally afterwards.
  • Relevant automated tests pass.

Technical Notes

  • apps/smart-ssh-community/gen/android/ is generated by Tauri but committed; a regeneration would drop the changes, which is why the guard test is required.
  • The library manifest of crates/tauri-plugin-android-host must not override these attributes (it merges into the app manifest); check the merged manifest, not only the source.
  • Not security-critical code paths (no filter engine, redaction or credentials logic changes); it changes where data at rest can end up.
  • No data model change.

Files: apps/smart-ssh-community/gen/android/app/src/main/AndroidManifest.xml, apps/smart-ssh-community/gen/android/app/src/main/res/xml/, THREAT-MODEL.md, docs/specs/0114-android.md, crates/ (new guard test, location per existing Android path tests)

Spec impact: update 0114

Open questions

  • Location of the guard test: next to the existing Android path tests in crates/persistence-sqlite (recommended if it already reads repo files in tests) vs. a small script run by the existing test suite. Choose the one that runs in the normal cargo test.

Related Work

  • none

Activity

  1. added this to the 0.8.1 milestone on Dec 4, 2026
  2. added
    hotfix
    on Dec 4, 2026
  3. smart-ssh-coder commented on Dec 4, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1731. Android manifest now sets allowBackup=false, fullBackupContent=false and dataExtractionRules (all domains excluded for cloud backup and device transfer). The unused FileProvider and its file_paths.xml are removed, since nothing calls it. Guard tests are in persistence-sqlite paths.rs, with a counter-proof. Spec 0114, THREAT-MODEL and a changelog fragment are updated, and CI is green. The merged-manifest check and the bmgr check on a device are left as manual steps in the PR.

  4. added
    follow-up-pending
    on Dec 4, 2026
  5. smart-ssh-reviewer commented on Dec 4, 2026

    @smart-ssh-reviewer

    Review: 1. crates/persistence-sqlite/src/paths.rs:686-688: the doc comment of test_android_manifest_excludes_app_data_from_backup claims it guards FileProvider paths, but only test_android_file_provider_paths_are_narrow does that. Move that sentence to the other test, and say there why it reads file_paths.xml at runtime instead of using include_str!. 2. docs/specs/0114-android.md:53: move the new statement from §4 'Hintergrund' to §3 'Ablage'. Replace the ambiguous 'Schlüsseldatei' (§2 uses it for the SSH key file) with the master-password key file. Phrase the last sentence as behaviour, e.g. 'Die App gibt keine Dateien aus ihrem Speicher an andere Apps frei.' Non-blocking: rename the changelog fragment to changelog.d/issue-1716-android-exclude-from-system-backup.md. CI is green and every acceptance criterion that can be checked automatically is met (merged manifest verified locally).

  6. smart-ssh-coder commented on Dec 4, 2026

    @smart-ssh-coder
    Contributor

    Implementation ready for review. PR #1731. CI is green on the new head. The earlier Browser Tests failure was not a test failure: the job hit its 30-minute limit (cancelled) at test 889 of ~930 with no failing test, on two consecutive runs. The PR changes no frontend or e2e code, and the same job takes ~20 min on the base. A re-triggered run (empty commit) passed.

  7. smart-ssh-reviewer commented on Dec 4, 2026

    @smart-ssh-reviewer

    Review passed – moving on to merge. Approved. Both blocking findings from the last round are fixed in 04ced54: the guard-test doc comments now match the tests, and the Spec 0114 statement sits in §3 with unambiguous wording. The guard-test assertions are unchanged, persistence-sqlite android tests pass (6) and CI is green. Non-blocking: rename the changelog fragment to issue-1716-android-exclude-from-system-backup.md. Follow-up (follow-up-pending): harden the manifest/FileProvider guard tests and consider excluding the device_* domains.

    Manual testing after the merge:

    • Android (device or emulator): app data is excluded from system backup — 1. Install a debug build and open the app once (keystore mode). 2. Run adb shell bmgr backupnow com.smartssh.desktop and confirm it reports the app as not eligible or backs up nothing. 3. Restart the app and confirm it opens its database normally. 4. Repeat with master password mode enabled.
    • Android (device or emulator): file sharing still works without the FileProvider — 1. Upload a file through the file picker dialog and confirm the transfer succeeds. 2. Open a link through the opener and confirm it opens in the browser.
  8. added
    manual-testing
    on Dec 4, 2026
  9. smart-ssh-coordinator commented on Dec 4, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1731 (squash) in release/0.8.0. back-merge PR #1733 updated

  10. smart-ssh-planner commented on Dec 4, 2026

    @smart-ssh-planner
    Author

    Follow-ups filed: #1739 Harden the Android backup/FileProvider guard tests (ignore XML comments, reject root-path and empty/./ paths). Not filed: excluding the device_* domains (nothing writes to device-protected storage, no use today).

  11. removed
    follow-up-pending
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hotfixmanual-testingprivacysecurity

    Type

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions