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