feat: import Autocrypt-Gossip keys without checking the addresses

It is safe to import any keys into the keychain.
Keys can anyway be imported from vCards
and Autocrypt headers without any checks.

These checks are from the time before we had key-contacts
and maintained Autocrypt `peerstates` table.
This commit is contained in:
link2xt
2026-08-28 20:56:57 +00:00
committed by l
parent 120bf11f4c
commit 38d6cf2bcd

View File

@@ -555,8 +555,7 @@ impl MimeMessage {
// but only if the mail was correctly signed. Probably it's ok to not require // but only if the mail was correctly signed. Probably it's ok to not require
// encryption here, but let's follow the standard. // encryption here, but let's follow the standard.
let gossip_headers = mail.headers.get_all_values("Autocrypt-Gossip"); let gossip_headers = mail.headers.get_all_values("Autocrypt-Gossip");
gossiped_keys = gossiped_keys = parse_gossip_headers(context, gossip_headers).await?;
parse_gossip_headers(context, &from.addr, &recipients, gossip_headers).await?;
} }
if let Some(inner_from) = inner_from { if let Some(inner_from) = inner_from {
@@ -2135,12 +2134,8 @@ fn remove_header(
/// Parses `Autocrypt-Gossip` headers from the email, /// Parses `Autocrypt-Gossip` headers from the email,
/// saves the keys into the `public_keys` table, /// saves the keys into the `public_keys` table,
/// and returns them in a HashMap<address, public key>. /// and returns them in a HashMap<address, public key>.
///
/// * `from`: The address which sent the message currently being parsed
async fn parse_gossip_headers( async fn parse_gossip_headers(
context: &Context, context: &Context,
from: &str,
recipients: &[SingleInfo],
gossip_headers: Vec<String>, gossip_headers: Vec<String>,
) -> Result<BTreeMap<String, GossipedKey>> { ) -> Result<BTreeMap<String, GossipedKey>> {
// XXX split the parsing from the modification part // XXX split the parsing from the modification part
@@ -2155,25 +2150,6 @@ async fn parse_gossip_headers(
} }
}; };
if !recipients
.iter()
.any(|info| addr_cmp(&info.addr, &header.addr))
{
warn!(
context,
"Ignoring gossiped \"{}\" as the address is not in To/Cc list.", &header.addr,
);
continue;
}
if addr_cmp(from, &header.addr) {
// Non-standard, might not be necessary to have this check here
warn!(
context,
"Ignoring gossiped \"{}\" as it equals the From address", &header.addr,
);
continue;
}
import_public_key(context, &header.public_key) import_public_key(context, &header.public_key)
.await .await
.context("Failed to import Autocrypt-Gossip key")?; .context("Failed to import Autocrypt-Gossip key")?;