Discussion:
[Mimedefang] Missed executable attachments with empty Content-Type
Tomasz Ostrowski
2015-04-28 12:34:59 UTC
Permalink
I've just received a trojan/exploit attachment with CHM extension, which
should be filtered by MIMEdefang but wasn't.

This attachment was send in a MIME part with broken header:
Content-Type: ;
name="SecureMessage.chm"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
name="SecureMessage.chm"

Please notice empty "Content-Type" in above header. Because of empty
content type my mail client (Thunderbird) displayed it as garbage, but
also defaulted to to save it as a file with original name
"SecureMessage.chm". Opening it would compromise a system, as it isn't
recognized as a virus by most antivirus programs yet:
https://www.virustotal.com/en/file/467f6d76802014ab671fa868b9b81b79497889f906c434620742e391aee17670/analysis/

I've retested it changing extension to EXE and it was also allowed.

I'm attaching the whole message (beware, contains virus) in 7z archive
with password "infected".

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
Dianne Skoll
2015-04-28 13:13:25 UTC
Permalink
On Tue, 28 Apr 2015 14:34:59 +0200
Post by Tomasz Ostrowski
I've just received a trojan/exploit attachment with CHM extension,
which should be filtered by MIMEdefang but wasn't.
Well, it surely depends on your filter?

Anyway, I made a SpamAssassin rule to block these. Feel free to use/adapt
the following:

#==========================================================================
ifplugin Mail::SpamAssassin::Plugin::MIMEHeader
mimeheader RP_D_00086 Content-Disposition =~ /SecureMessage\.chm/
score RP_D_00086 50
describe RP_D_00086 SecureMessage.chm malware
endif
#==========================================================================

Regards,

Dianne.
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Tomasz Ostrowski
2015-04-28 13:44:03 UTC
Permalink
Post by Dianne Skoll
Post by Tomasz Ostrowski
I've just received a trojan/exploit attachment with CHM extension,
which should be filtered by MIMEdefang but wasn't.
Well, it surely depends on your filter?
My filter is depending on "re_match" function provided by MIMEdefang.
Also suggested-minimum-filter-for-windows-clients is using it.
Post by Dianne Skoll
re_match returns true if any of the fields [Content-Disposition.filename,
Content-Type.name and Content-Description] matches the regexp without
regard to case.
In my example Content-Type should match, but it doesn't because it is
probably deliberately broken enough to avoid detection by security
products. But not enough to not work in Email clients.
Post by Dianne Skoll
Anyway, I made a SpamAssassin rule to block these [SecureMessage.chm].
I think this resolution is unsustainable - this technique might get
popular fast if this proves to foul filters.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Dianne Skoll
2015-04-28 13:58:24 UTC
Permalink
On Tue, 28 Apr 2015 15:44:03 +0200
Post by Tomasz Ostrowski
My filter is depending on "re_match" function provided by MIMEdefang.
Also suggested-minimum-filter-for-windows-clients is using it.
That's odd, because when I run a similar message through MIME::Parser,
I get this:

$ perl mimedefang-util --structure < /tmp/s
non-leaf: type=multipart/mixed; fname=; disp=
leaf: type=text/plain; fname=; disp=
leaf: type=text/plain; fname=SecureMessage.chm; disp=attachment

However, you're right... MIMEDefang is not picking up the attachment
name. I will look into it.

Regards,

Dianne.
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Dianne Skoll
2015-04-28 14:10:03 UTC
Permalink
On Tue, 28 Apr 2015 09:58:24 -0400
Post by Dianne Skoll
However, you're right... MIMEDefang is not picking up the attachment
name. I will look into it.
Actually, I'm wrong... in CanIt, we do pick up the attachment name
by using $entity->head->recommended_filename. I have no idea
why it's not working for you; this is very mysterious.

Regards,

Dianne.
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Paul Murphy
2015-04-28 17:23:42 UTC
Permalink
There are several approaches which will help - firstly, SpamAssassin
already detects null content types - my filter has a couple of
additional checks, but the key one here is "T_CTYPE_NULL" which my
system picked up for this attachment:

------------------_=_NextPart_001_01CF5EDB.A3086B20
Content-Type: ; name="SecureMessage.chm"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="SecureMessage.chm"

My logs show this:

Apr 28 12:29:18 baldur mimedefang.pl[14717]: SA debug -
t3SBTBpv024576,17.015(6/0/0),BAYES_60,CK_HELO_DYNAMIC_SPLIT_IP,DATE_IN_P
AST_96_XX,HELO_DYNAMIC_IPADDR2,MSGID_FROM_MTA_HEADER,RDNS_DYNAMIC,TVD_RC
VD_IP,T_CTYPE_NULL,T_TVD_MIME_NO_HEADERS,BROADBAND,autolearn=unavailable

