Files
ep-mail-client/SECURITY_REVIEW.md
T

4.3 KiB

Security review: OpenPGP encryption

Date: 2026-10-08 Version reviewed: 0.3.2 (working tree, uncommitted changes included) Type: automated review by an AI security-review agent. It is not a substitute for a human review.

Scope

  • desktop/pgp-keystore.cjs: key store, safeStorage wrapping, contacts, trust
  • desktop/pgp-mail.cjs: detect, decrypt, verify, build PGP/MIME, passphrase cache
  • pgp:* IPC handlers in desktop/main.cjs and desktop/preload.cjs
  • Renderer: pgp-mail-ui.js, pgp-ui.js, the pgpPrepareSend hook in mail-ui.js
  • Design reference: ENCRYPTION_PLAN.md

Focus areas: secret leaks (disk, logs, outbox, renderer), IPC abuse by a compromised renderer, HTML injection from key user IDs and decrypted content, signature status spoofing, key matching by fingerprint, silent downgrade to plaintext, malformed or oversized input, passphrase cache lifetime.

Findings

# Severity File Issue Confidence Status
1 🟡 MEDIUM pgp-mail-ui.js, mail-ui.js Encrypt-by-default is applied after a 300 ms debounced key lookup. Sending before it finished skipped the key check and sent the message unencrypted. 9/10 Fixed
2 🟡 MEDIUM desktop/preload.cjs, desktop/main.cjs, desktop/pgp-keystore.cjs A compromised renderer could add a public key for a recipient's address and call pgp:set-trust to mark it verified. Recipient key selection prefers higher trust, so later mail could be encrypted to the attacker's key. The confirmation existed only in the renderer UI. 8/10 Fixed

No critical or high severity issues were reported.

Fixes applied

  1. Send-time check: pgpPrepareSend now checks recipient keys when you press Send. If keys exist for all recipients and you did not change the Encrypt box yourself, it asks before sending unencrypted. Unticking Encrypt on purpose still sends without a prompt.
  2. Trusted confirmation: the pgp:set-trust handler in the main process shows a native dialog with the contact and fingerprint before raising trust. A cancelled dialog aborts the change. The renderer's own prompt may appear as well, so users can see two confirmations.

Verification

  • npm test: 20 passed, 0 failed (includes the GnuPG interoperability tests).
  • node --check on the edited files.
  • The fixes were not exercised in the running app.

Remaining work

  • Human review of the key store, the IPC boundary and the signature UI.
  • Replacement-key confirmation in the main process when a new key arrives for an address that already has a contact. The review suggested it, and only the trust confirmation was added.
  • Run npm audit and pin the OpenPGP.js version.
  • Re-run the GnuPG interoperability tests after dependency updates.
  • Android has no encryption support yet, so it was not reviewed.

Second review pass (2026-10-09)

Fresh review of the same scope after the first round of fixes. Tests: 20 passed, 0 failed. No code was changed in this pass.

# Severity File Issue Confidence Status
3 🟡 MEDIUM desktop/pgp-keystore.cjs, desktop/main.cjs pgp:add-contact adds a key for an address that already has one without a main-process confirmation. At equal trust the newest key wins recipient selection, so an added key can take over outgoing encryption. The trust dialog does not cover replacement. 9/10 Open
4 🟡 MEDIUM desktop/main.cjs, desktop/preload.cjs The send-time downgrade check exists only in the renderer. mail:send sends plaintext when pgp is omitted, so a compromised renderer can bypass the warning. 9/10 Open
5 🟡 MEDIUM desktop/main.cjs safeStorage is used without checking the backend. On Linux the basic_text backend uses a hardcoded password, so a copied store would expose account credentials and mail data. PGP private keys stay protected by their own passphrases. 8/10 Open

Suggested fixes:

  • #3: native confirmation showing both fingerprints when a key overlaps existing contacts, and do not select the new key until confirmed.
  • #4: make the main process decide on plaintext sends when recipient keys exist, with a trusted confirmation.
  • #5: on Linux, reject or warn on basic_text, or add independent encryption.