Security review and fix issues
This commit is contained in:
+11
-1
@@ -255,7 +255,7 @@ async function signatureStatuses(signatures, verification, sender) {
|
||||
return results;
|
||||
}
|
||||
|
||||
export function createAndroidPgp({ EpMail, getAccount }) {
|
||||
export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.confirm }) {
|
||||
let storePromise;
|
||||
const passphrases = new Map();
|
||||
let cacheMinutes = 10;
|
||||
@@ -373,6 +373,16 @@ export function createAndroidPgp({ EpMail, getAccount }) {
|
||||
if (pgp.encrypt && recipientKeys.missing.length) {
|
||||
throw Object.assign(new Error(`No public key for ${recipientKeys.missing.join(', ')}.`), { code: 'NO_RECIPIENT_KEY', missing: recipientKeys.missing });
|
||||
}
|
||||
const unverifiedKeys = recipientKeys.keys.filter(item => item.trust !== 'verified');
|
||||
if (pgp.encrypt && unverifiedKeys.length) {
|
||||
const details = unverifiedKeys.map(item =>
|
||||
`${item.address}\n${item.fingerprint.match(/.{1,4}/g).join(' ')} (${item.trust})`
|
||||
).join('\n\n');
|
||||
const warning = `These recipient keys have not been verified by fingerprint:\n\n${details}\n\nIf a key is incorrect, its owner may be able to read this message. Compare each fingerprint with its owner through another channel before sending. Send encrypted mail to these unverified keys anyway?`;
|
||||
if (typeof confirm !== 'function' || !confirm(warning)) {
|
||||
throw Object.assign(new Error('Sending to unverified recipient keys was cancelled.'), { code: 'UNVERIFIED_RECIPIENT_KEY' });
|
||||
}
|
||||
}
|
||||
let inner = mimeInner(`${String(message.text || '').slice(0, 500000)}${account.signature ? `\n\n${String(account.signature).slice(0, 5000)}` : ''}`, message.attachments || []);
|
||||
const headers = [
|
||||
`From: ${formatAddress(from)}`,
|
||||
|
||||
Reference in New Issue
Block a user