File: header_checks.5.html

package info (click to toggle)
postfix 2.3.8-2%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 15,744 kB
  • ctags: 11,426
  • sloc: ansic: 81,810; makefile: 10,743; sh: 7,874; perl: 2,468; awk: 41
file content (392 lines) | stat: -rw-r--r-- 20,246 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title> Postfix manual - header_checks(5) </title>
</head> <body> <pre>
HEADER_CHECKS(5)                                              HEADER_CHECKS(5)

<b>NAME</b>
       <a href="postconf.5.html#header_checks">header_checks</a> - Postfix built-in header/body inspection

<b>SYNOPSIS</b>
       <b><a href="postconf.5.html#header_checks">header_checks</a> = <a href="pcre_table.5.html">pcre</a>:/etc/postfix/header_checks</b>
       <b><a href="postconf.5.html#mime_header_checks">mime_header_checks</a> = <a href="pcre_table.5.html">pcre</a>:/etc/postfix/mime_header_checks</b>
       <b><a href="postconf.5.html#nested_header_checks">nested_header_checks</a> = <a href="pcre_table.5.html">pcre</a>:/etc/postfix/nested_header_checks</b>
       <b><a href="postconf.5.html#body_checks">body_checks</a> = <a href="pcre_table.5.html">pcre</a>:/etc/postfix/body_checks</b>

       <b>postmap -fq "</b><i>string</i><b>" <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i>
       <b>postmap -fq - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>

<b>DESCRIPTION</b>
       Postfix  provides  a  simple  built-in  content inspection
       mechanism that examines incoming mail one  message  header
       or one message body line at a time. Each input is compared
       against a list of patterns, and when a match is found  the
       corresponding  action is executed.  This feature is imple-
       mented by the Postfix <a href="cleanup.8.html"><b>cleanup</b>(8)</a> server.

       For examples, see the EXAMPLES section at the end of  this
       manual page.

       Postfix header or <a href="postconf.5.html#body_checks">body_checks</a> are designed to stop a flood
       of mail from worms or viruses; they do not decode  attach-
       ments,  and  they do not unzip archives. See the documents
       referenced below in the README FILES section if  you  need
       more sophisticated content analysis.

       Postfix supports four built-in content inspection classes:

       <b><a href="postconf.5.html#header_checks">header_checks</a></b>
              These  are  applied  to  initial  message   headers
              (except  for  the  headers  that are processed with
              <b><a href="postconf.5.html#mime_header_checks">mime_header_checks</a></b>).

       <b><a href="postconf.5.html#mime_header_checks">mime_header_checks</a></b> (default: <b>$<a href="postconf.5.html#header_checks">header_checks</a></b>)
              These are applied to MIME related  message  headers
              only.

              This feature is available in Postfix 2.0 and later.

       <b><a href="postconf.5.html#nested_header_checks">nested_header_checks</a></b> (default: <b>$<a href="postconf.5.html#header_checks">header_checks</a></b>)
              These are applied to message  headers  of  attached
              email  messages  (except  for  the headers that are
              processed with <b><a href="postconf.5.html#mime_header_checks">mime_header_checks</a></b>).

              This feature is available in Postfix 2.0 and later.

       <b><a href="postconf.5.html#body_checks">body_checks</a></b>
              These  are  applied to all other content, including
              multi-part message boundaries.

              With Postfix versions before 2.0, all content after
              the initial message headers is treated as body con-
              tent.

       Note: message headers are examined one logical header at a
       time,  even  when  a  message header spans multiple lines.
       Body lines are always examined one line at a time.

