feat: Don't affect MimeMessage with "From" and secured headers from encrypted unsigned messages

If a message is encrypted, but unsigned:
- Don't set `MimeMessage::from_is_signed`.
- Remove "secure-join-fingerprint" and "chat-verified" headers from `MimeMessage`.
- Minor: Preserve "Subject" from the unencrypted top level if there's no "Subject" in the encrypted
  part, this message is displayed w/o a padlock anyway.

Apparently it didn't lead to any vulnerabilities because there are checks for
`MimeMessage::signatures.is_empty()` in all necessary places, but still the code looked dangerous,
especially because `from_is_singed` var name didn't correspond to its actual value (it was rather
`from_is_encrypted_maybe_signed`).
This commit is contained in:
iequidoo
2023-11-18 21:46:55 -03:00
committed by iequidoo
parent 9cc9579b2d
commit ebfbc11973
5 changed files with 148 additions and 20 deletions

View File

@@ -63,6 +63,11 @@ pub struct ReceivedMsg {
/// Whether IMAP messages should be immediately deleted.
pub needs_delete_job: bool,
/// Whether the From address was repeated in the signed part
/// (and we know that the signer intended to send from this address).
#[cfg(test)]
pub(crate) from_is_signed: bool,
}
/// Emulates reception of a message from the network.
@@ -161,6 +166,8 @@ pub(crate) async fn receive_imf_inner(
sort_timestamp: 0,
msg_ids,
needs_delete_job: false,
#[cfg(test)]
from_is_signed: false,
}));
}
Ok(mime_parser) => mime_parser,
@@ -1393,6 +1400,8 @@ RETURNING id
sort_timestamp,
msg_ids: created_db_entries,
needs_delete_job,
#[cfg(test)]
from_is_signed: mime_parser.from_is_signed,
})
}