1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx B
\bBa
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br H
\bHo
\bow
\bwt
\bto
\bo
3 -------------------------------------------------------------------------------
5 O
\bOv
\bve
\ber
\brv
\bvi
\bie
\bew
\bw
7 This document describes features that require Postfix version 2.0 or later.
9 Topics covered in this document:
11 * What is backscatter mail?
12 * How do I block backscatter mail to random recipient addresses?
13 * How do I block backscatter mail to real recipient addresses?
15 o Blocking backscatter mail with forged mail server information
16 o Blocking backscatter mail with forged sender information
17 o Blocking backscatter mail with other forged information
18 o Blocking backscatter mail from virus scanners
20 The examples use Perl Compatible Regular Expressions (Postfix pcre: tables),
21 but also provide a translation to POSIX regular expressions (Postfix regexp:
22 tables). PCRE is preferred primarily because the implementation is often
25 W
\bWh
\bha
\bat
\bt i
\bis
\bs b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl?
\b?
27 When a spammer or worm sends mail with forged sender addresses, innocent sites
28 are flooded with undeliverable mail notifications. This is called backscatter
29 mail. With Postfix, you know that you're a backscatter victim when your logfile
30 goes on and on like this:
32 Dec 4 04:30:09 hostname postfix/smtpd[58549]: NOQUEUE: reject:
33 RCPT from xxxxxxx[x.x.x.x]: 550 5.1.1 <yyyyyy@your.domain.here>:
34 Recipient address rejected: User unknown; from=<>
35 to=<yyyyyy@your.domain.here> proto=ESMTP helo=<zzzzzz>
37 What you see are lots of "user unknown" errors with "from=<>". These are error
38 reports from MAILER-DAEMONs elsewhere on the Internet.
40 H
\bHo
\bow
\bw d
\bdo
\bo I
\bI b
\bbl
\blo
\boc
\bck
\bk b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl t
\bto
\bo r
\bra
\ban
\bnd
\bdo
\bom
\bm r
\bre
\bec
\bci
\bip
\bpi
\bie
\ben
\bnt
\bt a
\bad
\bdd
\bdr
\bre
\bes
\bss
\bse
\bes
\bs?
\b?
42 If your machine receives backscatter mail to random addresses, configure
43 Postfix to reject all mail for non-existent recipients as described in the
44 LOCAL_RECIPIENT_README and STANDARD_CONFIGURATION_README documentation.
46 If your machine runs Postfix 2.0 and earlier, disable the "pause before reject"
47 feature in the SMTP server. If your system is under stress then it should not
51 # Not needed with Postfix 2.1 and later.
52 smtpd_error_sleep_time = 0
54 # Not needed with Postfix 2.4 and later.
55 unknown_local_recipient_reject_code = 550
57 H
\bHo
\bow
\bw d
\bdo
\bo I
\bI b
\bbl
\blo
\boc
\bck
\bk b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl t
\bto
\bo r
\bre
\bea
\bal
\bl r
\bre
\bec
\bci
\bip
\bpi
\bie
\ben
\bnt
\bt a
\bad
\bdd
\bdr
\bre
\bes
\bss
\bse
\bes
\bs?
\b?
59 When backscatter mail passes the "unknown recipient" barrier, there still is no
60 need to despair. Many mail systems are kind enough to attach the message
61 headers of the undeliverable mail in the non-delivery notification. These
62 message headers contain information that you can use to recognize and block
65 B
\bBl
\blo
\boc
\bck
\bki
\bin
\bng
\bg b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl w
\bwi
\bit
\bth
\bh f
\bfo
\bor
\brg
\bge
\bed
\bd m
\bma
\bai
\bil
\bl s
\bse
\ber
\brv
\bve
\ber
\br i
\bin
\bnf
\bfo
\bor
\brm
\bma
\bat
\bti
\bio
\bon
\bn
67 Although my email address is "wietse@porcupine.org", all my mail systems
68 announce themselves with the SMTP HELO command as "hostname.porcupine.org".
69 Thus, if returned mail has a Received: message header like this:
71 Received: from porcupine.org ...
73 Then I know that this is almost certainly forged mail (almost; see next section
74 for the fly in the ointment). Mail that is really sent by my systems looks like
77 Received: from hostname.porcupine.org ...
79 For the same reason the following message headers are very likely to be the
82 Received: from host.example.com ([1.2.3.4] helo=porcupine.org) ...
83 Received: from [1.2.3.4] (port=12345 helo=porcupine.org) ...
84 Received: from host.example.com (HELO porcupine.org) ...
85 Received: from host.example.com (EHLO porcupine.org) ...
87 Some forgeries show up in the way that a mail server reports itself in
88 Received: message headers. Keeping in mind that all my systems have a mail
89 server name of hostname.porcupine.org, the following is definitely a forgery:
91 Received: by porcupine.org ...
92 Received: from host.example.com ( ... ) by porcupine.org ...
94 Another frequent sign of forgery is the Message-ID: header. My systems produce
95 a Message-ID: of <stuff@hostname.porcupine.org>. The following are forgeries,
96 especially the first one:
98 Message-ID: <1cb479435d8eb9.2beb1.qmail@porcupine.org>
99 Message-ID: <yulszqocfzsficvzzju@porcupine.org>
101 To block such backscatter I use header_checks and body_checks patterns like
104 /etc/postfix/main.cf:
105 header_checks = pcre:/etc/postfix/header_checks
106 body_checks = pcre:/etc/postfix/body_checks
108 /etc/postfix/header_checks:
110 /^Received: +from +(porcupine\.org) +/
111 reject forged client name in Received: header: $1
112 /^Received: +from +[^ ]+ +\(([^ ]+ +[he]+lo=|[he]+lo +)
114 reject forged client name in Received: header: $2
115 /^Received:.* +by +(porcupine\.org)\b/
116 reject forged mail server name in Received: header: $1
118 /^Message-ID:.* <!&!/ DUNNO
119 /^Message-ID:.*@(porcupine\.org)/
120 reject forged domain name in Message-ID: header: $1
122 /etc/postfix/body_checks:
124 /^[> ]*Received: +from +(porcupine\.org) /
125 reject forged client name in Received: header: $1
126 /^[> ]*Received: +from +[^ ]+ +\(([^ ]+ +[he]+lo=|[he]+lo +)
128 reject forged client name in Received: header: $2
129 /^[> ]*Received:.* +by +(porcupine\.org)\b/
130 reject forged mail server name in Received: header: $1
132 /^[> ]*Message-ID:.* <!&!/ DUNNO
133 /^[> ]*Message-ID:.*@(porcupine\.org)/
134 reject forged domain name in Message-ID: header: $1
138 * The example uses pcre: tables mainly for speed; with minor modifications,
139 you can use regexp: tables as explained below.
141 * The example is simplified for educational purposes. In reality my patterns
142 list multiple domain names, as "(domain|domain|...)".
144 * The "\." matches "." literally. Without the "\", the "." would match any
147 * The "\(" and "\)" match "(" and ")" literally. Without the "\", the "(" and
148 ")" would be grouping operators.
150 * The "\b" is used here to match the end of a word. If you use regexp:
151 tables, specify "[[:>:]]" (on some systems you should specify "\>" instead;
152 for details see your system documentation).
154 * The "if /pattern/" and "endif" eliminate unnecessary matching attempts. DO
155 NOT indent lines starting with /pattern/ between the "if" and "endif"!
157 * The two "Message-ID:.* <!&!" rules are workarounds for some versions of
158 Outlook express, as described in the caveats section below.
160 C
\bCa
\bav
\bve
\bea
\bat
\bts
\bs
162 * Netscape Messenger (and reportedly, Mozilla) sends a HELO name that is
163 identical to the sender address domain part. If you have such clients then
164 the above patterns would block legitimate email.
166 My network has only one such machine, and to prevent its mail from being
167 blocked I have configured it to send mail as user@hostname.porcupine.org.
168 On the Postfix server, a canonical mapping translates this temporary
169 address into user@porcupine.org.
171 /etc/postfix/main.cf:
172 canonical_maps = hash:/etc/postfix/canonical
174 /etc/postfix/canonical:
175 @hostname.porcupine.org @porcupine.org
177 This is of course practical only when you have very few systems that send
178 HELO commands like this, and when you never have to send mail to a user on
181 An alternative would be to remove the hostname from
182 "hostname.porcupine.org" with address masquerading, as described in the
183 ADDRESS_REWRITING_README document.
185 * Reportedly, Outlook 2003 (perhaps Outlook Express, and other versions as
186 well) present substantially different Message-ID headers depending upon
187 whether or not a DSN is requested (via Options "Request a delivery receipt
190 When a DSN is requested, Outlook 2003 uses a Message-ID string that ends in
191 the sender's domain name:
193 Message-ID: <!&! ...very long string... ==@example.com>
195 where example.com is the domain name part of the email address specified in
196 Outlook's account settings for the user. Since many users configure their
197 email addresses as username@example.com, messages with DSN turned on will
198 trigger the REJECT action in the previous section.
200 If you have such clients then you can to exclude their Message-ID strings
201 with the two "Message-ID:.* <!&!" patterns that are shown in the previous
202 section. Otherwise you will not be able to use the two backscatter rules to
203 stop forged Message ID strings. Of course this workaround may break the
204 next time Outlook is changed.
206 B
\bBl
\blo
\boc
\bck
\bki
\bin
\bng
\bg b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl w
\bwi
\bit
\bth
\bh f
\bfo
\bor
\brg
\bge
\bed
\bd s
\bse
\ben
\bnd
\bde
\ber
\br i
\bin
\bnf
\bfo
\bor
\brm
\bma
\bat
\bti
\bio
\bon
\bn
208 Like many people I still have a few email addresses in domains that I used in
209 the past. Mail for those addresses is forwarded to my current address. Most of
210 the backscatter mail that I get claims to be sent from these addresses. Such
211 mail is obviously forged and is very easy to stop.
213 /etc/postfix/main.cf:
214 header_checks = pcre:/etc/postfix/header_checks
215 body_checks = pcre:/etc/postfix/body_checks
217 /etc/postfix/header_checks:
218 /^(From|Return-Path):.*\b(user@domain\.tld)\b/
219 reject forged sender address in $1: header: $2
221 /etc/postfix/body_checks:
222 /^[> ]*(From|Return-Path):.*\b(user@domain\.tld)\b/
223 reject forged sender address in $1: header: $2
227 * The example uses pcre: tables mainly for speed; with minor modifications,
228 you can use regexp: tables as explained below.
230 * The example is simplified for educational purposes. In reality, my patterns
231 list multiple email addresses as "(user1@domain1\.tld|user2@domain2\.tld)".
233 * The two "\b" as used in "\b(user@domain\.tld)\b" match the beginning and
234 end of a word, respectively. If you use regexp: tables, specify "[[:<:]]
235 and [[:>:]]" (on some systems you should specify "\< and \>" instead; for
236 details see your system documentation).
238 * The "\." matches "." literally. Without the "\", the "." would match any
241 B
\bBl
\blo
\boc
\bck
\bki
\bin
\bng
\bg b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl w
\bwi
\bit
\bth
\bh o
\bot
\bth
\bhe
\ber
\br f
\bfo
\bor
\brg
\bge
\bed
\bd i
\bin
\bnf
\bfo
\bor
\brm
\bma
\bat
\bti
\bio
\bon
\bn
243 Another sign of forgery can be found in the IP address that is recorded in
244 Received: headers next to your HELO host or domain name. This information must
245 be used with care, though. Some mail servers are behind a network address
246 translator and never see the true client IP address.
248 B
\bBl
\blo
\boc
\bck
\bki
\bin
\bng
\bg b
\bba
\bac
\bck
\bks
\bsc
\bca
\bat
\btt
\bte
\ber
\br m
\bma
\bai
\bil
\bl f
\bfr
\bro
\bom
\bm v
\bvi
\bir
\bru
\bus
\bs s
\bsc
\bca
\ban
\bnn
\bne
\ber
\brs
\bs
250 With all the easily recognizable forgeries eliminated, there is one category of
251 backscatter mail that remains, and that is notifications from virus scanner
252 software. Unfortunately, some virus scanning software doesn't know that viruses
253 forge sender addresses. To make matters worse, the software also doesn't know
254 how to report a mail delivery problem, so that we cannot use the above
255 techniques to recognize forgeries.
257 Recognizing virus scanner mail is an error prone process, because there is a
258 lot of variation in report formats. The following is only a small example of
259 message header patterns. For a large collection of header and body patterns
260 that recognize virus notification email, see http://www.dkuug.dk/keld/virus/ or
261 http://www.t29.dk/antiantivirus.txt.
263 /etc/postfix/header_checks:
264 /^Subject: *Your email contains VIRUSES/ DISCARD virus notification
265 /^Content-Disposition:.*VIRUS1_DETECTED_AND_REMOVED/
266 DISCARD virus notification
267 /^Content-Disposition:.*VirusWarning.txt/ DISCARD virus notification
269 Note: these documents haven't been updated since 2004, so they are useful only
272 A plea to virus or spam scanner operators: please do not make the problem worse
273 by sending return mail to forged sender addresses. You're only harassing
274 innocent people. If you must return mail to the purported sender, please return
275 the full message headers, so that the sender can filter out the obvious