]>
Commit | Line | Data |
---|---|---|
b780ea8d SI |
1 | # SpamAssassin rules file: header tests |
2 | # | |
3 | # Please don't modify this file as your changes will be overwritten with | |
4 | # the next update. Use /etc/mail/spamassassin/local.cf instead. | |
5 | # See 'perldoc Mail::SpamAssassin::Conf' for details. | |
6 | # | |
7 | # <@LICENSE> | |
8 | # Licensed to the Apache Software Foundation (ASF) under one or more | |
9 | # contributor license agreements. See the NOTICE file distributed with | |
10 | # this work for additional information regarding copyright ownership. | |
11 | # The ASF licenses this file to you under the Apache License, Version 2.0 | |
12 | # (the "License"); you may not use this file except in compliance with | |
13 | # the License. You may obtain a copy of the License at: | |
14 | # | |
15 | # http://www.apache.org/licenses/LICENSE-2.0 | |
16 | # | |
17 | # Unless required by applicable law or agreed to in writing, software | |
18 | # distributed under the License is distributed on an "AS IS" BASIS, | |
19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
20 | # See the License for the specific language governing permissions and | |
21 | # limitations under the License. | |
22 | # </@LICENSE> | |
23 | # | |
24 | ########################################################################### | |
25 | ||
21dcadbf | 26 | require_version 4.000000 |
b780ea8d SI |
27 | |
28 | ########################################################################### | |
29 | ||
30 | # partial messages; currently-theoretical attack | |
31 | # unsurprisingly this hits 0/0 right now. | |
32 | header FRAGMENTED_MESSAGE Content-Type =~ /\bmessage\/partial/i | |
33 | describe FRAGMENTED_MESSAGE Partial message | |
34 | tflags FRAGMENTED_MESSAGE userconf | |
35 | ||
36 | ########################################################################### | |
37 | ||
38 | header FROM_BLANK_NAME From =~ /(?:\s|^)"" <\S+>/i | |
39 | describe FROM_BLANK_NAME From: contains empty name | |
40 | ||
41 | ########################################################################### | |
42 | # numeric address rules, these are written to avoid overlap with each other | |
43 | ||
44 | header __FROM_ENDS_IN_NUMS From:addr =~ /\D\d{8,}\@/i | |
45 | ||
46 | header FROM_STARTS_WITH_NUMS From:addr =~ /^\d{3,50}[^0-9\@]/ | |
47 | describe FROM_STARTS_WITH_NUMS From: starts with several numbers | |
48 | ||
49 | # don't match US/Canada phone numbers: 10 digits optionally preceded by a "1" | |
50 | header __FROM_ALL_NUMS From:addr =~ /^(?:\d{1,9}|[02-9]\d{10}|\d{12,})@/ | |
51 | ||
52 | ########################################################################### | |
53 | ||
54 | header FROM_OFFERS From:addr =~ /\@\S*offers(?![eo]n\b)/i | |
55 | describe FROM_OFFERS From address is "at something-offers" | |
56 | ||
57 | header FROM_NO_USER From =~ /(?:^\@|<\@| \@[^\)<]*$|<>)/ [if-unset: unset@unset.unset] | |
58 | describe FROM_NO_USER From: has no local-part before @ sign | |
59 | ||
60 | # also 100% valid | |
61 | # bug 6149: avoid common .jp false positives | |
62 | header __PLING_QUERY Subject =~ /\?.*!|!.*\?/ | |
63 | meta PLING_QUERY (__PLING_QUERY && !__ISO_2022_JP_DELIM) | |
64 | describe PLING_QUERY Subject has exclamation mark and question mark | |
65 | ||
66 | ||
67 | ||
68 | ||
69 | header MSGID_SPAM_CAPS Message-ID =~ /^\s*<?[A-Z]+\@(?!(?:mailcity|whowhere)\.com)/ | |
70 | describe MSGID_SPAM_CAPS Spam tool Message-Id: (caps variant) | |
71 | ||
72 | header MSGID_SPAM_LETTERS Message-Id =~ /<[a-z]{5,}\@(\S+\.)+\S+>/ | |
73 | describe MSGID_SPAM_LETTERS Spam tool Message-Id: (letters variant) | |
74 | ||
75 | ||
76 | ||
77 | # negative lookahead exempts this MUA from circa 1997-2000 | |
78 | # X-Mailer: Microsoft Outlook Express 4.71.1712.3 | |
79 | # Message-ID: <01bd45da$2649cdc0$LocalHost@andrew> | |
80 | header __MSGID_DOLLARS_OK MESSAGEID =~ /<[0-9a-f]{4,}\$[0-9a-f]{4,}\$[0-9a-f]{4,}\@\S+>/ | |
81 | header __MSGID_DOLLARS_MAYBE MESSAGEID =~ /<\w{4,}\$\w{4,}\$(?!localhost)\w{4,}\@\S+>/i | |
82 | meta MSGID_DOLLARS_RANDOM __MSGID_DOLLARS_MAYBE && !__MSGID_DOLLARS_OK | |
83 | ||
84 | # bit of a ratware rule, but catches a bit more than just the one ratware | |
85 | header __MSGID_RANDY Message-ID =~ /<[a-z\d][a-z\d\$-]{10,29}[a-z\d]\@[a-z\d][a-z\d.]{3,12}[a-z\d]>/ | |
86 | # heuristic to eliminate most good Message-ID formats | |
87 | header __MSGID_OK_HEX Message-ID =~ /\b[a-f\d]{8}\b/ | |
88 | header __MSGID_OK_DIGITS Message-ID =~ /\d{10}/ | |
89 | header __MSGID_OK_HOST Message-ID =~ /\@(?:\D{2,}|(?:\d{1,3}\.){3}\d{1,3})>/ | |
90 | meta MSGID_RANDY (__MSGID_RANDY && !(__MSGID_OK_HEX || __MSGID_OK_DIGITS || __MSGID_OK_HOST)) | |
91 | describe MSGID_RANDY Message-Id has pattern used in spam | |
92 | ||
93 | # bug 3395 | |
94 | header MSGID_YAHOO_CAPS Message-ID =~ /<[A-Z]+\@yahoo.com>/ | |
95 | describe MSGID_YAHOO_CAPS Message-ID has ALLCAPS@yahoo.com | |
96 | ||
97 | ########################################################################### | |
98 | ||
99 | header __AT_AOL_MSGID MESSAGEID =~ /\@aol\.com\b/i | |
100 | header __FROM_AOL_COM From =~ /\@aol\.com\b/i | |
101 | meta FORGED_MSGID_AOL (__AT_AOL_MSGID && !__FROM_AOL_COM) | |
102 | describe FORGED_MSGID_AOL Message-ID is forged, (aol.com) | |
103 | ||
104 | header __AT_EXCITE_MSGID MESSAGEID =~ /\@excite\.com\b/i | |
105 | header __MY_RCVD_EXCITE Received =~ /\.excite\.com\b/i | |
106 | meta FORGED_MSGID_EXCITE (__AT_EXCITE_MSGID && !__MY_RCVD_EXCITE) | |
107 | describe FORGED_MSGID_EXCITE Message-ID is forged, (excite.com) | |
108 | ||
109 | header __AT_HOTMAIL_MSGID MESSAGEID =~ /\@hotmail\.com\b/i | |
110 | header __FROM_HOTMAIL_COM From =~ /\@hotmail\.com\b/i | |
111 | meta FORGED_MSGID_HOTMAIL (__AT_HOTMAIL_MSGID && (!__FROM_HOTMAIL_COM && !__FROM_MSN_COM && !__FROM_YAHOO_COM)) | |
112 | describe FORGED_MSGID_HOTMAIL Message-ID is forged, (hotmail.com) | |
113 | ||
114 | header __AT_MSN_MSGID MESSAGEID =~ /\@msn\.com\b/i | |
115 | header __FROM_MSN_COM From =~ /\@msn\.com\b/i | |
116 | meta FORGED_MSGID_MSN (__AT_MSN_MSGID && (!__FROM_MSN_COM && !__FROM_HOTMAIL_COM && !__FROM_YAHOO_COM)) | |
117 | describe FORGED_MSGID_MSN Message-ID is forged, (msn.com) | |
118 | ||
119 | header __AT_YAHOO_MSGID MESSAGEID =~ /\@yahoo\.com\b/i | |
120 | header __FROM_YAHOO_COM From =~ /\@yahoo\.com\b/i | |
121 | meta FORGED_MSGID_YAHOO (__AT_YAHOO_MSGID && !__FROM_YAHOO_COM) | |
122 | describe FORGED_MSGID_YAHOO Message-ID is forged, (yahoo.com) | |
123 | ||
124 | ########################################################################### | |
125 | ||
126 | header __MSGID_BEFORE_RECEIVED ALL =~ /^Message-Id:.*?^Received:/msi | |
127 | header __MSGID_BEFORE_OKAY Message-Id =~ /\@[a-z0-9.-]+\.(?:yahoo|wanadoo)(?:\.[a-z]{2,3}){1,2}>/ | |
128 | ||
129 | meta MSGID_FROM_MTA_HEADER (__MSGID_BEFORE_RECEIVED && !__MSGID_BEFORE_OKAY && !__FROM_HOTMAIL_COM) | |
130 | describe MSGID_FROM_MTA_HEADER Message-Id was added by a relay | |
131 | ||
132 | ||
133 | ||
134 | header MSGID_SHORT MESSAGEID =~ /^.{1,15}$|<.{0,4}\@/ | |
135 | describe MSGID_SHORT Message-ID is unusually short | |
136 | ||
137 | #DEMOTED TO SANDBOX - 2012-03-21 | |
138 | #header MSGID_MULTIPLE_AT MESSAGEID =~ /<[^>]*\@[^>]*\@/ | |
139 | #describe MSGID_MULTIPLE_AT Message-ID contains multiple '@' characters | |
140 | ||
141 | ########################################################################### | |
142 | ||
143 | header DATE_SPAMWARE_Y2K Date =~ /^[A-Z][a-z]{2}, \d\d [A-Z][a-z]{2} [0-6]\d \d\d:\d\d:\d\d [A-Z]{3}$/ | |
144 | describe DATE_SPAMWARE_Y2K Date header uses unusual Y2K formatting | |
145 | ||
146 | # as noted on the dev@ list, ":60" is valid for seconds when there's a leap | |
147 | # second (12/31/2005 for instance), so let's accept that as valid. ISO 8601 | |
148 | # apparently allows for it. | |
149 | # there were a few whitespace issues in the original RE, and I wanted to avoid my | |
150 | # two common, but yes invalid, date headers. specifically / \(GMT\)$/ and | |
151 | # / 0000 GMT$/. dos has / "GMT"$/ - tvd | |
152 | # 2.229 2.7267 0.0517 0.981 0.86 0.00 INVALID_DATE | |
153 | # 2.263 2.7486 0.1368 0.953 0.78 0.00 INVALID_DATE_OLD | |
154 | # | |
155 | # WRT the tests, remember that ok and fail are reversed -- so valid dates | |
156 | # should be "fail" and invalid dates should be "ok". | |
157 | header INVALID_DATE Date !~ /^\s*(?:(?i:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?\s*(?:[12]\d|3[01]|0?[1-9])\s+(?i:Jan|Feb|Ma[ry]|Apr|Ju[nl]|Aug|Sep|Oct|Nov|Dec)\s+(?:19[7-9]\d|2\d{3})\s+(?:[01]?\d|2[0-3])\:[0-5]\d(?::(?:[0-5]\d|60))?(?:\s+[AP]M)?(?:\s+(?:[+-][0-9]{4}|UT|[A-Z]{2,3}T|0000 GMT|"GMT"))?(?:\s*\(.*\))?\s*$/ [if-unset: Wed, 31 Jul 2002 16:41:57 +0200] | |
158 | describe INVALID_DATE Invalid Date: header (not RFC 2822) | |
159 | test INVALID_DATE fail Sat, 31 Dec 2005 23:59:60 -0500 | |
160 | test INVALID_DATE fail Wed, 31 Jul 2002 16:41:57 +0200 | |
161 | test INVALID_DATE fail Sat, 31 Dec 2005 23:00:00 | |
162 | test INVALID_DATE ok Sat, 31 Dec 2005 24:00:00 -0500 | |
163 | test INVALID_DATE ok Thurs, 31 Jul 2002 16:41:57 +0200 | |
164 | ||
165 | # allow +1300, NZ timezone | |
166 | header INVALID_DATE_TZ_ABSURD Date =~ /[-+](?!(?:0\d|1[0-4])(?:[03]0|[14]5))\d{4}$/ | |
167 | describe INVALID_DATE_TZ_ABSURD Invalid Date: header (timezone does not exist) | |
168 | ||
169 | header INVALID_TZ_CST ALL =~ /[+-]\d\d[30]0(?<!-0600|-0500|\+0800|\+0930|\+1030)\s+(?:\bCST\b|\(CST\))/ | |
170 | describe INVALID_TZ_CST Invalid date in header (wrong CST timezone) | |
171 | ||
172 | header INVALID_TZ_EST ALL =~ /[+-]\d\d[30]0(?<!-0500|-0300|\+1000|\+1100)\s+(?:\bEST\b|\(EST\))/ | |
173 | describe INVALID_TZ_EST Invalid date in header (wrong EST timezone) | |
174 | ||
175 | ||
176 | ########################################################################### | |
177 | # MIME encoding with spam characteristics | |
178 | ||
179 | ifplugin Mail::SpamAssassin::Plugin::HeaderEval | |
180 | meta __SUBJECT_NEEDS_MIME __SUBJ_ILLEGAL_CHARS | |
181 | endif | |
182 | ||
183 | header __SUBJECT_ENCODED_QP Subject:raw =~ /=\?\S+\?Q\?/i | |
184 | header __SUBJECT_ENCODED_B64 Subject:raw =~ /=\?\S+\?B\?/i | |
185 | ||
186 | ||
187 | ||
188 | header __FROM_NEEDS_MIME From:name:raw =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ | |
189 | header __FROM_NEEDS_MIME2 From:name =~ /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff]/ | |
190 | header __FROM_ENCODED_QP From:raw =~ /=\?\S+\?Q\?/i | |
191 | header __FROM_ENCODED_B64 From:raw =~ /=\?\S+\?B\?/i | |
192 | ||
193 | ||
194 | meta FROM_EXCESS_BASE64 __FROM_ENCODED_B64 && !__FROM_NEEDS_MIME2 | |
195 | describe FROM_EXCESS_BASE64 From: base64 encoded unnecessarily | |
196 | ||
197 | ||
198 | ########################################################################### | |
199 | # ADV tags in various languages | |
200 | ||
201 | header ENGLISH_UCE_SUBJECT Subject =~ /^[^0-9a-z]*adv(?:ert)?\b/i | |
202 | describe ENGLISH_UCE_SUBJECT Subject contains an English UCE tag | |
203 | ||
204 | # alan premselaar <alien@12inch.com>, see SpamAssassin-talk list 2003-03 | |
205 | # quinlan: 2003-03-23 here are more generic Japanese iso-2022-jp codes | |
206 | # ("not yet acceptance" or "email") + "announcement" | |
207 | # FWIW, according to Peter Evans, this should be sufficient to catch the | |
208 | # UCE tag and a common attempt at evasion (using the "sue" instead of | |
209 | # "mi" Chinese character). 2006-10-12: updated by bug 4021. | |
210 | header JAPANESE_UCE_SUBJECT Subject =~ /\e\$B.*(?:L\$>5Bz|EE;R%a!<%k)(?:8x|9-)9p/ | |
211 | describe JAPANESE_UCE_SUBJECT Subject contains a Japanese UCE tag | |
212 | ||
213 | # check body for "shou nin daku kou koku" UCE tag (bug 4021) | |
214 | body __JAPANESE_UCE_BODY /(?:L\$>5Bz|EE;R%a!<%k)(?:8x|9-)9p/ | |
215 | ||
216 | meta JAPANESE_UCE_BODY (__ISO_2022_JP_DELIM && __JAPANESE_UCE_BODY) | |
217 | describe JAPANESE_UCE_BODY Body contains Japanese UCE tag | |
218 | ||
219 | # quinlan: "advertisement" in Russian KOI8-R | |
220 | # (no longer common, but worth noting in future) | |
221 | #header RUSSIAN_UCE_SUBJECT Subject =~ /\xf0\xe5\xea\xeb\xe0\xec\xf3/ | |
222 | #describe RUSSIAN_UCE_SUBJECT Subject contains a Russian UCE tag | |
223 | ||
224 | # Korean UCE Subject: lines are usually 8-bit, but are occasionally encoded | |
225 | # with quoted-printable or base64. | |
226 | # | |
227 | # \xbc\xba\xc0\xce means "adult" | |
228 | # \xb1\xa4\xb0\xed means "advertisement" | |
229 | # \xc1\xa4\xba\xb8 means "information" | |
230 | # \xc8\xab\xba\xb8 means "publicity" | |
231 | # | |
232 | # Each two byte sequence is one Korean letter; the spaces and periods are | |
233 | # sometimes used to obscure the words. \xb1\xa4\xb0\xed is the most common | |
234 | # tag and is sometimes very obscured so we look harder. | |
235 | # | |
236 | header KOREAN_UCE_SUBJECT Subject =~ /[({[<][. ]*(?-i:\xbc\xba[. ]*\xc0\xce[. ]*)?(?-i:\xb1\xa4(?:[. ]*|[\x00-\x7f]{0,3})\xb0\xed|\xc1\xa4[. ]*\xba\xb8|\xc8\xab[. ]*\xba\xb8)[. ]*[)}\]>]/ | |
237 | describe KOREAN_UCE_SUBJECT Subject: contains Korean unsolicited email tag | |
238 | ||
239 | ########################################################################### | |
240 | ||
241 | # two reliable signatures | |
242 | header __DOUBLE_IP_SPAM_1 Received =~ /from \[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\] by \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} with/ | |
243 | header __DOUBLE_IP_SPAM_2 Received =~ /from\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+by\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3};/ | |
244 | # loose match | |
245 | header __DOUBLE_IP_LOOSE Received =~ /(?:\b(?:from|by)\b.{1,4}\b\d{1,3}[._-]\d{1,3}[._-]\d{1,3}[._-]\d{1,3}(?<!127\.0\.0\.1)\b.{0,4}){2}/i | |
246 | # spam signature | |
247 | meta RCVD_DOUBLE_IP_SPAM (__DOUBLE_IP_SPAM_1 || __DOUBLE_IP_SPAM_2) | |
248 | describe RCVD_DOUBLE_IP_SPAM Bulk email fingerprint (double IP) found | |
249 | # other matches | |
250 | meta RCVD_DOUBLE_IP_LOOSE (__DOUBLE_IP_LOOSE && !RCVD_DOUBLE_IP_SPAM) | |
251 | describe RCVD_DOUBLE_IP_LOOSE Received: by and from look like IP addresses | |
252 | ||
253 | header FORGED_TELESP_RCVD Received =~ /\.(?!br).. \(\d+-\d+-\d+-\d+\.dsl\.telesp\.net\.br / | |
254 | describe FORGED_TELESP_RCVD Contains forged hostname for a DSL IP in Brazil | |
255 | ||
256 | # forgery meta-rules: more reliable than their inputs | |
257 | meta CONFIRMED_FORGED (__FORGED_RCVD_TRAIL && (__FORGED_AOL_RCVD || __FORGED_HOTMAIL_RCVD || __FORGED_EUDORAMAIL_RCVD || FORGED_YAHOO_RCVD || __FORGED_JUNO_RCVD || FORGED_GMAIL_RCVD)) | |
258 | describe CONFIRMED_FORGED Received headers are forged | |
259 | ||
260 | meta MULTI_FORGED ((__FORGED_AOL_RCVD + __FORGED_HOTMAIL_RCVD + __FORGED_EUDORAMAIL_RCVD + FORGED_YAHOO_RCVD + __FORGED_JUNO_RCVD + FORGED_GMAIL_RCVD) > 1) | |
261 | describe MULTI_FORGED Received headers indicate multiple forgeries | |
262 | ||
263 | header NONEXISTENT_CHARSET Content-Type =~ /charset=.?DEFAULT/ | |
264 | describe NONEXISTENT_CHARSET Character set doesn't exist | |
265 | ||
266 | header __HAS_MESSAGE_ID exists:Message-Id | |
21dcadbf | 267 | priority __HAS_MESSAGE_ID -2000 # Bug 8078 |
b780ea8d SI |
268 | meta MISSING_MID !__HAS_MESSAGE_ID |
269 | describe MISSING_MID Missing Message-Id: header | |
270 | ||
271 | header __HAS_DATE exists:Date | |
21dcadbf | 272 | priority __HAS_DATE -2000 # Bug 8078 |
b780ea8d SI |
273 | meta MISSING_DATE !__HAS_DATE |
274 | describe MISSING_DATE Missing Date: header | |
275 | ||
276 | header __HAS_SUBJECT exists:Subject | |
21dcadbf | 277 | priority __HAS_SUBJECT -2000 # Bug 8078 |
b780ea8d SI |
278 | meta MISSING_SUBJECT !__HAS_SUBJECT |
279 | describe MISSING_SUBJECT Missing Subject: header | |
280 | ||
281 | # bug 6353 | |
282 | header __HAS_FROM exists:From | |
21dcadbf | 283 | priority __HAS_FROM -2000 # Bug 8078 |
b780ea8d SI |
284 | meta MISSING_FROM !__HAS_FROM |
285 | describe MISSING_FROM Missing From: header | |
286 | ||
287 | # bug 6149: avoid common .jp false positives | |
288 | header __GAPPY_SUBJECT Subject =~ /\b(?:[a-z]([-_. =~\/:,*!\@\#\$\%\^&+;\"\'<>\\])\1{0,2}){4}/i | |
289 | meta GAPPY_SUBJECT (__GAPPY_SUBJECT && !__ISO_2022_JP_DELIM) | |
290 | describe GAPPY_SUBJECT Subject: contains G.a.p.p.y-T.e.x.t | |
291 | ||
292 | ### header existence tests (description is added automatically) | |
293 | ||
294 | # X-Fix example: NTMail fixed non RFC822 compliant EMail message | |
295 | # | |
296 | # X-PMFLAGS is all caps | |
297 | # | |
298 | # Headers that seem to only be used by a single spamming software and | |
299 | # are found together in the same message: | |
300 | # 1. X-MailingID and X-ServerHost | |
301 | # 2. X-Stormpost-To and X-List-Unsubscribe | |
302 | # | |
303 | # not spammish: X-EM-Registration, X-EM-Version, X-Antiabuse, X-List-Host, | |
304 | # X-Message-Id | |
305 | # bad FP rate: Comment, Date-warning | |
306 | ||
307 | header PREVENT_NONDELIVERY exists:Prevent-NonDelivery-Report | |
308 | describe PREVENT_NONDELIVERY Message has Prevent-NonDelivery-Report header | |
309 | ||
310 | header X_IP exists:X-IP | |
311 | describe X_IP Message has X-IP header | |
312 | ||
313 | header __HAS_MIMEOLE exists:X-MimeOLE | |
314 | header __HAS_MSMAIL_PRI exists:X-MSMail-Priority | |
315 | header __HAS_SQUIRRELMAIL_IN_MAILER X-Mailer =~ /SquirrelMail\b/ | |
316 | # Ever growing Office version list without X-MimeOLE, bug 6346, 7122, 7463. | |
317 | header __HAS_OFFICE1214_IN_MAILER X-Mailer =~ /^Microsoft (?:Office )?Outlook 1[2456]\.0/ | |
318 | # CGP MAPI module fingerprint, to protect from MISSING_MIMEOLE | |
319 | header __HAS_CGP_MAPI_IN_MAILER X-Mailer =~ /CommuniGate Pro MAPI/ | |
320 | meta MISSING_MIMEOLE (__HAS_MSMAIL_PRI && !__HAS_MIMEOLE && !__HAS_SQUIRRELMAIL_IN_MAILER && !__HAS_OFFICE1214_IN_MAILER && !__HAS_CGP_MAPI_IN_MAILER && !__HDR_RCVD_TONLINEDE && !__MIME_BASE64 && !__DKIM_EXISTS) | |
321 | describe MISSING_MIMEOLE Message has X-MSMail-Priority, but no X-MimeOLE | |
322 | ||
323 | header __HAS_X_MAILER exists:X-Mailer | |
324 | ||
325 | header __IS_EXCH X-MimeOLE =~ /Produced By Microsoft Exchange V/ | |
326 | ||
327 | header SUBJ_AS_SEEN Subject =~ /\bAs Seen/i | |
328 | describe SUBJ_AS_SEEN Subject contains "As Seen" | |
329 | ||
330 | header SUBJ_DOLLARS Subject =~ /^\$[0-9.,]+\b/ | |
331 | describe SUBJ_DOLLARS Subject starts with dollar amount | |
332 | ||
333 | ||
334 | ||
335 | ||
336 | ||
337 | ||
338 | #DISABLING DUE TO POOR S/O 2012-09-27 | |
339 | #header SUBJ_YOUR_DEBT Subject =~ /Your (?:Bills|Debt|Credit)/i | |
340 | #describe SUBJ_YOUR_DEBT Subject contains "Your Bills" or similar | |
341 | ||
342 | header SUBJ_YOUR_FAMILY Subject =~ /Your Family/i | |
343 | describe SUBJ_YOUR_FAMILY Subject contains "Your Family" | |
344 | ||
345 | ||
346 | # the real services never HELO as 'foo.com', instead 'mail.foo.com' or | |
347 | # something like that. Note: be careful when expanding this... legit dotcom | |
348 | # HELOers include: hotmail.com, drizzle.com, lockergnome.com. | |
349 | header RCVD_FAKE_HELO_DOTCOM Received =~ /^from (?:msn|yahoo|yourwebsite|lycos|excite|cs|aol|localhost|koreanmail|allexecs|mydomain|juno|eudoramail|compuserve|desertmail|excite|caramail)\.com \(/m | |
350 | describe RCVD_FAKE_HELO_DOTCOM Received contains a faked HELO hostname | |
351 | ||
352 | header SUBJECT_DIET Subject =~ /\bLose .*(?:pounds|lbs|weight)/i | |
353 | describe SUBJECT_DIET Subject talks about losing pounds | |
354 | ||
355 | ||
356 | # MIME boundary tests; spam tools use distinctive patterns. | |
357 | header MIME_BOUND_DD_DIGITS Content-Type =~ /boundary=\"--\d+\"/ | |
358 | describe MIME_BOUND_DD_DIGITS Spam tool pattern in MIME boundary | |
359 | header MIME_BOUND_DIGITS_15 Content-Type =~ /boundary=\"\d{15,}\"/ | |
360 | describe MIME_BOUND_DIGITS_15 Spam tool pattern in MIME boundary | |
361 | header MIME_BOUND_MANY_HEX Content-Type =~ /boundary="[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}"/ | |
362 | describe MIME_BOUND_MANY_HEX Spam tool pattern in MIME boundary | |
363 | ||
364 | # note: the first alternation is anchored for speed | |
365 | header TO_MALFORMED To !~ /(?:^|[^\S"])(?:(?:\"[^\"]+\"|\S+)\@\S+\.\S+|^\s*.+:\s*;|^\s*\"[^\"]+\":\s*;|^\s*\([^\)]*\)\s*$|<\S+(?:\!\S+){1,}>|^\s*$)/ [if-unset: unset@unset.unset] | |
366 | describe TO_MALFORMED To: has a malformed address | |
367 | ||
368 | header __CD exists:Content-Disposition | |
369 | header __CT exists:Content-Type | |
370 | header __CTE exists:Content-Transfer-Encoding | |
371 | header __MIME_VERSION exists:MIME-Version | |
372 | header __CT_TEXT_PLAIN Content-Type =~ /^text\/plain\b/i | |
373 | meta MIME_HEADER_CTYPE_ONLY (!__CD && !__CTE && __CT && !__MIME_VERSION && !__CT_TEXT_PLAIN) | |
374 | describe MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME headers | |
375 | ||
376 | header WITH_LC_SMTP Received =~ /\swith\ssmtp;\s/ | |
377 | describe WITH_LC_SMTP Received line contains spam-sign (lowercase smtp) | |
378 | ||
379 | ||
380 | header SUBJ_BUY Subject =~ /^buy/i | |
381 | describe SUBJ_BUY Subject line starts with Buy or Buying | |
382 | ||
383 | # seems to be ratware | |
384 | header RCVD_AM_PM Received =~ /; [A-Z][a-z][a-z], \d{1,2} \d{4} \d{1,2}:\d\d:\d\d [AP]M [+-]\d{4}/ | |
385 | describe RCVD_AM_PM Received headers forged (AM/PM) | |
386 | ||
387 | header __USER_AGENT_MSN X-Mailer =~ /^MSN Explorer / | |
388 | ||
389 | # host no longer exists according to administrator | |
390 | header FAKE_OUTBLAZE_RCVD Received =~ /\.mr\.outblaze\.com/ | |
391 | describe FAKE_OUTBLAZE_RCVD Received header contains faked 'mr.outblaze.com' | |
392 | ||
393 | ||
394 | # thanks to David Ritz for passing this on | |
395 | header UNCLOSED_BRACKET ALL =~ /\[\d+\r?\n/s | |
396 | describe UNCLOSED_BRACKET Headers contain an unclosed bracket | |
397 | ||
398 | header FROM_DOMAIN_NOVOWEL From =~ /\@\S*[bcdfgjklmnpqrstvwxz]{7}/i | |
399 | describe FROM_DOMAIN_NOVOWEL From: domain has series of non-vowel letters | |
400 | tflags FROM_DOMAIN_NOVOWEL userconf # lock scores low | |
401 | ||
402 | header FROM_LOCAL_NOVOWEL From =~ /[bcdfgjklmnpqrstvwxz]{7}\S*\@/i | |
403 | describe FROM_LOCAL_NOVOWEL From: localpart has series of non-vowel letters | |
404 | tflags FROM_LOCAL_NOVOWEL userconf # lock scores low | |
405 | ||
406 | header FROM_LOCAL_HEX From =~ /[0-9a-f]{11}\S*\@/i | |
407 | describe FROM_LOCAL_HEX From: localpart has long hexadecimal sequence | |
408 | ||
409 | header FROM_LOCAL_DIGITS From =~ /\d{11}\S*\@/i | |
410 | describe FROM_LOCAL_DIGITS From: localpart has long digit sequence | |
411 | ||
412 | header __TOCC_EXISTS exists:ToCc | |
413 | ||
fc5290a3 | 414 | header X_PRIORITY_CC ALL =~ /^X-Priority:.*?^Cc:/msi |
b780ea8d SI |
415 | describe X_PRIORITY_CC Cc: after X-Priority: (bulk email fingerprint) |
416 | ||
417 | # catch non-RFC2047 compliant messages | |
418 | # Apple Mail has a bug where headers will have whitespace around the encoded | |
419 | # text, so try to ignore that | |
420 | header BAD_ENC_HEADER ALL:raw =~ /=\?[^?\s]+\?[^?\s]\?\s*[^?]+\s(?!\?=)/ | |
421 | describe BAD_ENC_HEADER Message has bad MIME encoding in the header | |
422 | ||
423 | ||
424 | header __ML1 Precedence =~ m{\b(list|bulk)\b}i | |
46cfc9e2 | 425 | meta __ML2 __HAS_LIST_ID |
b780ea8d SI |
426 | header __ML3 exists:List-Post |
427 | header __ML4 exists:Mailing-List | |
428 | header __ML5 Return-Path:addr =~ m{^([^\@]+-(request|bounces|admin|owner)|owner-[^\@]+)(\@|\z)}i | |
429 | meta __VIA_ML __ML1 || __ML2 || __ML3 || __ML4 || __ML5 | |
430 | describe __VIA_ML Mail from a mailing list | |
431 | ||
432 | ||
433 | # some clueless mailing lists (like zmailer with an RFC822TABS option on) | |
434 | # are replacing a leading space by a TAB in header fields From, To, | |
435 | # Cc, Date (Bug 6429) | |
436 | header __ML_TURNS_SP_TO_TAB Received =~ /\(ORCPT <rfc822;/ | |
437 | describe __ML_TURNS_SP_TO_TAB A mailing list changing a space to a TAB | |
438 | ||
439 | ||
440 | # must keep it in sync with https://www.iana.org/assignments/ipv4-address-space/ | |
441 | header RCVD_ILLEGAL_IP X-Spam-Relays-Untrusted =~ / (?:by|ip)=(?=\d+\.\d+\.\d+\.\d+ )(?:(?:0|2(?:2[4-9]|[3-5]\d)|192\.0\.2|198\.51\.100|203\.0\.113)\.|(?:\d+\.){0,3}(?!(?:2(?:[0-4]\d|5[0-5])|[01]?\d\d?)\b))/ | |
442 | describe RCVD_ILLEGAL_IP Received: contains illegal IP address | |
443 | ||
444 | ||
445 | ########################################################################### | |
446 | ||
447 | ifplugin Mail::SpamAssassin::Plugin::HeaderEval | |
448 | ||
449 | header __FORGED_AOL_RCVD eval:check_for_fake_aol_relay_in_rcvd() | |
450 | ||
451 | header CHARSET_FARAWAY_HEADER eval:check_for_faraway_charset_in_headers() | |
452 | describe CHARSET_FARAWAY_HEADER A foreign language charset used in headers | |
453 | tflags CHARSET_FARAWAY_HEADER userconf | |
454 | ||
455 | ################################################################### | |
456 | ||
457 | # illegal characters that should be MIME encoded | |
458 | # might want to exempt users using languages that don't use Latin | |
459 | # alphabets, but do it in the eval | |
460 | ||
46cfc9e2 SI |
461 | # Will FP without 4.0 and UTF-8 support |
462 | if (version >= 4.000000) | |
463 | header __SUBJ_ILLEGAL_CHARS eval:check_illegal_chars('Subject','0.00','2') | |
464 | meta SUBJ_ILLEGAL_CHARS (__SUBJ_ILLEGAL_CHARS && !__FROM_YAHOO_COM) | |
465 | header FROM_ILLEGAL_CHARS eval:check_illegal_chars('From','0.20','2') | |
466 | header __HEAD_ILLEGAL_CHARS eval:check_illegal_chars('ALL','0.010','2') | |
467 | meta HEAD_ILLEGAL_CHARS __HEAD_ILLEGAL_CHARS && !__SUBJ_ILLEGAL_CHARS && !FROM_ILLEGAL_CHARS | |
468 | endif | |
469 | if (version < 4.000000) | |
470 | meta __SUBJ_ILLEGAL_CHARS 0 | |
471 | meta SUBJ_ILLEGAL_CHARS 0 | |
472 | meta FROM_ILLEGAL_CHARS 0 | |
473 | meta __HEAD_ILLEGAL_CHARS 0 | |
474 | meta HEAD_ILLEGAL_CHARS 0 | |
475 | endif | |
b780ea8d | 476 | |
46cfc9e2 | 477 | describe SUBJ_ILLEGAL_CHARS Subject: has too many raw illegal characters |
b780ea8d | 478 | describe FROM_ILLEGAL_CHARS From: has too many raw illegal characters |
b780ea8d SI |
479 | describe HEAD_ILLEGAL_CHARS Headers have too many raw illegal characters |
480 | ||
481 | ################################################################### | |
482 | ||
483 | # a forged Hotmail message; host HELO'd as hotmail.com, but it wasn't | |
484 | header __FORGED_HOTMAIL_RCVD eval:check_for_forged_hotmail_received_headers() | |
485 | ||
486 | # this, by comparison is more common: from was @hotmail.com, but it wasn't | |
487 | header FORGED_HOTMAIL_RCVD2 eval:check_for_no_hotmail_received_headers() | |
488 | describe FORGED_HOTMAIL_RCVD2 hotmail.com 'From' address, but no 'Received:' | |
489 | ||
490 | header __FORGED_EUDORAMAIL_RCVD eval:check_for_forged_eudoramail_received_headers() | |
491 | ||
492 | header FORGED_YAHOO_RCVD eval:check_for_forged_yahoo_received_headers() | |
493 | describe FORGED_YAHOO_RCVD 'From' yahoo.com does not match 'Received' headers | |
494 | ||
495 | if (version >= 3.004002) | |
496 | header FORGED_GMAIL_RCVD eval:check_for_forged_gmail_received_headers() | |
497 | describe FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received' headers | |
498 | endif | |
499 | ||
500 | header __FORGED_JUNO_RCVD eval:check_for_forged_juno_received_headers() | |
501 | ||
502 | ||
503 | ||
504 | header SORTED_RECIPS eval:sorted_recipients() | |
505 | describe SORTED_RECIPS Recipient list is sorted by address | |
506 | ||
507 | header SUSPICIOUS_RECIPS eval:similar_recipients('0.65','undef') | |
508 | describe SUSPICIOUS_RECIPS Similar addresses in recipient list | |
509 | ||
510 | # this is a quite common false positive, as it's legal to remove a To but leave | |
511 | # a CC. so don't score it high. | |
512 | header MISSING_HEADERS eval:check_for_missing_to_header() | |
513 | describe MISSING_HEADERS Missing To: header | |
514 | ||
515 | header DATE_IN_PAST_03_06 eval:check_for_shifted_date('-6', '-3') | |
516 | describe DATE_IN_PAST_03_06 Date: is 3 to 6 hours before Received: date | |
517 | ||
518 | header DATE_IN_PAST_06_12 eval:check_for_shifted_date('-12', '-6') | |
519 | describe DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date | |
520 | ||
521 | header DATE_IN_PAST_12_24 eval:check_for_shifted_date('-24', '-12') | |
522 | describe DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date | |
523 | ||
524 | header DATE_IN_PAST_24_48 eval:check_for_shifted_date('-48', '-24') | |
525 | describe DATE_IN_PAST_24_48 Date: is 24 to 48 hours before Received: date | |
526 | ||
527 | ||
528 | header DATE_IN_PAST_96_XX eval:check_for_shifted_date('undef', '-96') | |
529 | describe DATE_IN_PAST_96_XX Date: is 96 hours or more before Received: date | |
530 | ||
531 | header DATE_IN_FUTURE_03_06 eval:check_for_shifted_date('3', '6') | |
532 | describe DATE_IN_FUTURE_03_06 Date: is 3 to 6 hours after Received: date | |
533 | ||
534 | header DATE_IN_FUTURE_06_12 eval:check_for_shifted_date('6', '12') | |
535 | describe DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date | |
536 | ||
537 | header DATE_IN_FUTURE_12_24 eval:check_for_shifted_date('12', '24') | |
538 | describe DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date | |
539 | ||
540 | header DATE_IN_FUTURE_24_48 eval:check_for_shifted_date('24', '48') | |
541 | describe DATE_IN_FUTURE_24_48 Date: is 24 to 48 hours after Received: date | |
542 | ||
543 | header DATE_IN_FUTURE_48_96 eval:check_for_shifted_date('48', '96') | |
544 | describe DATE_IN_FUTURE_48_96 Date: is 48 to 96 hours after Received: date | |
545 | ||
546 | #header DATE_IN_FUTURE_96_XX eval:check_for_shifted_date('96', 'undef') | |
547 | meta DATE_IN_FUTURE_96_XX (0) | |
548 | describe DATE_IN_FUTURE_96_XX Date: is 96 hours or more after Received: date | |
549 | ||
550 | header UNRESOLVED_TEMPLATE eval:check_unresolved_template() | |
551 | describe UNRESOLVED_TEMPLATE Headers contain an unresolved template | |
552 | ||
553 | header SUBJ_ALL_CAPS eval:subject_is_all_caps() | |
554 | describe SUBJ_ALL_CAPS Subject is all capitals | |
555 | ||
556 | ||
557 | header LOCALPART_IN_SUBJECT eval:check_for_to_in_subject('user') | |
558 | describe LOCALPART_IN_SUBJECT Local part of To: address appears in Subject | |
559 | ||
560 | header MSGID_OUTLOOK_INVALID eval:check_outlook_message_id() | |
561 | describe MSGID_OUTLOOK_INVALID Message-Id is fake (in Outlook Express format) | |
562 | ||
563 | header HEADER_COUNT_CTYPE eval:check_header_count_range('Content-Type','2','999') | |
564 | describe HEADER_COUNT_CTYPE Multiple Content-Type headers found | |
565 | ||
566 | endif | |
567 | ||
568 | ########################################################################### | |
569 | ||
570 | ifplugin Mail::SpamAssassin::Plugin::MIMEEval | |
571 | ||
572 | # this is also mostly-theoretical, so allow 0 hits | |
573 | header HEAD_LONG eval:check_msg_parse_flags('truncated_header') | |
574 | describe HEAD_LONG Message headers are very long | |
575 | tflags HEAD_LONG userconf | |
576 | ||
577 | header MISSING_HB_SEP eval:check_msg_parse_flags('missing_head_body_separator') | |
578 | describe MISSING_HB_SEP Missing blank line between message header and body | |
579 | tflags MISSING_HB_SEP userconf | |
580 | ||
581 | endif | |
582 | ||
583 | ########################################################################### | |
584 | ||
585 | ifplugin Mail::SpamAssassin::Plugin::RelayEval | |
586 | ||
587 | header __UNPARSEABLE_RELAY_COUNT eval:check_relays_unparseable() | |
588 | tflags __UNPARSEABLE_RELAY_COUNT userconf | |
589 | ||
590 | meta UNPARSEABLE_RELAY (__UNPARSEABLE_RELAY_COUNT >= 1) | |
591 | tflags UNPARSEABLE_RELAY userconf | |
592 | describe UNPARSEABLE_RELAY Informational: message has unparseable relay lines | |
593 | ||
594 | ||
595 | header RCVD_HELO_IP_MISMATCH eval:helo_ip_mismatch() | |
596 | describe RCVD_HELO_IP_MISMATCH Received: HELO and IP do not match, but should | |
597 | ||
598 | # not used directly right now due to FPs; but CONFIRMED_FORGED turns it | |
599 | # into a 1.0 S/O rule anyway, so that's not a problem ;) | |
600 | # 2.626 3.6340 1.5251 0.704 0.34 1.44 FORGED_RCVD_TRAIL | |
601 | # 0.956 3.3890 0.0000 1.000 0.98 4.30 CONFIRMED_FORGED | |
602 | header __FORGED_RCVD_TRAIL eval:check_for_forged_received_trail() | |
603 | ||
604 | header NO_RDNS_DOTCOM_HELO eval:check_for_no_rdns_dotcom_helo() | |
605 | describe NO_RDNS_DOTCOM_HELO Host HELO'd as a big ISP, but had no rDNS | |
606 | ||
607 | endif | |
608 | ||
609 | ifplugin Mail::SpamAssassin::Plugin::HeaderEval | |
610 | ||
611 | header __ENV_AND_HDR_FROM_MATCH eval:check_for_matching_env_and_hdr_from() | |
612 | ||
613 | endif | |
614 |