markov2 / perl5-Mail-Message

Processing MIME messages
http://perl.overmeer.net/CPAN
1 stars 1 forks source link

Multiple boundary attributes cause parts to be missed completely #20

Open todd-richmond opened 2 hours ago

todd-richmond commented 2 hours ago

A serious issue has been discovered that if you supply multiple boundaries, Mail::Message will only parse content from the 1st boundary, but Apple Mail will parse the last boundary. That causes us to skip processing parts that the end-user sees in their mail client. I think the simplest fix is to always use the last boundary so that any content before that is considered prologue and ignored

Note that $field->attribute('boundary, '2') will only change the 1st boundary and not any subsequent boundaries if > 1 attribute


Date: Wed, 21 Aug 2024 10:10:49 +0000
MIME-Version: 1.0
Subject: a email contain virus
Content-Type: multipart/mixed; boundary=0;boundary=1;boundary=2

--1
Content-type: application/octet-stream; name=123
Content-Disposition: attachment; filename=noteicar

123
--1--
--2
Content-type: application/octet-stream; name=123
Content-Disposition: attachment; filename=eicar

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
--2--
todd-richmond commented 2 hours ago

proposed solution


diff Multipart.pm.org Multipart.pm
448,449c448,449
<     {   my $boundary = $mime->attribute('boundary');
<         return $boundary if defined $boundary;
---
>     {   my @boundary = $mime->attributes('boundary');
>         return $boundary[-1] if $#boundary != -1;