The SpamAssassin report for this message shows:

Content analysis details: (11.0 points, 5.0 required)

pts rule name description
---- ----------------------
--------------------------------------------------
1.5 CK_HELO_DYNAMIC_SPLIT_IP Relay HELO'd using suspicious hostname
(Split IP)
0.0 TVD_RCVD_IP Message was received from an IP address
3.4 DATE_IN_PAST_96_XX Date: is 96 hours or more before Received:
date
0.0 T_TVD_MIME_NO_HEADERS BODY: T_TVD_MIME_NO_HEADERS
1.5 BAYES_60 BODY: Bayes spam probability is 60 to 80%
[score: 0.7020]
1.0 RDNS_DYNAMIC Delivered to internal network by host with
dynamic-looking rDNS
0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay
0.0 T_CTYPE_NULL Malformed Content-Type header
3.6 HELO_DYNAMIC_IPADDR2 Relay HELO'd using suspicious hostname (IP
addr 2)

So, if you are concerned about this, change the score for T_CTYPE_NULL
to something like 10 in your local Spamassassin configuration.

Secondly, your filter should be checking for .chm files and either
rejecting or quarantining them - they are compiled Windows help files,
which are not usually sent by e-mail, and which most modern Windows
systems will specifically refuse to open until you mark them as safe
from File/Properties. I define two types of bad attachment types -
really bad types which are rejected outright, and dangerous types which
are quarantined:

$really_bad_exts = '(bat|com|exe|hta|pif|scr|sys|wsh)';
# Bad extensions
$bad_exts =
'(ade|adp|app|asd|asf|asx|avi|bas|bat|bz2|chm|cmd|com|cpl|crt|dll|exe|fl
v|fxp|hlp|hta|hto|inf|ini|ins|isp|jse?|lib|lnk|m1v|mdb|mde|mpg|mpeg|mp3|
mp4|mov|msc|msi|msp|mst|ocx|pcd|pif|pps|prg|rar|reg|scr|sct|sh|shb|shs|s
wf|sys|url|vb|vbe|vbs|vxd|wav|wma|wmd|wms|wmv|wmz|wsc|wsf|wsh|\{[^\}]+\}
)';

My filter quarantined this message, and with no content type specified,
it classified it as text/plain - I keep a "progress" file in each spool
folder which shows what happened, and I keep all spool folders for 24
hours to aid investigations - this is a very low volume mail server at
home, so I can get away with this better than someone handling millions
of messages per day. The progress file shows:

Filter_begin: OK
Filter: Part /text/plain Filter OK
Filter: QUARANTINE - bad filename SecureMessage.chm of type text/plain
Filter: Part /text/plain Filter OK

Finally, this was sent from a system which is almost certainly a
compromised PC on a DSL connection:

SENDER=<***@bonniej.com>
HOSTIP=105.237.107.22
HOSTNAME=105-237-107-22.access.mtnbusiness.co.za
HELO=105-237-107-22.access.mtnbusiness.co.za ...

Given the IP appears in the rDNS entry, my system bumps the SpamAssassin
score by 6, which you can see in the log entry above - the section which
gives "17.015(6/0/0)" reflects the total SpamAssassin score of 11.015
from the scans, plus my local adjustments of 6 for a "broadband" system
which has its IP in its rDNS, 0 for checks against the Mailer header (I
keep stats on the "spaminess" of different mailer strings) , and 0 for
checks against the subject header (where I check for things like my
domain name or username in the subject).

Any one of these should have caused the message to be failed. The key
is to tailor your filter and apply some local logic based on your
knowledge of what "normal" e-mail patterns are for you. The example
filter is a good starting point, but it has its limits, and is called
"example" and "minimal" for good reasons.

Best Wishes,

Paul.
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Tomasz Ostrowski
2015-04-29 09:51:30 UTC
Permalink
Post by Dianne Skoll
Post by Dianne Skoll
However, you're right... MIMEDefang is not picking up the attachment
name. I will look into it.
Actually, I'm wrong... in CanIt, we do pick up the attachment name
by using $entity->head->recommended_filename. I have no idea
why it's not working for you; this is very mysterious.
I've found the cause - I have outdated MIME-tools. Distributions I use,
CentOS 6 and CentOS 5 (clones of RHEL 6 and 5), provide very outdated
Post by Dianne Skoll
Content-Type: ; name="malware.zip"
I've managed to work around this without conflicting with system's
package management like this:

