Imported Debian patch 4.84-8
[hcoop/debian/exim4.git] / debian / debconf / conf.d / acl / 30_exim4-config_check_rcpt
1
2 ### acl/30_exim4-config_check_rcpt
3 #################################
4
5 # This access control list is used for every RCPT command in an incoming
6 # SMTP message. The tests are run in order until the address is either
7 # accepted or denied.
8 #
9 acl_check_rcpt:
10
11 # Accept if the source is local SMTP (i.e. not over TCP/IP). We do this by
12 # testing for an empty sending host field.
13 accept
14 hosts = :
15 control = dkim_disable_verify
16
17 # Do not try to verify DKIM signatures of incoming mail if DC_minimaldns
18 # or DISABLE_DKIM_VERIFY are set.
19 .ifdef DC_minimaldns
20 warn
21 control = dkim_disable_verify
22 .else
23 .ifdef DISABLE_DKIM_VERIFY
24 warn
25 control = dkim_disable_verify
26 .endif
27 .endif
28
29 # The following section of the ACL is concerned with local parts that contain
30 # certain non-alphanumeric characters. Dots in unusual places are
31 # handled by this ACL as well.
32 #
33 # Non-alphanumeric characters other than dots are rarely found in genuine
34 # local parts, but are often tried by people looking to circumvent
35 # relaying restrictions. Therefore, although they are valid in local
36 # parts, these rules disallow certain non-alphanumeric characters, as
37 # a precaution.
38 #
39 # Empty components (two dots in a row) are not valid in RFC 2822, but Exim
40 # allows them because they have been encountered. (Consider local parts
41 # constructed as "firstinitial.secondinitial.familyname" when applied to
42 # a name without a second initial.) However, a local part starting
43 # with a dot or containing /../ can cause trouble if it is used as part of a
44 # file name (e.g. for a mailing list). This is also true for local parts that
45 # contain slashes. A pipe symbol can also be troublesome if the local part is
46 # incorporated unthinkingly into a shell command line.
47 #
48 # These ACL components will block recipient addresses that are valid
49 # from an RFC2822 point of view. We chose to have them blocked by
50 # default for security reasons.
51 #
52 # If you feel that your site should have less strict recipient
53 # checking, please feel free to change the default values of the macros
54 # defined in main/01_exim4-config_listmacrosdefs or override them from a
55 # local configuration file.
56 #
57 # Two different rules are used. The first one has a quite strict
58 # default, and is applied to messages that are addressed to one of the
59 # local domains handled by this host.
60
61 # The default value of CHECK_RCPT_LOCAL_LOCALPARTS is defined in
62 # main/01_exim4-config_listmacrosdefs:
63 # CHECK_RCPT_LOCAL_LOCALPARTS = ^[.] : ^.*[@%!/|`#&?]
64 # This blocks local parts that begin with a dot or contain a quite
65 # broad range of non-alphanumeric characters.
66 .ifdef CHECK_RCPT_LOCAL_LOCALPARTS
67 deny
68 domains = +local_domains
69 local_parts = CHECK_RCPT_LOCAL_LOCALPARTS
70 message = restricted characters in address
71 .endif
72
73
74 # The second rule applies to all other domains, and its default is
75 # considerably less strict.
76
77 # The default value of CHECK_RCPT_REMOTE_LOCALPARTS is defined in
78 # main/01_exim4-config_listmacrosdefs:
79 # CHECK_RCPT_REMOTE_LOCALPARTS = ^[./|] : ^.*[@%!`#&?] : ^.*/\\.\\./
80
81 # It allows local users to send outgoing messages to sites
82 # that use slashes and vertical bars in their local parts. It blocks
83 # local parts that begin with a dot, slash, or vertical bar, but allows
84 # these characters within the local part. However, the sequence /../ is
85 # barred. The use of some other non-alphanumeric characters is blocked.
86 # Single quotes might probably be dangerous as well, but they're
87 # allowed by the default regexps to avoid rejecting mails to Ireland.
88 # The motivation here is to prevent local users (or local users' malware)
89 # from mounting certain kinds of attack on remote sites.
90 .ifdef CHECK_RCPT_REMOTE_LOCALPARTS
91 deny
92 domains = !+local_domains
93 local_parts = CHECK_RCPT_REMOTE_LOCALPARTS
94 message = restricted characters in address
95 .endif
96
97
98 # Accept mail to postmaster in any local domain, regardless of the source,
99 # and without verifying the sender.
100 #
101 accept
102 .ifndef CHECK_RCPT_POSTMASTER
103 local_parts = postmaster
104 .else
105 local_parts = CHECK_RCPT_POSTMASTER
106 .endif
107 domains = +local_domains : +relay_to_domains
108
109
110 # Deny unless the sender address can be verified.
111 #
112 # This is disabled by default so that DNSless systems don't break. If
113 # your system can do DNS lookups without delay or cost, you might want
114 # to enable this feature.
115 #
116 # This feature does not work in smarthost and satellite setups as
117 # with these setups all domains pass verification. See spec.txt chapter
118 # 39.31 with the added information that a smarthost/satellite setup
119 # routes all non-local e-mail to the smarthost.
120 .ifdef CHECK_RCPT_VERIFY_SENDER
121 deny
122 message = Sender verification failed
123 !acl = acl_local_deny_exceptions
124 !verify = sender
125 .endif
126
127 # Verify senders listed in local_sender_callout with a callout.
128 #
129 # In smarthost and satellite setups, this causes the callout to be
130 # done to the smarthost. Verification will thus only be reliable if the
131 # smarthost does reject illegal addresses in the SMTP dialog.
132 deny
133 !acl = acl_local_deny_exceptions
134 senders = ${if exists{CONFDIR/local_sender_callout}\
135 {CONFDIR/local_sender_callout}\
136 {}}
137 !verify = sender/callout
138
139
140 # Accept if the message comes from one of the hosts for which we are an
141 # outgoing relay. It is assumed that such hosts are most likely to be MUAs,
142 # so we set control=submission to make Exim treat the message as a
143 # submission. It will fix up various errors in the message, for example, the
144 # lack of a Date: header line. If you are actually relaying out out from
145 # MTAs, you may want to disable this. If you are handling both relaying from
146 # MTAs and submissions from MUAs you should probably split them into two
147 # lists, and handle them differently.
148
149 # Recipient verification is omitted here, because in many cases the clients
150 # are dumb MUAs that don't cope well with SMTP error responses. If you are
151 # actually relaying out from MTAs, you should probably add recipient
152 # verification here.
153
154 # Note that, by putting this test before any DNS black list checks, you will
155 # always accept from these hosts, even if they end up on a black list. The
156 # assumption is that they are your friends, and if they get onto black
157 # list, it is a mistake.
158 accept
159 hosts = +relay_from_hosts
160 control = submission/sender_retain
161 control = dkim_disable_verify
162
163
164 # Accept if the message arrived over an authenticated connection, from
165 # any host. Again, these messages are usually from MUAs, so recipient
166 # verification is omitted, and submission mode is set. And again, we do this
167 # check before any black list tests.
168 accept
169 authenticated = *
170 control = submission/sender_retain
171 control = dkim_disable_verify
172
173
174 # Insist that any other recipient address that we accept is either in one of
175 # our local domains, or is in a domain for which we explicitly allow
176 # relaying. Any other domain is rejected as being unacceptable for relaying.
177 require
178 message = relay not permitted
179 domains = +local_domains : +relay_to_domains
180
181
182 # We also require all accepted addresses to be verifiable. This check will
183 # do local part verification for local domains, but only check the domain
184 # for remote domains.
185 require
186 verify = recipient
187
188
189 # Verify recipients listed in local_rcpt_callout with a callout.
190 # This is especially handy for forwarding MX hosts (secondary MX or
191 # mail hubs) of domains that receive a lot of spam to non-existent
192 # addresses. The only way to check local parts for remote relay
193 # domains is to use a callout (add /callout), but please read the
194 # documentation about callouts before doing this.
195 deny
196 !acl = acl_local_deny_exceptions
197 recipients = ${if exists{CONFDIR/local_rcpt_callout}\
198 {CONFDIR/local_rcpt_callout}\
199 {}}
200 !verify = recipient/callout
201
202
203 # CONFDIR/local_sender_blacklist holds a list of envelope senders that
204 # should have their access denied to the local host. Incoming messages
205 # with one of these senders are rejected at RCPT time.
206 #
207 # The explicit white lists are honored as well as negative items in
208 # the black list. See exim4-config_files(5) for details.
209 deny
210 message = sender envelope address $sender_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
211 !acl = acl_local_deny_exceptions
212 senders = ${if exists{CONFDIR/local_sender_blacklist}\
213 {CONFDIR/local_sender_blacklist}\
214 {}}
215
216
217 # deny bad sites (IP address)
218 # CONFDIR/local_host_blacklist holds a list of host names, IP addresses
219 # and networks (CIDR notation) that should have their access denied to
220 # The local host. Messages coming in from a listed host will have all
221 # RCPT statements rejected.
222 #
223 # The explicit white lists are honored as well as negative items in
224 # the black list. See exim4-config_files(5) for details.
225 deny
226 message = sender IP address $sender_host_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
227 !acl = acl_local_deny_exceptions
228 hosts = ${if exists{CONFDIR/local_host_blacklist}\
229 {CONFDIR/local_host_blacklist}\
230 {}}
231
232
233 # Warn if the sender host does not have valid reverse DNS.
234 #
235 # If your system can do DNS lookups without delay or cost, you might want
236 # to enable this.
237 # If sender_host_address is defined, it's a remote call. If
238 # sender_host_name is not defined, then reverse lookup failed. Use
239 # this instead of !verify = reverse_host_lookup to catch deferrals
240 # as well as outright failures.
241 .ifdef CHECK_RCPT_REVERSE_DNS
242 warn
243 condition = ${if and{{def:sender_host_address}{!def:sender_host_name}}\
244 {yes}{no}}
245 add_header = X-Host-Lookup-Failed: Reverse DNS lookup failed for $sender_host_address (${if eq{$host_lookup_failed}{1}{failed}{deferred}})
246 .endif
247
248
249 # Use spfquery to perform a pair of SPF checks (for details, see
250 # http://www.openspf.org/)
251 #
252 # This is quite costly in terms of DNS lookups (~6 lookups per mail). Do not
253 # enable if that's an issue. Also note that if you enable this, you must
254 # install "spf-tools-perl" which provides the spfquery command.
255 # Missing spf-tools-perl will trigger the "Unexpected error in
256 # SPF check" warning.
257 .ifdef CHECK_RCPT_SPF
258 deny
259 message = [SPF] $sender_host_address is not allowed to send mail from \
260 ${if def:sender_address_domain {$sender_address_domain}{$sender_helo_name}}. \
261 Please see \
262 http://www.openspf.org/Why?scope=${if def:sender_address_domain \
263 {mfrom}{helo}};identity=${if def:sender_address_domain \
264 {$sender_address}{$sender_helo_name}};ip=$sender_host_address
265 log_message = SPF check failed.
266 !acl = acl_local_deny_exceptions
267 condition = ${run{/usr/bin/spfquery.mail-spf-perl --ip \
268 ${quote:$sender_host_address} --identity \
269 ${if def:sender_address_domain \
270 {--scope mfrom --identity ${quote:$sender_address}}\
271 {--scope helo --identity ${quote:$sender_helo_name}}}}\
272 {no}{${if eq {$runrc}{1}{yes}{no}}}}
273
274 defer
275 message = Temporary DNS error while checking SPF record. Try again later.
276 !acl = acl_local_deny_exceptions
277 condition = ${if eq {$runrc}{5}{yes}{no}}
278
279 warn
280 condition = ${if <={$runrc}{6}{yes}{no}}
281 add_header = Received-SPF: ${if eq {$runrc}{0}{pass}\
282 {${if eq {$runrc}{2}{softfail}\
283 {${if eq {$runrc}{3}{neutral}\
284 {${if eq {$runrc}{4}{permerror}\
285 {${if eq {$runrc}{6}{none}{error}}}}}}}}}\
286 } client-ip=$sender_host_address; \
287 ${if def:sender_address_domain \
288 {envelope-from=${sender_address}; }{}}\
289 helo=$sender_helo_name
290
291 warn
292 log_message = Unexpected error in SPF check.
293 condition = ${if >{$runrc}{6}{yes}{no}}
294 .endif
295
296
297 # Check against classic DNS "black" lists (DNSBLs) which list
298 # sender IP addresses
299 .ifdef CHECK_RCPT_IP_DNSBLS
300 warn
301 dnslists = CHECK_RCPT_IP_DNSBLS
302 add_header = X-Warning: $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
303 log_message = $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
304 .endif
305
306
307 # Check against DNSBLs which list sender domains, with an option to locally
308 # whitelist certain domains that might be blacklisted.
309 #
310 # Note: If you define CHECK_RCPT_DOMAIN_DNSBLS, you must append
311 # "/$sender_address_domain" after each domain. For example:
312 # CHECK_RCPT_DOMAIN_DNSBLS = rhsbl.foo.org/$sender_address_domain \
313 # : rhsbl.bar.org/$sender_address_domain
314 .ifdef CHECK_RCPT_DOMAIN_DNSBLS
315 warn
316 !senders = ${if exists{CONFDIR/local_domain_dnsbl_whitelist}\
317 {CONFDIR/local_domain_dnsbl_whitelist}\
318 {}}
319 dnslists = CHECK_RCPT_DOMAIN_DNSBLS
320 add_header = X-Warning: $sender_address_domain is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
321 log_message = $sender_address_domain is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
322 .endif
323
324
325 # This hook allows you to hook in your own ACLs without having to
326 # modify this file. If you do it like we suggest, you'll end up with
327 # a small performance penalty since there is an additional file being
328 # accessed. This doesn't happen if you leave the macro unset.
329 .ifdef CHECK_RCPT_LOCAL_ACL_FILE
330 .include CHECK_RCPT_LOCAL_ACL_FILE
331 .endif
332
333
334 #############################################################################
335 # This check is commented out because it is recognized that not every
336 # sysadmin will want to do it. If you enable it, the check performs
337 # Client SMTP Authorization (csa) checks on the sending host. These checks
338 # do DNS lookups for SRV records. The CSA proposal is currently (May 2005)
339 # an Internet draft. You can, of course, add additional conditions to this
340 # ACL statement to restrict the CSA checks to certain hosts only.
341 #
342 # require verify = csa
343 #############################################################################
344
345
346 # Accept if the address is in a domain for which we are an incoming relay,
347 # but again, only if the recipient can be verified.
348
349 accept
350 domains = +relay_to_domains
351 endpass
352 verify = recipient
353
354
355 # At this point, the address has passed all the checks that have been
356 # configured, so we accept it unconditionally.
357
358 accept