<b>TABLE FORMAT</b>
       This document assumes that header  and  <a href="postconf.5.html#body_checks">body_checks</a>  rules
       are  specified  in  the form of Postfix regular expression
       lookup tables. Usually the best  performance  is  obtained
       with <b>pcre</b> (Perl Compatible Regular Expression) tables, but
       the slower <b>regexp</b> (POSIX regular expressions)  support  is
       more  widely  available.  Use the command "<b>postconf -m</b>" to
       find out what lookup table types your Postfix system  sup-
       ports.

       The general format of Postfix regular expression tables is
       given below.  For a  discussion  of  specific  pattern  or
       flags   syntax,   see  <a href="pcre_table.5.html"><b>pcre_table</b>(5)</a>  or  <a href="regexp_table.5.html"><b>regexp_table</b>(5)</a>,
       respectively.

       <b>/</b><i>pattern</i><b>/</b><i>flags action</i>
              When <i>pattern</i> matches the input string, execute  the
              corresponding  <i>action</i>. See below for a list of pos-
              sible actions.

       <b>!/</b><i>pattern</i><b>/</b><i>flags action</i>
              When <i>pattern</i> does <b>not</b> match the input string,  exe-
              cute the corresponding <i>action</i>.

       <b>if /</b><i>pattern</i><b>/</b><i>flags</i>

       <b>endif</b>  Match the input string against the patterns between
              <b>if</b> and <b>endif</b>, if and only if the input string  also
              matches <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.

              Note:  do not prepend whitespace to patterns inside
              <b>if</b>..<b>endif</b>.

       <b>if !/</b><i>pattern</i><b>/</b><i>flags</i>

       <b>endif</b>  Match the input string against the patterns between
              <b>if</b>  and <b>endif</b>, if and only if the input string does
              <b>not</b> match <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.

       blank lines and comments
              Empty lines and whitespace-only lines are  ignored,
              as  are  lines whose first non-whitespace character
              is a `#'.

       multi-line text
              A pattern/action line  starts  with  non-whitespace
              text.  A line that starts with whitespace continues
              a logical line.

<b>TABLE SEARCH ORDER</b>
       For each line of message input, the patterns  are  applied
       in  the order as specified in the table. When a pattern is
       found that  matches  the  input  line,  the  corresponding
       action  is  executed  and  then  the  next  input  line is
       inspected.

<b>TEXT SUBSTITUTION</b>
       Substitution of substrings  from  the  matched  expression
       into  the <i>action</i> string is possible using the conventional
       Perl syntax (<b>$1</b>, <b>$2</b>, etc.).   The  macros  in  the  result
       string  may  need  to  be  written as <b>${n}</b> or <b>$(n)</b> if they
       aren't followed by whitespace.

       Note: since negated patterns (those preceded by <b>!</b>)  return
       a result when the expression does not match, substitutions
       are not available for negated patterns.

<b>ACTIONS</b>
       Action names are case insensitive. They are shown in upper
       case for consistency with other Postfix documentation.

       <b>DISCARD</b> <i>optional text...</i>
              Claim  successful delivery and silently discard the
              message.  Log the optional text if specified,  oth-
              erwise log a generic message.

              Note:   this  action  disables  further  header  or
              <a href="postconf.5.html#body_checks">body_checks</a> inspection of the current  message  and
              affects all recipients.  To discard only one recip-
              ient without discarding the entire message, use the
              <a href="transport.5.html">transport(5)</a> table to direct mail to the <a href="discard.8.html">discard(8)</a>
              service.

              This feature is available in Postfix 2.0 and later.

       <b>DUNNO</b>  Pretend  that the input line did not match any pat-
              tern, and inspect the next input line. This  action
              can be used to shorten the table search.

              For  backwards  compatibility reasons, Postfix also
              accepts <b>OK</b> but it is (and always has been)  treated
              as <b>DUNNO</b>.

              This feature is available in Postfix 2.1 and later.

       <b>FILTER</b> <i>transport:destination</i>
              Write a content filter request to  the  queue  file
              and  inspect  the  next input line.  After the com-
              plete message is received it will be  sent  through
              the specified external content filter.  More infor-
              mation about external content  filters  is  in  the
              Postfix <a href="FILTER_README.html">FILTER_README</a> file.

              Note:   this  action  overrides  the  <b>main.cf  <a href="postconf.5.html#content_filter">con</a>-</b>
              <b><a href="postconf.5.html#content_filter">tent_filter</a></b> setting, and affects all recipients  of
              the  message.  In  the  case  that  multiple <b>FILTER</b>
              actions fire, only the last one is executed.

              This feature is available in Postfix 2.0 and later.

       <b>HOLD</b> <i>optional text...</i>
              Arrange  for  the  message to be placed on the <b>hold</b>
              queue, and inspect the next input line.   The  mes-
              sage  remains  on <b>hold</b> until someone either deletes
              it or releases it for delivery.  Log  the  optional
              text if specified, otherwise log a generic message.

              Mail that is placed on hold can  be  examined  with
              the  <a href="postcat.1.html"><b>postcat</b>(1)</a>  command,  and  can be destroyed or
              released with the <a href="postsuper.1.html"><b>postsuper</b>(1)</a> command.

              Note: use "<b>postsuper -r</b>" to release mail  that  was
              kept  on  hold for a significant fraction of <b>$<a href="postconf.5.html#maximal_queue_lifetime">maxi</a>-</b>
              <b><a href="postconf.5.html#maximal_queue_lifetime">mal_queue_lifetime</a></b>  or  <b>$<a href="postconf.5.html#bounce_queue_lifetime">bounce_queue_lifetime</a></b>,  or
              longer.

              Note:  this  action  affects  all recipients of the
              message.

              This feature is available in Postfix 2.0 and later.

       <b>IGNORE</b> Delete  the current line from the input and inspect
              the next input line.

       <b>PREPEND</b> <i>text...</i>
              Prepend  one  line  with  the  specified  text  and
              inspect the next input line.

              Notes:

              <b>o</b>      The  prepended  text is output on a separate
                     line,  immediately  before  the  input  that
                     triggered the <b>PREPEND</b> action.

              <b>o</b>      The prepended text is not considered part of
                     the input  stream:  it  is  not  subject  to
                     header/body checks or address rewriting, and
                     it does not affect the way that Postfix adds
                     missing message headers.

              <b>o</b>      When prepending text before a message header
                     line, the prepended text must begin  with  a
                     valid message header label.

              <b>o</b>      This action cannot be used to prepend multi-
                     line text.

              This feature is available in Postfix 2.1 and later.

       <b>REDIRECT</b> <i>user@domain</i>
              Write  a  message  redirection request to the queue
              file and inspect the next  input  line.  After  the
              message is queued, it will be sent to the specified
              address instead of the intended recipient(s).

              Note: this action overrides the <b>FILTER</b> action,  and
              affects  all recipients of the message. If multiple
              <b>REDIRECT</b> actions fire, only the last  one  is  exe-
              cuted.

              This feature is available in Postfix 2.1 and later.

       <b>REPLACE</b> <i>text...</i>
              Replace the current line with  the  specified  text
              and inspect the next input line.

              This feature is available in Postfix 2.2 and later.
              The description below applies to Postfix 2.2.2  and
              later.

              Notes:

              <b>o</b>      When  replacing  a  message header line, the
                     replacement text must  begin  with  a  valid
                     header label.

              <b>o</b>      The  replaced text remains part of the input
                     stream. Unlike the result from  the  <b>PREPEND</b>
                     action,  a  replaced  message  header may be
                     subject to address rewriting and may  affect
                     the  way  that  Postfix adds missing message
                     headers.

       <b>REJECT</b> <i>optional text...</i>
              Reject the  entire  message.  Reply  with  <i>optional</i>
              <i>text...</i> when the optional text is specified, other-
              wise reply with a generic error message.

              Note:  this  action  disables  further  header   or
              <a href="postconf.5.html#body_checks">body_checks</a>  inspection  of the current message and
              affects all recipients.

              Postfix version 2.3 and later support enhanced sta-
              tus codes.  When no code is specified at the begin-
              ning of <i>optional text...</i>, Postfix inserts a default
              enhanced status code of "5.7.1".

       <b>WARN</b> <i>optional text...</i>
              Log  a  warning with the <i>optional text...</i> (or log a
              generic message) and inspect the next  input  line.
              This action is useful for debugging and for testing
              a pattern before applying more drastic actions.

<b>BUGS</b>
       Many people overlook the main limitations  of  header  and
       <a href="postconf.5.html#body_checks">body_checks</a>  rules.   These  rules  operate on one logical
       message header or one body line at a time, and a  decision
       made  for  one  line is not carried over to the next line.
       If text in the message body is encoded (<a href="http://www.faqs.org/rfcs/rfc2045.html">RFC 2045</a>) then the
       rules  have  to specified for the encoded form.  Likewise,
       when message headers are encoded (<a href="http://www.faqs.org/rfcs/rfc2047.html">RFC 2047</a>) then the rules
       need to be specified for the encoded form.

       Message  headers added by the <a href="cleanup.8.html"><b>cleanup</b>(8)</a> daemon itself are
       excluded from inspection. Examples of such message headers
       are <b>From:</b>, <b>To:</b>, <b>Message-ID:</b>, <b>Date:</b>.

       Message  headers  deleted by the <a href="cleanup.8.html"><b>cleanup</b>(8)</a> daemon will be
       examined before they are deleted. Examples are: <b>Bcc:, Con-</b>
       <b>tent-Length:</b>, <b>Return-Path:</b>.

<b>CONFIGURATION PARAMETERS</b>
       <b><a href="postconf.5.html#body_checks">body_checks</a></b>
              Lookup tables with content filter rules for message
              body lines.  These filters see one physical line at
              a  time,  in  chunks  of at most <b>$<a href="postconf.5.html#line_length_limit">line_length_limit</a></b>
              bytes.

       <b><a href="postconf.5.html#body_checks_size_limit">body_checks_size_limit</a></b>
              The amount of  content  per  message  body  segment
              (attachment) that is subjected to <b>$<a href="postconf.5.html#body_checks">body_checks</a></b> fil-
              tering.

       <b><a href="postconf.5.html#header_checks">header_checks</a></b>

       <b><a href="postconf.5.html#mime_header_checks">mime_header_checks</a></b> (default: <b>$<a href="postconf.5.html#header_checks">header_checks</a></b>)

       <b><a href="postconf.5.html#nested_header_checks">nested_header_checks</a></b> (default: <b>$<a href="postconf.5.html#header_checks">header_checks</a></b>)
              Lookup tables with content filter rules for message
              header  lines:  respectively,  these are applied to
              the initial message  headers  (not  including  MIME
              headers),  to the MIME headers anywhere in the mes-
              sage, and to the initial headers of  attached  mes-
              sages.

              Note:  these filters see one logical message header
              at a time, even when a message header spans  multi-
              ple  lines.  Message  headers  that are longer than
              <b>$<a href="postconf.5.html#header_size_limit">header_size_limit</a></b> characters are truncated.

       <b><a href="postconf.5.html#disable_mime_input_processing">disable_mime_input_processing</a></b>
              While receiving mail, give no special treatment  to
              MIME  related  message  headers; all text after the
              initial message headers is considered to be part of
              the  message body. This means that <b><a href="postconf.5.html#header_checks">header_checks</a></b> is
              applied to all the  initial  message  headers,  and
              that <b><a href="postconf.5.html#body_checks">body_checks</a></b> is applied to the remainder of the
              message.

              Note: when used in this  manner,  <b><a href="postconf.5.html#body_checks">body_checks</a></b>  will
              process  a  multi-line message header one line at a
              time.

<b>EXAMPLES</b>
       Header pattern to block attachments  with  bad  file  name
       extensions.

       /etc/postfix/main.cf:
           <a href="postconf.5.html#header_checks">header_checks</a> = <a href="regexp_table.5.html">regexp</a>:/etc/postfix/header_checks

       /etc/postfix/header_checks:
           /^content-(type|disposition):.*name[[:space:]]*=.*\.(exe|vbs)/
               REJECT Bad attachment file name extension: $2

       Body pattern to stop a specific HTML browser vulnerability
       exploit.

       /etc/postfix/main.cf:
           <a href="postconf.5.html#body_checks">body_checks</a> = <a href="regexp_table.5.html">regexp</a>:/etc/postfix/body_checks

       /etc/postfix/body_checks:
           /^&lt;iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0&gt;$/
               REJECT IFRAME vulnerability exploit

<b>SEE ALSO</b>
       <a href="cleanup.8.html">cleanup(8)</a>, canonicalize and enqueue Postfix message
       <a href="pcre_table.5.html">pcre_table(5)</a>, format of PCRE lookup tables
       <a href="regexp_table.5.html">regexp_table(5)</a>, format of POSIX regular expression tables
       <a href="postconf.1.html">postconf(1)</a>, Postfix configuration utility
       <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table management
       <a href="postsuper.1.html">postsuper(1)</a>, Postfix janitor
       <a href="postcat.1.html">postcat(1)</a>, show Postfix queue file contents
       <a href="http://www.faqs.org/rfcs/rfc2045.html">RFC 2045</a>, base64 and quoted-printable encoding rules
       <a href="http://www.faqs.org/rfcs/rfc2047.html">RFC 2047</a>, message header encoding for non-ASCII text

<b>README FILES</b>
       <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
       <a href="CONTENT_INSPECTION_README.html">CONTENT_INSPECTION_README</a>, Postfix content inspection overview
       <a href="BUILTIN_FILTER_README.html">BUILTIN_FILTER_README</a>, Postfix built-in content inspection
       <a href="BACKSCATTER_README.html">BACKSCATTER_README</a>, blocking returned forged mail

<b>LICENSE</b>
       The  Secure  Mailer  license must be distributed with this
       software.

<b>AUTHOR(S)</b>
       Wietse Venema
       IBM T.J. Watson Research
       P.O. Box 704
       Yorktown Heights, NY 10598, USA

                                                              HEADER_CHECKS(5)
</pre> </body> </html>