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
+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: '' });