File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -378,13 +378,20 @@ impl MimeMessage {
378378 // signed part, but it doesn't match the outer one.
379379 // This _might_ be because the sender's mail server
380380 // replaced the sending address, e.g. in a mailing list.
381- // Or it's because someone is doing some replay attack
382- // - OTOH, I can't come up with an attack scenario
383- // where this would be useful.
381+ // Or it's because someone is doing some replay attack.
382+ // Resending encrypted messages via mailing lists
383+ // without reencrypting is not useful anyway,
384+ // so we return an error below.
384385 warn ! (
385386 context,
386387 "From header in signed part doesn't match the outer one" ,
387388 ) ;
389+
390+ // Return an error from the parser.
391+ // This will result in creating a tombstone
392+ // and no further message processing
393+ // as if the MIME structure is broken.
394+ bail ! ( "From header is forged" ) ;
388395 }
389396 }
390397 }
Original file line number Diff line number Diff line change @@ -4241,3 +4241,22 @@ Chat-Group-Member-Added: charlie@example.com",
42414241
42424242 Ok ( ( ) )
42434243}
4244+
4245+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
4246+ async fn test_forged_from ( ) -> Result < ( ) > {
4247+ let mut tcm = TestContextManager :: new ( ) ;
4248+ let alice = tcm. alice ( ) . await ;
4249+ let bob = tcm. bob ( ) . await ;
4250+
4251+ let bob_chat_id = tcm. send_recv_accept ( & alice, & bob, "hi" ) . await . chat_id ;
4252+ chat:: send_text_msg ( & bob, bob_chat_id, "hi!" . to_string ( ) ) . await ?;
4253+
4254+ let mut sent_msg = bob. pop_sent_msg ( ) . await ;
4255+ sent_msg. payload = sent_msg
4256+ . payload
4257+ . replace ( "bob@example.net" , "notbob@example.net" ) ;
4258+
4259+ let msg = alice. recv_msg ( & sent_msg) . await ;
4260+ assert ! ( msg. chat_id. is_trash( ) ) ;
4261+ Ok ( ( ) )
4262+ }
You can’t perform that action at this time.
0 commit comments