Files
ep-mail-client/SECURITY_REVIEW.md

2.8 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.