c426f60bcb1678b2f2bc2509ec57211203f29179
[hcoop/config/exim.git] / 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 : +unix_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 : !+unix_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 : +unix_domains : +relay_to_domains
108
109 # Deny unless the sender address can be verified.
110 #
111 # This is disabled by default so that DNSless systems don't break. If
112 # your system can do DNS lookups without delay or cost, you might want
113 # to enable this feature.
114 #
115 # This feature does not work in smarthost and satellite setups as
116 # with these setups all domains pass verification. See spec.txt chapter
117 # 39.31 with the added information that a smarthost/satellite setup
118 # routes all non-local e-mail to the smarthost.
119 .ifdef CHECK_RCPT_VERIFY_SENDER
120 # hcoop-change: warn so that we can track down webapps sending
121 # without a valid return user, but not break the many web apps that
122 # do so. Fix.
123 warn
124 log_message = Sender verification failed
125 !acl = acl_local_deny_exceptions
126 !verify = sender
127 .endif
128
129 # hcoop-change: Add recommended lines from
130 # /usr/share/doc/mailman/README.EXIM.gz so that bounce messages
131 # get through, even if they are from a malformed address
132
133 # Accept bounces to lists even if callbacks or other checks would fail
134 warn
135 message = X-WhitelistedRCPT-nohdrfromcallback: Yes
136 condition = ${if and {{match{$local_part}{(.*)-bounces\+.*}} \
137 {def:domain} \
138 {eq {${lookup{$local_part@$domain}lsearch{MAILMAN_DB}}} \
139 {true}}} \
140 {yes}{no}}
141
142 accept
143 condition = ${if and {{match{$local_part}{(.*)-bounces\+.*}} \
144 {def:domain} \
145 {eq {${lookup{$local_part@$domain}lsearch{MAILMAN_DB}}} \
146 {true}}} \
147 {yes}{no}}
148
149 # Verify senders listed in local_sender_callout with a callout.
150 #
151 # In smarthost and satellite setups, this causes the callout to be
152 # done to the smarthost. Verification will thus only be reliable if the
153 # smarthost does reject illegal addresses in the SMTP dialog.
154 deny
155 !acl = acl_local_deny_exceptions
156 senders = ${if exists{CONFDIR/local_sender_callout}\
157 {CONFDIR/local_sender_callout}\
158 {}}
159 !verify = sender/callout
160
161
162 # Accept if the message comes from one of the hosts for which we are an
163 # outgoing relay. It is assumed that such hosts are most likely to be MUAs,
164 # so we set control=submission to make Exim treat the message as a
165 # submission. It will fix up various errors in the message, for example, the
166 # lack of a Date: header line. If you are actually relaying out out from
167 # MTAs, you may want to disable this. If you are handling both relaying from
168 # MTAs and submissions from MUAs you should probably split them into two
169 # lists, and handle them differently.
170
171 # Recipient verification is omitted here, because in many cases the clients
172 # are dumb MUAs that don't cope well with SMTP error responses. If you are
173 # actually relaying out from MTAs, you should probably add recipient
174 # verification here.
175
176 # Note that, by putting this test before any DNS black list checks, you will
177 # always accept from these hosts, even if they end up on a black list. The
178 # assumption is that they are your friends, and if they get onto black
179 # list, it is a mistake.
180 accept
181 hosts = +relay_from_hosts
182 control = submission/sender_retain
183 control = dkim_disable_verify
184
185
186 # Accept if the message arrived over an authenticated connection, from
187 # any host. Again, these messages are usually from MUAs, so recipient
188 # verification is omitted, and submission mode is set. And again, we do this
189 # check before any black list tests.
190 accept
191 authenticated = *
192 control = submission/sender_retain
193 control = dkim_disable_verify
194
195 # Insist that a HELO/EHLO was accepted.
196
197 require message = nice hosts say HELO first
198 condition = ${if def:sender_helo_name}
199
200 # Insist that any other recipient address that we accept is either in one of
201 # our local domains, or is in a domain for which we explicitly allow
202 # relaying. Any other domain is rejected as being unacceptable for relaying.
203 require
204 message = relay not permitted
205 domains = +local_domains : +unix_domains : +relay_to_domains
206
207
208 # We also require all accepted addresses to be verifiable. This check will
209 # do local part verification for local domains, but only check the domain
210 # for remote domains.
211 require
212 verify = recipient
213
214
215 # Verify recipients listed in local_rcpt_callout with a callout.
216 # This is especially handy for forwarding MX hosts (secondary MX or
217 # mail hubs) of domains that receive a lot of spam to non-existent
218 # addresses. The only way to check local parts for remote relay
219 # domains is to use a callout (add /callout), but please read the
220 # documentation about callouts before doing this.
221 deny
222 !acl = acl_local_deny_exceptions
223 recipients = ${if exists{CONFDIR/local_rcpt_callout}\
224 {CONFDIR/local_rcpt_callout}\
225 {}}
226 !verify = recipient/callout
227
228
229 # CONFDIR/local_sender_blacklist holds a list of envelope senders that
230 # should have their access denied to the local host. Incoming messages
231 # with one of these senders are rejected at RCPT time.
232 #
233 # The explicit white lists are honored as well as negative items in
234 # the black list. See exim4-config_files(5) for details.
235 deny
236 message = sender envelope address $sender_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
237 !acl = acl_local_deny_exceptions
238 senders = ${if exists{CONFDIR/local_sender_blacklist}\
239 {CONFDIR/local_sender_blacklist}\
240 {}}
241
242
243 # deny bad sites (IP address)
244 # CONFDIR/local_host_blacklist holds a list of host names, IP addresses
245 # and networks (CIDR notation) that should have their access denied to
246 # The local host. Messages coming in from a listed host will have all
247 # RCPT statements rejected.
248 #
249 # The explicit white lists are honored as well as negative items in
250 # the black list. See exim4-config_files(5) for details.
251 deny
252 message = sender IP address $sender_host_address is locally blacklisted here. If you think this is wrong, get in touch with postmaster
253 !acl = acl_local_deny_exceptions
254 hosts = ${if exists{CONFDIR/local_host_blacklist}\
255 {CONFDIR/local_host_blacklist}\
256 {}}
257
258
259 # Warn if the sender host does not have valid reverse DNS.
260 #
261 # If your system can do DNS lookups without delay or cost, you might want
262 # to enable this.
263 # If sender_host_address is defined, it's a remote call. If
264 # sender_host_name is not defined, then reverse lookup failed. Use
265 # this instead of !verify = reverse_host_lookup to catch deferrals
266 # as well as outright failures.
267 .ifdef CHECK_RCPT_REVERSE_DNS
268 warn
269 condition = ${if and{{def:sender_host_address}{!def:sender_host_name}}\
270 {yes}{no}}
271 log_message = Reverse DNS lookup failed for $sender_host_address (${if eq{$host_lookup_failed}{1}{failed}{deferred}})
272 add_header = X-Host-Lookup-Failed: Reverse DNS lookup failed for $sender_host_address (${if eq{$host_lookup_failed}{1}{failed}{deferred}})
273 .endif
274
275
276 # Use spfquery to perform a pair of SPF checks (for details, see
277 # http://www.openspf.org/)
278 #
279 # This is quite costly in terms of DNS lookups (~6 lookups per mail). Do not
280 # enable if that's an issue. Also note that if you enable this, you must
281 # install "spf-tools-perl" which provides the spfquery command.
282 # Missing spf-tools-perl will trigger the "Unexpected error in
283 # SPF check" warning.
284 .ifdef CHECK_RCPT_SPF
285 deny
286 message = [SPF] $sender_host_address is not allowed to send mail from \
287 ${if def:sender_address_domain {$sender_address_domain}{$sender_helo_name}}. \
288 Please see \
289 http://www.openspf.org/Why?scope=${if def:sender_address_domain \
290 {mfrom}{helo}};identity=${if def:sender_address_domain \
291 {$sender_address}{$sender_helo_name}};ip=$sender_host_address
292 log_message = SPF check failed.
293 !acl = acl_local_deny_exceptions
294 condition = ${run{/usr/bin/spfquery.mail-spf-perl --ip \
295 ${quote:$sender_host_address} --identity \
296 ${if def:sender_address_domain \
297 {--scope mfrom --identity ${quote:$sender_address}}\
298 {--scope helo --identity ${quote:$sender_helo_name}}}}\
299 {no}{${if eq {$runrc}{1}{yes}{no}}}}
300
301 defer
302 message = Temporary DNS error while checking SPF record. Try again later.
303 !acl = acl_local_deny_exceptions
304 condition = ${if eq {$runrc}{5}{yes}{no}}
305
306 warn
307 condition = ${if <={$runrc}{6}{yes}{no}}
308 add_header = Received-SPF: ${if eq {$runrc}{0}{pass}\
309 {${if eq {$runrc}{2}{softfail}\
310 {${if eq {$runrc}{3}{neutral}\
311 {${if eq {$runrc}{4}{permerror}\
312 {${if eq {$runrc}{6}{none}{error}}}}}}}}}\
313 } client-ip=$sender_host_address; \
314 ${if def:sender_address_domain \
315 {envelope-from=${sender_address}; }{}}\
316 helo=$sender_helo_name
317
318 warn
319 log_message = Unexpected error in SPF check.
320 condition = ${if >{$runrc}{6}{yes}{no}}
321 .endif
322
323
324 # Check against classic DNS "black" lists (DNSBLs) which list
325 # sender IP addresses
326 .ifdef CHECK_RCPT_IP_DNSBLS
327 # hcoop-change: drop connection instead of warning
328 drop
329 message = X-Warning: $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
330 log_message = $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
331 dnslists = CHECK_RCPT_IP_DNSBLS
332 add_header = X-Warning: $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
333 log_message = $sender_host_address is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
334 .endif
335
336
337 # Check against DNSBLs which list sender domains, with an option to locally
338 # whitelist certain domains that might be blacklisted.
339 #
340 # Note: If you define CHECK_RCPT_DOMAIN_DNSBLS, you must append
341 # "/$sender_address_domain" after each domain. For example:
342 # CHECK_RCPT_DOMAIN_DNSBLS = rhsbl.foo.org/$sender_address_domain \
343 # : rhsbl.bar.org/$sender_address_domain
344 .ifdef CHECK_RCPT_DOMAIN_DNSBLS
345 warn
346 !senders = ${if exists{CONFDIR/local_domain_dnsbl_whitelist}\
347 {CONFDIR/local_domain_dnsbl_whitelist}\
348 {}}
349 dnslists = CHECK_RCPT_DOMAIN_DNSBLS
350 add_header = X-Warning: $sender_address_domain is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
351 log_message = $sender_address_domain is listed at $dnslist_domain ($dnslist_value: $dnslist_text)
352 .endif
353
354
355 # This hook allows you to hook in your own ACLs without having to
356 # modify this file. If you do it like we suggest, you'll end up with
357 # a small performance penalty since there is an additional file being
358 # accessed. This doesn't happen if you leave the macro unset.
359 .ifdef CHECK_RCPT_LOCAL_ACL_FILE
360 .include CHECK_RCPT_LOCAL_ACL_FILE
361 .endif
362
363 # hcoop-change: 2015-03-19 clinton_admin
364 # testing if this will reject the fucktons of spam hitting logs@,
365 # most of it fscking signed with valid DKIM keys and evading
366 # spamassassin.
367 deny
368 log_message = rejecting non-hcoop host sending to logs
369 recipients = logs@*.hcoop.net,log@hcoop.net
370 !hosts = +relay_from_hosts
371
372 #############################################################################
373 # This check is commented out because it is recognized that not every
374 # sysadmin will want to do it. If you enable it, the check performs
375 # Client SMTP Authorization (csa) checks on the sending host. These checks
376 # do DNS lookups for SRV records. The CSA proposal is currently (May 2005)
377 # an Internet draft. You can, of course, add additional conditions to this
378 # ACL statement to restrict the CSA checks to certain hosts only.
379 #
380 # require verify = csa
381 #############################################################################
382
383
384 # Accept if the address is in a domain for which we are an incoming relay,
385 # but again, only if the recipient can be verified.
386
387 accept
388 domains = +relay_to_domains
389 endpass
390 verify = recipient
391
392
393 # At this point, the address has passed all the checks that have been
394 # configured, so we accept it unconditionally.
395
396 accept