3 # $Id: system_filter.exim,v 1.2 2001/05/10 11:35:45 nigel Exp $
5 ## If you haven't worked with exim filters before, read
6 ## the install notes at the end of this file.
9 # Only run any of this stuff on the first pass through the
10 # filter - this is an optomisation for messages that get
11 # queued and have several delivery attempts
13 # we express this in reverse so we can just bail out
14 # on inappropriate messages
21 # Check for MS buffer overruns as per latest BUGTRAQ.
22 # http://www.securityfocus.com/frames/?content=/templates/article.html%3Fid%3D61
23 # This could happen in error messages, hence its placing
25 # We substract the first n characters of the date header
26 # and test if its the same as the date header... which
27 # is a lousy way of checking if the date is longer than
29 if ${length_80:$header_date:} is not $header_date:
31 fail text "This message has been rejected because it has\n\
32 \tan overlength date field which can be used\n\
33 \tto subvert Microsoft mail programs\n\
34 \tThe following URL has further information\n\
35 \thttp://www.securityfocus.com/frames/?content=/templates/article.html%3Fid%3D61"
39 # This is a nasty compromise.
40 # This crud is now being sent with a <> envelope sender, but
41 # blocking all error messages that pattern match prevents
42 # bounces getting back.... so we fudge it somewhat
43 if $header_from: contains "@sexyfun.net"
45 fail text "This message has been rejected since it has\n\
46 \tthe signature of a known virus in the header."
49 if error_message and $header_from: contains "Mailer-Daemon@"
51 # looks like a real error message - just ignore it
55 # Look for single part MIME messages with suspicious name extensions
56 # Check Content-Type header using quoted filename [content_type_quoted_fn_match]
57 if $header_content-type: matches "(?:file)?name=(\"[^\"]+\\\\.(?:vb[se]|ws[fh]|jse?|exe|com|cmd|shs|hta|bat|scr|pif)\")"
59 fail text "This message has been rejected because it has\n\
60 \tpotentially executable content $1\n\
61 \tThis form of attachment has been used by\n\
62 \trecent viruses or other malware.\n\
63 \tIf you meant to send this file then please\n\
64 \tpackage it up as a zip file and resend it."
67 # same again using unquoted filename [content_type_unquoted_fn_match]
68 if $header_content-type: matches "(?:file)?name=([\\\\w.-]+\\\\.(?:vb[se]|ws[fh]|jse?|exe|com|cmd|shs|hta|bat|scr|pif))"
70 fail text "This message has been rejected because it has\n\
71 \tpotentially executable content $1\n\
72 \tThis form of attachment has been used by\n\
73 \trecent viruses or other malware.\n\
74 \tIf you meant to send this file then please\n\
75 \tpackage it up as a zip file and resend it."
80 # Attempt to catch embedded VBS attachments
81 # in emails. These were used as the basis for
82 # the ILOVEYOU virus and its variants
83 # Quoted filename - [body_quoted_fn_match]
84 if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w-]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[0-7]{3,4}(?>\\\\s+))(\"[^\"]+\\\\.(?:vb[se]|ws[fh]|jse?|exe|com|cmd|shs|hta|bat|scr|pif)\")[\\\\s;]"
86 fail text "This message has been rejected because it has\n\
87 \ta potentially executable attachment $1\n\
88 \tThis form of attachment has been used by\n\
89 \trecent viruses or other malware.\n\
90 \tIf you meant to send this file then please\n\
91 \tpackage it up as a zip file and resend it."
94 # same again using unquoted filename [body_unquoted_fn_match]
95 if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w-]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[0-7]{3,4}(?>\\\\s+))([\\\\w.-]+\\\\.(?:vb[se]|ws[fh]|jse?|exe|com|cmd|shs|hta|bat|scr|pif))[\\\\s;]"
97 fail text "This message has been rejected because it has\n\
98 \ta potentially executable attachment $1\n\
99 \tThis form of attachment has been used by\n\
100 \trecent viruses or other malware.\n\
101 \tIf you meant to send this file then please\n\
102 \tpackage it up as a zip file and resend it."
111 # Widened list of content-types accepted, added WSF extension
113 # Embedded the install notes in for those that don't do manuals
115 # Check global content-type header. Efficiency mods to REs
117 # More minor efficiency mods, doc changes
119 # Added extension handling - thx to Douglas Gray Stephens & Jeff Carnahan
121 # Latest MS Outhouse bug catching
123 # Changed trigger length to 80 chars, fixed some spelling
124 # 0.09 29 September 2000
125 # More extensions... its getting so we should just allow 2 or 3 through
126 # 0.10 18 January 2001
127 # Removed exclusion for error messages - this is a little nasty
128 # since it has other side effects, hence we do still exclude
129 # on unix like error messages
130 # 0.11 20 March, 2001
131 # Added CMD extension, tidied docs slightly, added RCS tag
132 # ** Missed changing version number at top of file :-(
134 # Added HTA extension
138 # Exim filters run the exim filter language - a very primitive
139 # scripting language - in place of a user .forward file, or on
140 # a per system basis (on all messages passing through).
141 # The filtering capability is documented in the main set of manuals
142 # a copy of which can be found on the exim web site
143 # http://www.exim.org/
145 # To install, copy the filter file (with appropriate permissions)
146 # to /etc/exim/system_filter.exim and add to your exim config file
147 # [location is installation depedant - typicaly /etc/exim/config ]
148 # at the top the line:-
149 # message_filter = /etc/exim/system_filter.exim
150 # message_body_visible = 5000
152 # You may also want to set the message_filter_user & message_filter_group
153 # options, but they default to the standard exim user and so can
154 # be left untouched. The other message_filter_* options are only
155 # needed if you modify this to do other functions such as deliveries.
156 # The main exim documentation is quite thorough and so I see no need
157 # to expand it here...
159 # Any message that matches the filter will then be bounced.
160 # If you wish you can change the error message by editing it
161 # in the section above - however be careful you don't break it.
163 # After install exim should be restarted - a kill -HUP to the
164 # daemon will do this.
168 # This filter tries to parse MIME with a regexp... that doesn't
169 # work too well. It will also only see the amount of the body
170 # specified in message_body_visible
174 # The regexp that is used to pickup MIME/uuencoded parts is replicated
175 # below (in perl format). You need to remember that exim converts
176 # newlines to spaces in the message_body variable.
178 # (?:Content- # start of content header
179 # (?:Type: (?>\s*) # rest of c/t header
180 # [\w-]+/[\w-]+ # content-type (any)
181 # |Disposition: (?>\s*) # content-disposition hdr
182 # attachment) # content-disposition
183 # ;(?>\s*) # ; space or newline
184 # (?:file)?name= # filename=/name=
185 # |begin (?>\s+) [0-7]{3,4} (?>\s+)) # begin octal-mode
186 # (\"[^\"]+\. # quoted filename.
187 # (?:vb[se] # list of extns
199 # |[\w.-]+\. # unquoted filename.ext
200 # (?:vb[se] # list of extns
211 # ) # end of filename capture
212 # [\s;] # trailing ;/space/newline