# Downloaded latest version of MIME-tools
# from http://search.cpan.org/~dskoll/MIME-tools/ to /tmp/

# Extracted it:
cd /tmp; tar xf MIME-tools-*.tar.gz; cd MIME-tools-*

# Created a directory for updated MIME-tools module:
mkdir /etc/mail/mimedefang-lib

# Installed the module:
perl Makefile.PL INSTALL_BASE=/etc/mail/mimedefang-lib/
make install

# Added module path to search path in mimedefang run script
echo export PERL5LIB=/etc/mail/mimedefang-lib/lib/perl5/ >> \
/etc/sysconfig/mimedefang

# Restarted mimedefang:
service mimedefang restart


This might be useful for other RHEL/CentOS/Scientific/Oracle Linux
users. Thank you, Dianne, for your help.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Kevin A. McGrail
2015-04-28 14:06:27 UTC
Permalink
Post by Tomasz Ostrowski
My filter is depending on "re_match" function provided by MIMEdefang.
Also suggested-minimum-filter-for-windows-clients is using it.
Post by Dianne Skoll
re_match returns true if any of the fields
[Content-Disposition.filename,
Content-Type.name and Content-Description] matches the regexp without
regard to case.
In my example Content-Type should match, but it doesn't because it is
probably deliberately broken enough to avoid detection by security
products. But not enough to not work in Email clients.
Post by Dianne Skoll
Anyway, I made a SpamAssassin rule to block these [SecureMessage.chm].
I think this resolution is unsustainable - this technique might get
popular fast if this proves to foul filters.
I took a little umbrage about your statement and wanted to rant for a
moment about why.

1st, DFS in good faith gave a triage idea for your concern.

You however, didn't even thank her and pointed out the obvious. Namely,
these bastards are always evolving their techniques.

2md MD is open-source and the enemy is the bastard spammers/malware
authors. Don't attack people trying to help, donating their time and
giving you possible solutions. Instead you might consider thanking
them, providing feedback or even taking a swipe at the code and post a
patch.

</rant>
KAM
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Tomasz Ostrowski
2015-04-29 10:14:52 UTC
Permalink
Post by Tomasz Ostrowski
Post by Dianne Skoll
Anyway, I made a SpamAssassin rule to block these [SecureMessage.chm].
I think this resolution is unsustainable - this technique might get
popular fast if this proves to foul filters.
(...) MD is open-source and the enemy is the bastard spammers/malware
authors. Don't attack people trying to help, donating their time and
giving you possible solutions. Instead you might consider thanking
them, providing feedback or even taking a swipe at the code and post a
patch.
I'm very sorry if I've written something rude - I didn't mean to.
English isn't my primary language - I might have failed to convey a tone
of my statement.

I just wanted to report this to mailing list because I was afraid that
other users could have their network compromised if they used similar
setup. Thanks to Dianne's test on her systems I was able to find the
cause, which was outdated perl module. I've shared my solution in a
follow-up email.

I really think MIMEdefang is an awesome, very powerful software. It's
protecting my non-profit foundation for more than 10 years. Thank you.

Regards
Tometzky
--
...although Eating Honey was a very good thing to do, there was a
moment just before you began to eat it which was better than when you
were...
Winnie the Pooh
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Dianne Skoll
2015-04-29 11:45:31 UTC
Permalink
On Wed, 29 Apr 2015 12:14:52 +0200
Post by Tomasz Ostrowski
I'm very sorry if I've written something rude - I didn't mean to.
English isn't my primary language - I might have failed to convey a
tone of my statement.
I didn't think you were rude at all; I think KAM might have overreacted
slightly. Please let's all calm down. :)
Post by Tomasz Ostrowski
I just wanted to report this to mailing list because I was afraid
that other users could have their network compromised if they used
similar setup. Thanks to Dianne's test on her systems I was able to
find the cause, which was outdated perl module. I've shared my
solution in a follow-up email.
Great, glad you resolved it!

Regards,

Dianne.
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
Kevin A. McGrail
2015-04-29 11:57:50 UTC
Permalink
Post by Tomasz Ostrowski
I'm very sorry if I've written something rude
Sorry too. I was grumpy yesterday but appreciate you apologizing about
it. I commented the same off-list yesterday but should have posted it
to the list. You very professionally posted the spample and provided
swift feedback which is better than 99% of the problem reports ;-)

regards,
KAM
_______________________________________________
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 ***@lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Loading...