fix: Take the last valid Autocrypt header (#7167)

DKIM-Signatures apply to the last headers, so start from the last header and take a valid one,
i.e. skip headers having unknown critical attributes, etc. Though this means that Autocrypt header
must be "oversigned" to guarantee that a not DKIM-signed header isn't taken, still start from the
last header for consistency with processing other headers. This isn't a security issue anyway.
This commit is contained in:
iequidoo
2025-09-21 13:42:36 -03:00
committed by iequidoo
parent 738dc5ce19
commit 7477ebbdd7
3 changed files with 180 additions and 24 deletions

View File

@@ -1990,6 +1990,27 @@ async fn test_chat_edit_imf_header() -> Result<()> {
Ok(())
}
/// Tests that the last valid Autocrypt header is taken:
/// - The 3rd header is skipped because of the unknown critical attribute.
/// - The 2nd header is taken despite it has an unknown non-critical attribute.
/// - The 1st header shouldn't be looked at.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_multiple_autocrypt_hdrs() -> Result<()> {
let mut tcm = TestContextManager::new();
let bob = &tcm.bob().await;
let msg_id = receive_imf(
bob,
include_bytes!("../../test-data/message/thunderbird_with_multiple_autocrypts.eml"),
false,
)
.await?
.unwrap()
.msg_ids[0];
let msg = Message::load_from_db(bob, msg_id).await?;
assert!(msg.get_showpadlock());
Ok(())
}
/// Tests that timestamp of signed but not encrypted message is protected.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_protected_date() -> Result<()> {