Android security implementation Phase 3.2 update Android_Security_Plan.md for more progress tracking
This commit is contained in:
+39
-30
@@ -6,10 +6,19 @@ Related: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md), [SECURITY_REVIEW.md](./SECU
|
||||
|
||||
## Implementation progress (2026-11-03)
|
||||
|
||||
- Implemented: explicit Android cleartext denial and backup/data-extraction exclusions; removed the wildcard Cordova origin and unused broad `FileProvider`; DAV now requires HTTPS, rejects embedded credentials/fragments, stays on the configured origin, and does not follow redirects; saved attachment names are sanitized; notification details are opt-in, stored in the encrypted vault, and redacted on the lock screen; the optional native Android app lock covers the WebView, disables JavaScript bridge access while locked, and uses the device credential without blocking background sync; native logs no longer expose mailbox content; debug APKs are labeled as debug and signed release builds require environment-provided signing credentials.
|
||||
- Tested: DAV URL, attachment-name, and notification privacy policies have Android unit tests. The optional app lock was exercised on an Android emulator with a device PIN, including background lock and unlock. Android OpenPGP key generation/storage and native trust-change/plaintext-send confirmation dialogs were exercised on an emulator; cancellation preserved the untrusted state and prevented the plaintext send, and confirming a trust change persisted it. Phone and landscape layouts were checked for horizontal overflow. The debug Android build and unit tests pass, as does the Node test suite.
|
||||
- Experimental Phase 2 implementation: Android now bundles the pinned OpenPGP.js 6.3.2, stores passphrase-protected keys and public contacts in the existing Keystore-encrypted vault, supports key generation/import/export, contact trust controls, PGP/MIME encrypt/sign, and on-demand PGP/MIME or inline-message decryption. The native plugin prompts before trust elevation, key replacement, and plaintext sending when keys exist or encryption was requested, and validates PGP/MIME structure before its protected send path. Encrypted sends are converted to ciphertext before native sending or offline queueing; decrypted content is held in renderer memory only. Android key-server lookup is disabled, and PGP/MIME messages are capped at 25 MiB on the Android test path. This test path has not had an independent human cryptography review and is not approved for sensitive or production use.
|
||||
- Still open before release: independent cryptography/security review; automated regression tests for native confirmation accept/cancel paths and policy bypass attempts; full signed/inline-message and hostile-input parity tests; Android/GnuPG/Thunderbird interoperability; Keystore lifecycle/recovery and biometric design; invalid-certificate integration tests; device-level review of a production-signed merged APK; app-lock timeout and recovery polish; and resolution/compatibility review of the three moderate `npm audit --omit=dev` advisories in `ip-address` and the `nodemailer`/`mailparser` dependency chain.
|
||||
- **Phase 0 — Baseline:** Mostly implemented; release verification remains open.
|
||||
- **Phase 1 — Local data/privacy:** Notification privacy and the basic native app lock are implemented; vault lifecycle, deletion, and lock-recovery assurance remain open.
|
||||
- **Phase 2 — Android OpenPGP:** Experimental test implementation is present. It is not security-reviewed or release-complete.
|
||||
- **Phase 3 — WebView/bridge:** Important protections are implemented; complete bridge review and device/content testing remain open.
|
||||
- **Phase 4 — Assurance:** Open; independent review, release assurance, and vulnerability/maintenance work remain.
|
||||
|
||||
Tracking legend: `[x]` implemented for the stated item; `[~]` partially implemented, with the remaining work stated beside it; `[ ]` not yet complete. A checked implementation item does **not** mean its phase's exit criteria or release gate have passed.
|
||||
|
||||
OpenPGP.js 6.3.2 is bundled for Android testing. The test implementation stores passphrase-protected keys and public contacts in the existing Keystore-encrypted vault; supports key generation/import/export, contact trust controls, PGP/MIME encrypt/sign, and on-demand PGP/MIME or inline-encrypted-message decryption. Encrypted sends are converted to ciphertext before native sending or offline queueing; decrypted content is held in renderer memory only. Native prompts cover trust elevation, key replacement, and plaintext sending when keys exist or encryption was requested. Key-server lookup is disabled, and PGP/MIME messages are capped at 25 MiB. This work was implemented to enable testing before the independent review gate was satisfied; it is **not approved for sensitive or production use**.
|
||||
|
||||
**Validation evidence:** DAV URL, attachment-name, and notification privacy policies have Android unit tests. The app lock was exercised on an emulator with a device PIN, including background lock and unlock. OpenPGP key generation/storage and native trust/plaintext confirmation dialogs were exercised on an emulator; trust cancellation left trust unchanged, trust confirmation persisted, and plaintext cancellation returned `PLAINTEXT_CANCELLED`. Phone and landscape layouts were checked for horizontal overflow. The latest validation was 152 passing Node tests and a successful Android debug build with 12 Android unit tests. This does not constitute live-provider mail testing or GnuPG/Thunderbird interoperability testing on Android.
|
||||
|
||||
**Release blockers:** independent human cryptography/security review; automated native confirmation and bypass tests; full signed/inline and hostile-input parity; Android/GnuPG/Thunderbird interoperability; Keystore lifecycle/recovery and biometric design; invalid-certificate integration tests; production-signed APK/manifest review; app-lock recovery polish; and compatibility review/remediation of the three moderate `npm audit --omit=dev` advisories in `ip-address` and the `nodemailer`/`mailparser` dependency chain.
|
||||
|
||||
## Goals and limits
|
||||
|
||||
@@ -30,52 +39,52 @@ These are implementation observations, not proof that all paths are safe. In par
|
||||
|
||||
### Phase 0 — Android security baseline and release gate (P0)
|
||||
|
||||
1. Establish a repeatable security checklist for the actual merged manifest and release APK: permissions, exported components, backup/data-extraction rules, cleartext policy, WebView debugging, file access, and Capacitor plugin exposure.
|
||||
2. Audit all native network clients. Require TLS, certificate-chain and hostname validation for IMAP/SMTP STARTTLS and DAV HTTPS; reject downgrade and insecure schemes. Add negative tests using invalid, expired, and mismatched certificates. Do not add certificate pinning by default; it creates rotation and recovery risks.
|
||||
3. Review all `EpMailPlugin` methods as an untrusted-input boundary. Validate IDs, folders, URLs, attachment sizes/types, and state transitions natively; return only data needed by the UI. Ensure external navigation permits only explicitly supported safe schemes and is always user initiated.
|
||||
4. Ensure release builds disable WebView debugging and do not include debug-only configuration. Keep signing keys outside the repository and CI logs. Publish only signed release artifacts, not the current debug APK output.
|
||||
5. Remove or sanitize sensitive diagnostics. Logs must not contain credentials, message bodies, subjects, recipient lists, attachment contents, passphrases, or raw protocol errors containing secrets. Use opaque IDs where correlation is needed.
|
||||
- [ ] Complete and record a checklist for the merged manifest and production APK (permissions, exported components, backup rules, cleartext policy, WebView debugging, file access, and plugin exposure). Backup/data-extraction exclusions, cleartext denial, removal of the wildcard origin, and removal of the unused broad `FileProvider` are implemented; the production-artifact review is not.
|
||||
- [~] Require TLS and hostname validation on IMAP/SMTP and DAV. DAV is restricted to HTTPS and the configured origin; transport TLS modes are implemented and covered by unit tests. Invalid, expired, and mismatched certificate integration tests and a full native-client review remain open.
|
||||
- [~] Review `EpMailPlugin` as an untrusted-input boundary. DAV URLs and attachment names have specific native validation; PGP MIME structure and send confirmations have added native checks. A complete method-by-method bridge review and comprehensive size/state tests remain open.
|
||||
- [~] Keep signing keys outside the repository, label debug APKs, and require environment-provided credentials for signed builds. No production-signed APK or merged release review has been completed.
|
||||
- [x] Remove/sanitize sensitive native logging; the current mail sync log omits mailbox content and credentials.
|
||||
|
||||
**Exit criteria:** documented release manifest/config review; TLS validation and downgrade regression tests pass; no sensitive data in logs; release APK is signed and distinguishable from debug output.
|
||||
|
||||
### Phase 1 — Local data and privacy controls (P0)
|
||||
|
||||
1. Harden the encrypted vault: document the Keystore key's security properties and fallback behavior; use authenticated encryption with unique IVs; handle corruption, reinstall, lock-screen/key invalidation, and upgrades without plaintext fallback. Confirm all cached bodies, drafts, attachments, pending sends, DAV credentials, and account passwords remain inside the encrypted store or are deleted safely.
|
||||
2. Add explicit account removal and app-data deletion behavior, including queued messages, caches, downloaded attachments, and encryption keys. Test that deletion is complete within app-controlled storage and explain that exported files/backups are outside app control.
|
||||
3. Add a privacy setting for notification content. Default to generic “New mail” text without sender or subject; allow a user choice to show details. Apply the same rule to snooze reminders. Keep foreground-service notifications non-sensitive.
|
||||
4. Add optional app-lock behavior (immediate, after a delay, or off) using Android biometric/device credential authentication. Lock on background/resume and process recreation according to the chosen timeout; obscure sensitive UI in the task switcher. Make screenshot/screen-recording blocking an optional policy rather than an unconditional default.
|
||||
5. Keep background sync semantics separate from UI lock. Do not require biometric auth for every background sync if that would break notifications; instead define which credential/key material is available to background work, minimize it, and ensure the UI lock prevents reading local mail. Document that a UI lock is not equivalent to encrypting against a rooted or already-unlocked device.
|
||||
- [~] The combined account/cache/draft/outbox store uses AES-GCM with an Android Keystore key. Document and test the key's security/fallback behavior, corruption and reinstall handling, and lock-screen/key invalidation; verify no plaintext fallback across all stored data.
|
||||
- [~] Account removal exists, but prove deletion covers account caches, queued sends, downloaded files, and related encryption-key lifecycle; document exported files and recovery limits.
|
||||
- [x] Notification details are opt-in, persisted in the encrypted vault, and redacted from lock-screen previews; snooze notifications follow the privacy setting.
|
||||
- [~] A native app lock covers the WebView on background/resume and uses the device credential; background sync continues. Delayed lock, task-switcher obscuring, process-recreation/timeout tests, biometric UX, and recovery polish remain open.
|
||||
- [x] Background sync is separate from the UI lock. Further verification of which credentials/key material are available to background workers remains part of the vault lifecycle review.
|
||||
|
||||
**Exit criteria:** storage migration and failure tests; no plaintext fallback; app-lock/session tests across lifecycle events; notification privacy tests on supported Android versions; data removal tests.
|
||||
|
||||
### Phase 2 — OpenPGP on Android (P0 before claiming encrypted-mail parity)
|
||||
|
||||
1. Reuse the desktop OpenPGP.js protocol and MIME behavior only after the independent cryptography review is complete. Confirm the selected library/version and generated key formats interoperate with GnuPG and Thunderbird on Android too.
|
||||
2. Add an Android key store for private keys, public contacts, fingerprints, trust, and preferences. Protect the store with a random Android Keystore-wrapped encryption key. Private keys must additionally remain passphrase-protected; never persist passphrases. Support a bounded in-memory passphrase cache and wipe it on expiry, lock, and process teardown where practical.
|
||||
3. Support biometric/device-credential unlock as an optional way to release the store-wrapping key. Design background sync so it never needs private-key access. Handle biometric enrollment/key invalidation without silently destroying or regenerating the user's key store; provide explicit recovery/export guidance.
|
||||
4. Add the narrow Android bridge and settings UI for key generation, import/export/delete, revocation certificate export, contact-key import, fingerprint comparison, and trust changes. Keep security decisions out of renderer-only code.
|
||||
5. Implement read and send paths: detect/decrypt PGP/MIME and supported inline PGP; verify signatures and show clear unknown/bad/changed-key states; encrypt/sign recipients and the sender's Sent copy; include attachments inside the encrypted MIME payload. Do not cache decrypted bodies or put plaintext/passphrases in drafts, logs, notifications, or offline outbox.
|
||||
6. Enforce key replacement, trust elevation, and plaintext downgrade confirmations in native code (or another boundary the renderer cannot bypass). Show recipient addresses and full fingerprints; cancellation must leave state unchanged. Never silently send plaintext when encryption was requested or keys exist.
|
||||
7. Leave key-server lookup/publication disabled/out of initial Android scope. If added later, make it opt-in, disclose address lookup, require explicit publish destination and confirmation, and never treat server results as verified.
|
||||
- [~] OpenPGP.js 6.3.2 is pinned and used by the experimental Android bundle, before the independent review gate is complete solely to enable local testing. Independent review and GnuPG/Thunderbird interoperability on Android are release blockers.
|
||||
- [~] PGP keys, contacts, trust, and settings are stored in the existing Keystore-encrypted vault; keys generated/imported by the UI are passphrase-protected, and passphrases are not serialized. Biometric wrapping-key release, lifecycle/recovery handling, and automated checks against unprotected-key persistence remain open.
|
||||
- [ ] Add optional biometric/device-credential release of PGP key access and test Keystore invalidation/recovery. Background sync does not use PGP private keys.
|
||||
- [~] The Android UI/bridge supports key generation, paste-based import, export, deletion, revocation export, contacts, fingerprints, and trust. Native prompts now guard trust elevation and replacement; automated cancel/confirm regression tests remain open.
|
||||
- [~] PGP/MIME encryption/signing, PGP/MIME and inline-encrypted-message decryption, attachments, encrypted Sent copies, and ciphertext-before-queueing are implemented. Signed-only/clear-signed/inline signature parity, full hostile-input/tampering suite, and Android interoperability remain open.
|
||||
- [~] Native prompts guard trust elevation, key replacement, and plaintext sending when a key is available or encryption was requested; the native send path checks PGP/MIME structure. Emulator smoke tests cover trust accept/cancel and plaintext cancel. Automated bypass, stale-key, and queue policy tests remain open.
|
||||
- [x] Key-server lookup and publication are disabled in the initial Android test implementation.
|
||||
|
||||
**Exit criteria:** parity tests for desktop message formats and trust rules; Android-specific tests for cancel/confirm paths, tampering, malformed/oversized messages, key replacement, offline queueing, process death, and passphrase expiry; independent human review before release.
|
||||
|
||||
### Phase 3 — WebView, native bridge, and content hardening (P1)
|
||||
|
||||
1. Verify the production CSP and generated `www` assets match the reviewed source. Keep mail HTML inert and sanitized; do not allow remote script, CSS, frames, forms, or arbitrary navigation. Continue blocking remote images by default and reset approval per message.
|
||||
2. Restrict WebView navigation to the packaged app origin. External links must be parsed and scheme/host checked, shown to the user, and opened outside the WebView; reject `javascript:`, `file:`, `content:`, `intent:`, and unknown schemes.
|
||||
3. Review every Capacitor plugin/method and remove unused permissions/plugins. No generic filesystem, arbitrary intent, or unrestricted URL capability should be exposed to the renderer.
|
||||
4. Treat message HTML, headers, attachment names, filenames, sender data, key user IDs, and decrypted content as hostile input. Add sanitizer and UI regression cases for DOM injection, oversized payloads, spoofed signature indicators, and malicious filenames.
|
||||
- [~] Mail HTML is sanitized, remote images are blocked until per-message approval, and CSP restrictions are in place. Verify the generated release assets/CSP against the reviewed source on supported devices.
|
||||
- [x] External URLs are constrained and require user confirmation before opening outside the WebView; unsafe schemes are rejected.
|
||||
- [~] Broad unused filesystem/navigation capabilities have been removed, but a complete review of every Capacitor plugin/method and permission remains open.
|
||||
- [~] Attachment names, DAV values, PGP MIME, and several mail-content boundaries have validation/tests. More hostile-input, DOM-injection, oversized-data, and UI spoofing cases remain open.
|
||||
|
||||
**Exit criteria:** automated CSP/navigation/bridge tests, sanitizer regressions, and a manual WebView inspection on the minimum and target Android versions.
|
||||
|
||||
### Phase 4 — Assurance, maintenance, and incident readiness (P1)
|
||||
|
||||
1. Add Android dependency vulnerability checks and update policy for Capacitor, AndroidX, mail libraries, OpenPGP.js, and Gradle plugins. Review licenses and lock versions for security-critical dependencies.
|
||||
2. Run static analysis and Android-focused checks (including merged-manifest review and OWASP MASVS-aligned test cases) on release builds. Keep test evidence tied to the exact APK version/hash.
|
||||
3. Perform independent reviews of the Android Keystore/vault, Capacitor bridge, network/TLS configuration, and OpenPGP integration before describing Android as security-reviewed.
|
||||
4. Publish a concise Android security and recovery page: device-lock assumptions, notification/image privacy, TLS, local encryption, OpenPGP limits, key backup/revocation, and what account/key deletion does.
|
||||
5. Define a private vulnerability-reporting contact, triage process, supported Android version range, and security-fix release process.
|
||||
- [ ] Add/maintain Android dependency scanning and an update policy; review licenses and security-critical versions. Three moderate production dependency advisories are still open for compatibility review.
|
||||
- [ ] Run static analysis, merged-manifest review, and Android/MASVS-aligned checks against a production release; bind evidence to that APK's version and hash.
|
||||
- [ ] Obtain independent human review of the Keystore/vault, bridge, TLS, and OpenPGP implementation before making security-reviewed claims.
|
||||
- [ ] Publish user-facing Android security, key-backup, and recovery guidance.
|
||||
- [ ] Define a vulnerability-reporting contact, triage process, supported Android versions, and security-fix release process.
|
||||
|
||||
## Minimum release criteria for Android OpenPGP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user