mailsploit prevention in MD

Jan-Pieter Cornet <[email protected]> Wed, 6 Dec 2017 01:37:39 +0100
Newsgroups gmane.mail.mimedefang
Message-ID <[email protected]>
Another bug with it's own logo and website has appeared: www.mailsploit.com.

This targets MUAs. It abuses RFC2047 MIME encoding of headers to insert NUL characters.

The mails are relatively easy to stop using mimedefang. I've just rolled it out on our platform.

Boilerplate code (completely untested, but partly cut-n-pasted out of working code). Enjoy.


use Encode qw(decode);

sub filter_end ($) {
     my($entity) = @_;

     # ... any other processing you do in filter_end

     my $fromline = $entity->head->get('From');
     eval {
         # MIME::Decode of the header might fail for unknown charset.
         my $friendly_from = decode('MIME-Header', $fromline);
         if ( $friendly_from =~ /\0/ ) {
             md_syslog('warning', "$MsgID: Encoded NUL in From header: $fromline");
             # XXX insert your own code to handle such messages, eg redirect, reject, or change the From: header
             action_bounce('Encoded NUL in From rejected');
         }
     };
     if ( $@ ) {
         # you may, for security reasons, choose to reject here too.
         md_syslog('warning', "$MsgID: Error decoding From: $fromline; error: $@");
     }

     # ... any more processing you wish to do in filter_end
}


-- 
Jan-Pieter Cornet <[email protected]>
"Any sufficiently advanced incompetence is indistinguishable from malice."
     - Grey's Law

_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
signature.asc (application/pgp-signature, 963 B)
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEERi08X+sQJ+Ye9TauIGpRrVHKNykFAlonO9NfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDQ2
MkQzQzVGRUIxMDI3RTYxRUY1MzZBRTIwNkE1MUFENTFDQTM3MjkACgkQIGpRrVHK
NykoIxAAsYoqjttoSfDF5p4s2gZAwRS0+tj2taMGHAzrVKTp7H+tiFyVSXal5MfX
d/2t92+ZaK479yOfHxrUCUUO8zAuGa4DsGx+dQwGqNK9LhogYe5IOHV/+4vzX0/X
4Jf7L8IX2mdncSqPms1EN3wPmB7/pA3JCtTG5vp3ggw/+yvCYQXGKCJlkvQm8ODf
08cApgsAILYnoEErh+znJBfZWT8YmZ+RZAcXHR1v00FSRbpO5ZXqYDpEtgXEFWip
uArjRRJ54mFLHzaYTmw4EuuLxTQn/Lnjrd+5c4ffypSpjaI3kU1GzLnX81qIR/AF
QzzXSW078k3bV3ZAqWMJmZ/Lw4p1C+UyLhxdIhQ2j6uBmSWebi69ckpwGhr5CHwY
z+9C2GD04XaLtAIIphn0Orok3TyuG7mrqIoDalzPIRH2qUnmdy6SkC7PxqI+oxV2
TsqcvhL7nhXxq2dMraWAg488UJefZyVTDz4syb/nECY9Rn3iMdSHMlEQQUJvmTG5
ar55oedBe/rADijPlkpSqSyGGz949mu/2dOfBOqN8abZX6EG59PUVSYinZDjJ/XP
rlpA3JjiR3fHIh6QTG9SfFtd61GbF3N5ohbgKbMPRCHNzi9p4J0ddDRQG+MBX1vF
yLYdVdjlC2Y/qmTuCN3QTvVBAy/jSqcOKM2t7krBkB5qio9AoOY=
=GLsk
-----END PGP SIGNATURE-----