6.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.
Current status (2026-10-16, ep-mail 0.4.38): The entries below are a historical review record. The replacement-key and trust-elevation confirmations are implemented in the main process and now have IPC regression tests for cancel/confirm behavior. The send-time plaintext downgrade check is enforced in the main process. The user confirms the current built artifact works. A direct IPC test for the plaintext-send confirmation branch and an independent human review remain open; Android OpenPGP support is not implemented.
Scope
desktop/pgp-keystore.cjs: key store,safeStoragewrapping, contacts, trustdesktop/pgp-mail.cjs: detect, decrypt, verify, build PGP/MIME, passphrase cachepgp:*IPC handlers, now registered indesktop/ipc/pgp.cjs, plus the plaintext-send check indesktop/ipc/mail.cjs; the original review predates this IPC extraction.- Renderer:
pgp-mail-ui.js,pgp-ui.js, and thewindow.epMailFeatures.pgp.prepareSendfeature hook used bymail-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
- Send-time check: the renderer 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. This renderer hook is now exposed as
window.epMailFeatures.pgp.prepareSend. - Trusted confirmation: the
pgp:set-trusthandler 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 at the original review time
npm test: 20 passed, 0 failed (includes the GnuPG interoperability tests).node --checkon the edited files.- The fixes were not exercised in the running app.
Remaining work recorded after the first review (2026-10-08)
- 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. This was still open at the time; see the later review pass below.
- Run
npm auditand 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 | Fixed |
| 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 | Fixed |
| 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 | Fixed |
Applied fixes:
- #3: native confirmation showing both fingerprints when a key overlaps existing contacts, and the add-contact flow aborts if the replacement is not confirmed.
- #4: the main process checks recipient keys before allowing a plaintext send and shows a trusted confirmation dialog.
- #5: Linux now rejects the insecure
basic_textsafeStorage backend and asks the user to switch to a secure system keyring before storing mail or PGP secrets.
Current follow-up
- Replacement-key and trust-elevation confirmation are enforced in
desktop/ipc/pgp.cjs.tests/pgp-ipc-registration.test.cjsverifies both cancellation and confirmation paths for those changes. - Main-process plaintext-send confirmation is implemented in
desktop/ipc/mail.cjs; direct regression coverage for that dialog's accept/cancel branches remains open. - Human cryptography/security review and dependency remediation remain outstanding. OpenPGP.js is pinned to 6.3.2;
npm audit --omit=devcurrently reports three moderate advisories inip-addressand the Nodemailer/mailparser dependency chain. GnuPG interoperability tests are in the current test suite and should be rerun after dependency changes. - Android's experimental OpenPGP implementation was added after the desktop review and is outside the reviewed scope. It must not be relied on for sensitive mail until independently reviewed; native trust/replacement and downgrade enforcement also remain open.
Third review pass (2026-10-17)
Fresh automated review of the whole repository (ep-mail 0.4.39), covering the Electron main process, IPC, preload and renderer boundary, mail content handling, storage and crypto, and network and file operations. No code was changed in this pass.
| # | Severity | File | Lines | Vulnerability | Confidence |
|---|---|---|---|---|---|
| - | - | - | - | No actionable vulnerabilities found. | - |
The open items under "Current follow-up" still apply: human review, dependency audit, OpenPGP.js version pinning and Android OpenPGP support.