Security review and fix issues

This commit is contained in:
2026-11-03 23:57:48 +02:00
parent 5f456e64d0
commit 78989f7b56
14 changed files with 95 additions and 18 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ function makeEndpoint(account) {
async pgpGetMessageSource() { return messageSource; }
};
return {
api: createAndroidPgp({ EpMail, getAccount: async () => account }),
api: createAndroidPgp({ EpMail, getAccount: async () => account, confirm: () => true }),
setMessage(rawBase64) { messageSource = { rawBase64 }; }
};
}
+21 -2
View File
@@ -20,7 +20,7 @@ const bundled = esbuild.buildSync({
vm.runInThisContext(bundled);
const { createAndroidPgp } = global.AndroidPgpBundle;
function makeEndpoint(account) {
function makeEndpoint(account, { confirm = () => true } = {}) {
const vault = { keys: [], contacts: [], settings: {} };
let messageSource = null;
const EpMail = {
@@ -29,7 +29,7 @@ function makeEndpoint(account) {
async pgpGetMessageSource() { return messageSource; }
};
return {
api: createAndroidPgp({ EpMail, getAccount: async () => account }),
api: createAndroidPgp({ EpMail, getAccount: async () => account, confirm }),
EpMail,
setMessage(value) { messageSource = value; },
vault
@@ -85,6 +85,25 @@ test('Android OpenPGP refuses encryption when any recipient key is missing', asy
}), error => error.code === 'NO_RECIPIENT_KEY');
});
test('Android OpenPGP requires explicit fingerprint confirmation for unverified recipient keys', async () => {
const sender = makeEndpoint({ email: 'alice@example.test', displayName: 'Alice', signature: '' }, {
confirm: warning => {
assert.match(warning, /bob@example\.test/);
assert.match(warning, /[A-F0-9]{4}(?: [A-F0-9]{4}){9}/);
assert.match(warning, /not been verified by fingerprint/);
assert.match(warning, /Compare each fingerprint with its owner through another channel/);
return false;
}
});
const recipient = makeEndpoint({ email: 'bob@example.test', displayName: 'Bob', signature: '' });
const bob = await recipient.api.generate({ name: 'Bob', email: 'bob@example.test', passphrase: 'bob test passphrase' });
await sender.api.addContact({ armoredKey: await recipient.api.exportPublic(bob.key.fingerprint) });
await assert.rejects(sender.api.buildOutgoing({
to: 'bob@example.test', text: 'do not send to an unverified key',
pgp: { encrypt: true }, attachments: []
}), error => error.code === 'UNVERIFIED_RECIPIENT_KEY');
});
test('Android verifies PGP/MIME signed-only and clear-signed mail', async () => {
const sender = makeEndpoint({ email: 'alice@example.test', displayName: 'Alice', signature: '' });
const recipient = makeEndpoint({ email: 'bob@example.test', displayName: 'Bob', signature: '' });
+4
View File
@@ -150,6 +150,8 @@ test('Android OpenPGP uses the encrypted vault and queues only built MIME data',
assert.match(plugin, /fun pgpGetMessageSource/);
assert.match(plugin, /pgpStoreChangeWarning/);
assert.match(plugin, /plaintextSendWarning/);
assert.match(plugin, /AndroidPgpPolicy\.unverifiedRawMimeWarning\(\)/);
assert.match(plugin, /title = if \(rawMime\) "Send unverified MIME\?"/);
assert.match(plugin, /Send plaintext/);
assert.match(plugin, /showPgpConfirmation\(/);
assert.match(plugin, /onCancelled = \{ call\.reject\("OpenPGP key change cancelled\."\) \}/);
@@ -158,7 +160,9 @@ test('Android OpenPGP uses the encrypted vault and queues only built MIME data',
assert.match(androidPgpConfirmationGate, /compareAndSet\(false, true\)/);
assert.match(androidPgpPolicy, /fun storeChangeWarning/);
assert.match(androidPgpPolicy, /fun plaintextSendWarning/);
assert.match(androidPgpPolicy, /fun unverifiedRawMimeWarning/);
assert.match(androidPgp, /curve25519Legacy/);
assert.match(androidPgp, /These recipient keys have not been verified by fingerprint/);
assert.match(androidPgp, /multipart\/encrypted/);
assert.match(androidPgp, /MAX_MESSAGE_BYTES = 25 \* 1024 \* 1024/);
assert.match(androidPgp, /async function verifyMessage/);