header_checks revision 1.1.1.2 1 #++
2 # NAME
3 # header_checks 5
4 # SUMMARY
5 # Postfix built-in content inspection
6 # SYNOPSIS
7 # .nf
8 # \fBheader_checks = pcre:/etc/postfix/header_checks\fR
9 # \fBmime_header_checks = pcre:/etc/postfix/mime_header_checks\fR
10 # \fBnested_header_checks = pcre:/etc/postfix/nested_header_checks\fR
11 # \fBbody_checks = pcre:/etc/postfix/body_checks\fR
12 # .sp
13 # \fBpostmap -q "\fIstring\fB" pcre:/etc/postfix/\fIfilename\fR
14 # \fBpostmap -q - pcre:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
15 # .fi
16 # DESCRIPTION
17 # This document describes access control on the content of
18 # message headers and message body lines; it is implemented
19 # by the Postfix \fBcleanup\fR(8) server before mail is queued.
20 # See \fBaccess\fR(5) for access control on remote SMTP client
21 # information.
22 #
23 # Each message header or message body line is compared against
24 # a list of patterns.
25 # When a match is found the corresponding action is executed, and
26 # the matching process is repeated for the next message header or
27 # message body line.
28 #
29 # For examples, see the EXAMPLES section at the end of this
30 # manual page.
31 #
32 # Postfix header or body_checks are designed to stop a flood of mail
33 # from worms or viruses; they do not decode attachments, and they do
34 # not unzip archives. See the documents referenced below in the README
35 # FILES section if you need more sophisticated content analysis.
36 #
37 # Postfix supports four built-in content inspection classes:
38 # .IP \fBheader_checks\fR
39 # These are applied to initial message headers (except for
40 # the headers that are processed with \fBmime_header_checks\fR).
41 # .IP "\fBmime_header_checks\fR (default: \fB$header_checks\fR)"
42 # These are applied to MIME related message headers only.
43 # .sp
44 # This feature is available in Postfix 2.0 and later.
45 # .IP "\fBnested_header_checks\fR (default: \fB$header_checks\fR)"
46 # These are applied to message headers of attached email
47 # messages (except for the headers that are processed with
48 # \fBmime_header_checks\fR).
49 # .sp
50 # This feature is available in Postfix 2.0 and later.
51 # .IP \fBbody_checks\fR
52 # These are applied to all other content, including multi-part
53 # message boundaries.
54 # .sp
55 # With Postfix versions before 2.0, all content after the initial
56 # message headers is treated as body content.
57 # .PP
58 # Note: message headers are examined one logical header at a time,
59 # even when a message header spans multiple lines. Body lines are
60 # always examined one line at a time.
61 # COMPATIBILITY
62 # .ad
63 # .fi
64 # With Postfix version 2.2 and earlier specify "\fBpostmap
65 # -fq\fR" to query a table that contains case sensitive
66 # patterns. By default, regexp: and pcre: patterns are case
67 # insensitive.
68 # TABLE FORMAT
69 # .ad
70 # .fi
71 # This document assumes that header and body_checks rules are specified
72 # in the form of Postfix regular expression lookup tables. Usually the
73 # best performance is obtained with \fBpcre\fR (Perl Compatible Regular
74 # Expression) tables, but the slower \fBregexp\fR (POSIX regular
75 # expressions) support is more widely available.
76 # Use the command "\fBpostconf -m\fR" to find out what lookup table
77 # types your Postfix system supports.
78 #
79 # The general format of Postfix regular expression tables is
80 # given below.
81 # For a discussion of specific pattern or flags syntax,
82 # see \fBpcre_table\fR(5) or \fBregexp_table\fR(5), respectively.
83 # .IP "\fB/\fIpattern\fB/\fIflags action\fR"
84 # When /\fIpattern\fR/ matches the input string, execute
85 # the corresponding \fIaction\fR. See below for a list
86 # of possible actions.
87 # .IP "\fB!/\fIpattern\fB/\fIflags action\fR"
88 # When /\fIpattern\fR/ does \fBnot\fR match the input string,
89 # execute the corresponding \fIaction\fR.
90 # .IP "\fBif /\fIpattern\fB/\fIflags\fR"
91 # .IP "\fBendif\fR"
92 # Match the input string against the patterns between \fBif\fR
93 # and \fBendif\fR, if and only if the same input string also
94 # matches /\fIpattern\fR/. The \fBif\fR..\fBendif\fR can nest.
95 # .sp
96 # Note: do not prepend whitespace to patterns inside
97 # \fBif\fR..\fBendif\fR.
98 # .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
99 # .IP "\fBendif\fR"
100 # Match the input string against the patterns between \fBif\fR
101 # and \fBendif\fR, if and only if the same input string does
102 # \fBnot\fR match /\fIpattern\fR/. The \fBif\fR..\fBendif\fR
103 # can nest.
104 # .IP "blank lines and comments"
105 # Empty lines and whitespace-only lines are ignored, as
106 # are lines whose first non-whitespace character is a `#'.
107 # .IP "multi-line text"
108 # A pattern/action line starts with non-whitespace text. A line that
109 # starts with whitespace continues a logical line.
110 # TABLE SEARCH ORDER
111 # .ad
112 # .fi
113 # For each line of message input, the patterns are applied in the
114 # order as specified in the table. When a pattern is found that matches
115 # the input line, the corresponding action is executed and then the
116 # next input line is inspected.
117 # TEXT SUBSTITUTION
118 # .ad
119 # .fi
120 # Substitution of substrings from the matched expression into the
121 # \fIaction\fR
122 # string is possible using the conventional Perl syntax
123 # (\fB$1\fR, \fB$2\fR, etc.).
124 # The macros in the result string may need to be written as \fB${n}\fR
125 # or \fB$(n)\fR if they aren't followed by whitespace.
126 #
127 # Note: since negated patterns (those preceded by \fB!\fR) return a
128 # result when the expression does not match, substitutions are not
129 # available for negated patterns.
130 # ACTIONS
131 # .ad
132 # .fi
133 # Action names are case insensitive. They are shown in upper case
134 # for consistency with other Postfix documentation.
135 # \" .IP "\fBDELAY \fItime\fR"
136 # \" Place the message into the deferred queue, and delay the
137 # \" initial delivery attempt by \fItime\fR. The time value may
138 # \" be followed by a one-character suffix that specifies the
139 # \" time unit: s (seconds), m (minutes), h (hours), d (days),
140 # \" w (weeks). The default time unit is s (seconds).
141 # \" .sp
142 # \" Limitations:
143 # \" .RS
144 # \" .IP \(bu
145 # \" This action affects all the recipients of the message.
146 # \" .IP \(bu
147 # \" The delay value has no effect with remote file systems that
148 # \" don't correctly emulate UNIX local file system semantics.
149 # \" In that case, the delay will be half of $queue_run_delay
150 # \" on average.
151 # \" .IP \(bu
152 # \" Mail will still be delivered with "sendmail -q", "postfix
153 # \" flush" or "postqueue -f".
154 # \" .IP \(bu
155 # \" Delayed mail increases the amount of disk I/O during deferred
156 # \" queue scans. When large amounts of mail are queued for
157 # \" delayed delivery it may be preferable to use the HOLD feature
158 # \" instead.
159 # \" .RE
160 # \" .IP
161 # \" This feature is available in Postfix 2.3 and later.
162 # .IP "\fBDISCARD \fIoptional text...\fR"
163 # Claim successful delivery and silently discard the message.
164 # Log the optional text if specified, otherwise log a generic
165 # message.
166 # .sp
167 # Note: this action disables further header or body_checks inspection
168 # of the current message and affects all recipients.
169 # To discard only one recipient without discarding the entire message,
170 # use the transport(5) table to direct mail to the discard(8) service.
171 # .sp
172 # This feature is available in Postfix 2.0 and later.
173 # .IP \fBDUNNO\fR
174 # Pretend that the input line did not match any pattern, and inspect the
175 # next input line. This action can be used to shorten the table search.
176 # .sp
177 # For backwards compatibility reasons, Postfix also accepts
178 # \fBOK\fR but it is (and always has been) treated as \fBDUNNO\fR.
179 # .sp
180 # This feature is available in Postfix 2.1 and later.
181 # .IP "\fBFILTER \fItransport:destination\fR"
182 # After the message is queued, send the entire message through
183 # the specified external content filter. The \fItransport\fR
184 # name specifies the first field of a mail delivery agent
185 # definition in master.cf; the syntax of the next-hop
186 # \fIdestination\fR is described in the manual page of the
187 # corresponding delivery agent. More information about
188 # external content filters is in the Postfix FILTER_README
189 # file.
190 # .sp
191 # Note 1: do not use $\fInumber\fR regular expression
192 # substitutions for \fItransport\fR or \fIdestination\fR
193 # unless you know that the information has a trusted origin.
194 # .sp
195 # Note 2: this action overrides the main.cf \fBcontent_filter\fR
196 # setting, and affects all recipients of the message. In the
197 # case that multiple \fBFILTER\fR actions fire, only the last
198 # one is executed.
199 # .sp
200 # Note 3: the purpose of the FILTER command is to override
201 # message routing. To override the recipient's \fItransport\fR
202 # but not the next-hop \fIdestination\fR, specify an empty
203 # filter \fIdestination\fR (Postfix 2.7 and later), or specify
204 # a \fItransport:destination\fR that delivers through a
205 # different Postfix instance (Postfix 2.6 and earlier). Other
206 # options are using the recipient-dependent \fBtrans\%port\%_maps\fR
207 # or the sen\%der-dependent
208 # \fBsender\%_de\%pen\%dent\%_de\%fault\%_trans\%port\%_maps\fR
209 # features.
210 # .sp
211 # This feature is available in Postfix 2.0 and later.
212 # .IP "\fBHOLD \fIoptional text...\fR"
213 # Arrange for the message to be placed on the \fBhold\fR queue,
214 # and inspect the next input line. The message remains on \fBhold\fR
215 # until someone either deletes it or releases it for delivery.
216 # Log the optional text if specified, otherwise log a generic
217 # message.
218 #
219 # Mail that is placed on hold can be examined with the
220 # \fBpostcat\fR(1) command, and can be destroyed or released with
221 # the \fBpostsuper\fR(1) command.
222 # .sp
223 # Note: use "\fBpostsuper -r\fR" to release mail that was kept on
224 # hold for a significant fraction of \fB$maximal_queue_lifetime\fR
225 # or \fB$bounce_queue_lifetime\fR, or longer. Use "\fBpostsuper -H\fR"
226 # only for mail that will not expire within a few delivery attempts.
227 # .sp
228 # Note: this action affects all recipients of the message.
229 # .sp
230 # This feature is available in Postfix 2.0 and later.
231 # .IP \fBIGNORE\fR
232 # Delete the current line from the input, and inspect
233 # the next input line.
234 # .IP "\fBPREPEND \fItext...\fR"
235 # Prepend one line with the specified text, and inspect the next
236 # input line.
237 # .sp
238 # Notes:
239 # .RS
240 # .IP \(bu
241 # The prepended text is output on a separate line, immediately
242 # before the input that triggered the \fBPREPEND\fR action.
243 # .IP \(bu
244 # The prepended text is not considered part of the input
245 # stream: it is not subject to header/body checks or address
246 # rewriting, and it does not affect the way that Postfix adds
247 # missing message headers.
248 # .IP \(bu
249 # When prepending text before a message header line, the prepended
250 # text must begin with a valid message header label.
251 # .IP \(bu
252 # This action cannot be used to prepend multi-line text.
253 # .RE
254 # .IP
255 # This feature is available in Postfix 2.1 and later.
256 # .IP "\fBREDIRECT \fIuser@domain\fR"
257 # Write a message redirection request to the queue file, and
258 # inspect the next input line. After the message is queued,
259 # it will be sent to the specified address instead of the
260 # intended recipient(s).
261 # .sp
262 # Note: this action overrides the \fBFILTER\fR action, and affects
263 # all recipients of the message. If multiple \fBREDIRECT\fR actions
264 # fire, only the last one is executed.
265 # .sp
266 # This feature is available in Postfix 2.1 and later.
267 # .IP "\fBREPLACE \fItext...\fR"
268 # Replace the current line with the specified text, and inspect the next
269 # input line.
270 # .sp
271 # This feature is available in Postfix 2.2 and later. The
272 # description below applies to Postfix 2.2.2 and later.
273 # .sp
274 # Notes:
275 # .RS
276 # .IP \(bu
277 # When replacing a message header line, the replacement text
278 # must begin with a valid header label.
279 # .IP \(bu
280 # The replaced text remains part of the input stream. Unlike
281 # the result from the \fBPREPEND\fR action, a replaced message
282 # header may be subject to address rewriting and may affect
283 # the way that Postfix adds missing message headers.
284 # .RE
285 # .IP "\fBREJECT \fIoptional text...\fR
286 # Reject the entire message. Reply with \fIoptional text...\fR when
287 # the optional text is specified, otherwise reply with a generic error
288 # message.
289 # .sp
290 # Note: this action disables further header or body_checks inspection
291 # of the current message and affects all recipients.
292 # .sp
293 # Postfix version 2.3 and later support enhanced status codes.
294 # When no code is specified at the beginning of \fIoptional
295 # text...\fR, Postfix inserts a default enhanced status code of
296 # "5.7.1".
297 # .IP "\fBWARN \fIoptional text...\fR
298 # Log a warning with the \fIoptional text...\fR (or log a
299 # generic message), and inspect the next input line. This
300 # action is useful for debugging and for testing a pattern
301 # before applying more drastic actions.
302 # BUGS
303 # Empty lines never match, because some map types mis-behave
304 # when given a zero-length search string. This limitation may
305 # be removed for regular expression tables in a future release.
306 #
307 # Many people overlook the main limitations of header and body_checks
308 # rules.
309 # .IP \(bu
310 # These rules operate on one logical message header or one body
311 # line at a time. A decision made for one line is not carried over
312 # to the next line.
313 # .IP \(bu
314 # If text in the message body is encoded
315 # (RFC 2045) then the rules need to be specified for the encoded
316 # form.
317 # .IP \(bu
318 # Likewise, when message headers are encoded (RFC
319 # 2047) then the rules need to be specified for the encoded
320 # form.
321 # .PP
322 # Message headers added by the \fBcleanup\fR(8) daemon itself
323 # are excluded from inspection. Examples of such message headers
324 # are \fBFrom:\fR, \fBTo:\fR, \fBMessage-ID:\fR, \fBDate:\fR.
325 #
326 # Message headers deleted by the \fBcleanup\fR(8) daemon will
327 # be examined before they are deleted. Examples are: \fBBcc:\fr,
328 # \fBContent-Length:\fR, \fBReturn-Path:\fR.
329 # CONFIGURATION PARAMETERS
330 # .ad
331 # .fi
332 # .IP \fBbody_checks\fR
333 # Lookup tables with content filter rules for message body lines.
334 # These filters see one physical line at a time, in chunks of
335 # at most \fB$line_length_limit\fR bytes.
336 # .IP \fBbody_checks_size_limit\fP
337 # The amount of content per message body segment (attachment) that is
338 # subjected to \fB$body_checks\fR filtering.
339 # .IP \fBheader_checks\fR
340 # .IP "\fBmime_header_checks\fR (default: \fB$header_checks\fR)"
341 # .IP "\fBnested_header_checks\fR (default: \fB$header_checks\fR)"
342 # Lookup tables with content filter rules for message header lines:
343 # respectively, these are applied to the initial message headers
344 # (not including MIME headers), to the MIME headers anywhere in
345 # the message, and to the initial headers of attached messages.
346 # .sp
347 # Note: these filters see one logical message header at a time, even
348 # when a message header spans multiple lines. Message headers that
349 # are longer than \fB$header_size_limit\fR characters are truncated.
350 # .IP \fBdisable_mime_input_processing\fR
351 # While receiving mail, give no special treatment to MIME related
352 # message headers; all text after the initial message headers is
353 # considered to be part of the message body. This means that
354 # \fBheader_checks\fR is applied to all the initial message headers,
355 # and that \fBbody_checks\fR is applied to the remainder of the
356 # message.
357 # .sp
358 # Note: when used in this manner, \fBbody_checks\fR will process
359 # a multi-line message header one line at a time.
360 # EXAMPLES
361 # .ad
362 # .fi
363 # Header pattern to block attachments with bad file name
364 # extensions. For convenience, the PCRE /x flag is specified,
365 # so that there is no need to collapse the pattern into a
366 # single line of text. The purpose of the [[:xdigit:]]
367 # sub-expressions is to recognize Windows CLSID strings.
368 #
369 # .na
370 # .nf
371 # /etc/postfix/main.cf:
372 # header_checks = pcre:/etc/postfix/header_checks.pcre
373 #
374 # /etc/postfix/header_checks.pcre:
375 # /^Content-(Disposition|Type).*name\es*=\es*"?(.*(\e.|=2E)(
376 # ade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|dll|exe|
377 # hlp|ht[at]|
378 # inf|ins|isp|jse?|lnk|md[betw]|ms[cipt]|nws|
379 # \e{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\e}|
380 # ops|pcd|pif|prf|reg|sc[frt]|sh[bsm]|swf|
381 # vb[esx]?|vxd|ws[cfh]))(\e?=)?"?\es*(;|$)/x
382 # REJECT Attachment name "$2" may not end with ".$4"
383 # .ad
384 # .fi
385 #
386 # Body pattern to stop a specific HTML browser vulnerability exploit.
387 #
388 # .na
389 # .nf
390 # /etc/postfix/main.cf:
391 # body_checks = regexp:/etc/postfix/body_checks
392 #
393 # /etc/postfix/body_checks:
394 # /^<iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0>$/
395 # REJECT IFRAME vulnerability exploit
396 # SEE ALSO
397 # cleanup(8), canonicalize and enqueue Postfix message
398 # pcre_table(5), format of PCRE lookup tables
399 # regexp_table(5), format of POSIX regular expression tables
400 # postconf(1), Postfix configuration utility
401 # postmap(1), Postfix lookup table management
402 # postsuper(1), Postfix janitor
403 # postcat(1), show Postfix queue file contents
404 # RFC 2045, base64 and quoted-printable encoding rules
405 # RFC 2047, message header encoding for non-ASCII text
406 # README FILES
407 # .ad
408 # .fi
409 # Use "\fBpostconf readme_directory\fR" or
410 # "\fBpostconf html_directory\fR" to locate this information.
411 # .na
412 # .nf
413 # DATABASE_README, Postfix lookup table overview
414 # CONTENT_INSPECTION_README, Postfix content inspection overview
415 # BUILTIN_FILTER_README, Postfix built-in content inspection
416 # BACKSCATTER_README, blocking returned forged mail
417 # LICENSE
418 # .ad
419 # .fi
420 # The Secure Mailer license must be distributed with this software.
421 # AUTHOR(S)
422 # Wietse Venema
423 # IBM T.J. Watson Research
424 # P.O. Box 704
425 # Yorktown Heights, NY 10598, USA
426 #--
427