141fbaed0Stron#++ 241fbaed0Stron# NAME 341fbaed0Stron# header_checks 5 441fbaed0Stron# SUMMARY 541fbaed0Stron# Postfix built-in content inspection 641fbaed0Stron# SYNOPSIS 741fbaed0Stron# .nf 841fbaed0Stron# \fBheader_checks = pcre:/etc/postfix/header_checks\fR 941fbaed0Stron# \fBmime_header_checks = pcre:/etc/postfix/mime_header_checks\fR 1041fbaed0Stron# \fBnested_header_checks = pcre:/etc/postfix/nested_header_checks\fR 1141fbaed0Stron# \fBbody_checks = pcre:/etc/postfix/body_checks\fR 1241fbaed0Stron# .sp 13ff6d749dStron# \fBmilter_header_checks = pcre:/etc/postfix/milter_header_checks\fR 14ff6d749dStron# .sp 15ff6d749dStron# \fBsmtp_header_checks = pcre:/etc/postfix/smtp_header_checks\fR 16ff6d749dStron# \fBsmtp_mime_header_checks = pcre:/etc/postfix/smtp_mime_header_checks\fR 17ff6d749dStron# \fBsmtp_nested_header_checks = pcre:/etc/postfix/smtp_nested_header_checks\fR 18ff6d749dStron# \fBsmtp_body_checks = pcre:/etc/postfix/smtp_body_checks\fR 19ff6d749dStron# .sp 2041fbaed0Stron# \fBpostmap -q "\fIstring\fB" pcre:/etc/postfix/\fIfilename\fR 2141fbaed0Stron# \fBpostmap -q - pcre:/etc/postfix/\fIfilename\fR <\fIinputfile\fR 2241fbaed0Stron# .fi 2341fbaed0Stron# DESCRIPTION 2441fbaed0Stron# This document describes access control on the content of 2541fbaed0Stron# message headers and message body lines; it is implemented 2641fbaed0Stron# by the Postfix \fBcleanup\fR(8) server before mail is queued. 2741fbaed0Stron# See \fBaccess\fR(5) for access control on remote SMTP client 2841fbaed0Stron# information. 2941fbaed0Stron# 3041fbaed0Stron# Each message header or message body line is compared against 3141fbaed0Stron# a list of patterns. 3241fbaed0Stron# When a match is found the corresponding action is executed, and 3341fbaed0Stron# the matching process is repeated for the next message header or 3441fbaed0Stron# message body line. 3541fbaed0Stron# 36ff6d749dStron# Note: message headers are examined one logical header at a time, 37ff6d749dStron# even when a message header spans multiple lines. Body lines are 38ff6d749dStron# always examined one line at a time. 39ff6d749dStron# 4041fbaed0Stron# For examples, see the EXAMPLES section at the end of this 4141fbaed0Stron# manual page. 4241fbaed0Stron# 4341fbaed0Stron# Postfix header or body_checks are designed to stop a flood of mail 4441fbaed0Stron# from worms or viruses; they do not decode attachments, and they do 4541fbaed0Stron# not unzip archives. See the documents referenced below in the README 4641fbaed0Stron# FILES section if you need more sophisticated content analysis. 47ff6d749dStron# FILTERS WHILE RECEIVING MAIL 48ff6d749dStron# .ad 49ff6d749dStron# .fi 50ff6d749dStron# Postfix implements the following four built-in content 51ff6d749dStron# inspection classes while receiving mail: 52ff6d749dStron# .IP "\fBheader_checks\fR (default: empty)" 5341fbaed0Stron# These are applied to initial message headers (except for 5441fbaed0Stron# the headers that are processed with \fBmime_header_checks\fR). 5541fbaed0Stron# .IP "\fBmime_header_checks\fR (default: \fB$header_checks\fR)" 5641fbaed0Stron# These are applied to MIME related message headers only. 5741fbaed0Stron# .sp 5841fbaed0Stron# This feature is available in Postfix 2.0 and later. 5941fbaed0Stron# .IP "\fBnested_header_checks\fR (default: \fB$header_checks\fR)" 6041fbaed0Stron# These are applied to message headers of attached email 6141fbaed0Stron# messages (except for the headers that are processed with 6241fbaed0Stron# \fBmime_header_checks\fR). 6341fbaed0Stron# .sp 6441fbaed0Stron# This feature is available in Postfix 2.0 and later. 6541fbaed0Stron# .IP \fBbody_checks\fR 6641fbaed0Stron# These are applied to all other content, including multi-part 6741fbaed0Stron# message boundaries. 6841fbaed0Stron# .sp 6941fbaed0Stron# With Postfix versions before 2.0, all content after the initial 7041fbaed0Stron# message headers is treated as body content. 71ff6d749dStron# FILTERS AFTER RECEIVING MAIL 72ff6d749dStron# .ad 73ff6d749dStron# .fi 74ff6d749dStron# Postfix supports a subset of the built-in content inspection 75ff6d749dStron# classes after the message is received: 76ff6d749dStron# .IP "\fBmilter_header_checks\fR (default: empty)" 77ff6d749dStron# These are applied to headers that are added with Milter 78ff6d749dStron# applications. 79ff6d749dStron# .sp 80ff6d749dStron# This feature is available in Postfix 2.7 and later. 81ff6d749dStron# FILTERS WHILE DELIVERING MAIL 82ff6d749dStron# .ad 83ff6d749dStron# .fi 84ff6d749dStron# Postfix supports all four content inspection classes while 85ff6d749dStron# delivering mail via SMTP. 86ff6d749dStron# .IP "\fBsmtp_header_checks\fR (default: empty)" 87ff6d749dStron# .IP "\fBsmtp_mime_header_checks\fR (default: empty)" 88ff6d749dStron# .IP "\fBsmtp_nested_header_checks\fR (default: empty)" 89ff6d749dStron# .IP "\fBsmtp_body_checks\fR (default: empty)" 90ff6d749dStron# These features are available in Postfix 2.5 and later. 9141fbaed0Stron# COMPATIBILITY 9241fbaed0Stron# .ad 9341fbaed0Stron# .fi 9441fbaed0Stron# With Postfix version 2.2 and earlier specify "\fBpostmap 9541fbaed0Stron# -fq\fR" to query a table that contains case sensitive 9641fbaed0Stron# patterns. By default, regexp: and pcre: patterns are case 9741fbaed0Stron# insensitive. 9841fbaed0Stron# TABLE FORMAT 9941fbaed0Stron# .ad 10041fbaed0Stron# .fi 10141fbaed0Stron# This document assumes that header and body_checks rules are specified 10241fbaed0Stron# in the form of Postfix regular expression lookup tables. Usually the 10341fbaed0Stron# best performance is obtained with \fBpcre\fR (Perl Compatible Regular 104e6ca80d4Stron# Expression) tables. The \fBregexp\fR (POSIX regular 105e6ca80d4Stron# expressions) tables are usually slower, but more widely 106e6ca80d4Stron# available. 10741fbaed0Stron# Use the command "\fBpostconf -m\fR" to find out what lookup table 10841fbaed0Stron# types your Postfix system supports. 10941fbaed0Stron# 11041fbaed0Stron# The general format of Postfix regular expression tables is 11141fbaed0Stron# given below. 11241fbaed0Stron# For a discussion of specific pattern or flags syntax, 11341fbaed0Stron# see \fBpcre_table\fR(5) or \fBregexp_table\fR(5), respectively. 11441fbaed0Stron# .IP "\fB/\fIpattern\fB/\fIflags action\fR" 11541fbaed0Stron# When /\fIpattern\fR/ matches the input string, execute 11641fbaed0Stron# the corresponding \fIaction\fR. See below for a list 11741fbaed0Stron# of possible actions. 11841fbaed0Stron# .IP "\fB!/\fIpattern\fB/\fIflags action\fR" 11941fbaed0Stron# When /\fIpattern\fR/ does \fBnot\fR match the input string, 12041fbaed0Stron# execute the corresponding \fIaction\fR. 12141fbaed0Stron# .IP "\fBif /\fIpattern\fB/\fIflags\fR" 12241fbaed0Stron# .IP "\fBendif\fR" 123e262b48eSchristos# If the input string matches /\fIpattern\fR/, then match that 124e262b48eSchristos# input string against the patterns between \fBif\fR and 125e262b48eSchristos# \fBendif\fR. The \fBif\fR..\fBendif\fR can nest. 12641fbaed0Stron# .sp 12741fbaed0Stron# Note: do not prepend whitespace to patterns inside 12841fbaed0Stron# \fBif\fR..\fBendif\fR. 12941fbaed0Stron# .IP "\fBif !/\fIpattern\fB/\fIflags\fR" 13041fbaed0Stron# .IP "\fBendif\fR" 131e262b48eSchristos# If the input string does not match /\fIpattern\fR/, then 132e262b48eSchristos# match that input string against the patterns between \fBif\fR 133e262b48eSchristos# and \fBendif\fR. The \fBif\fR..\fBendif\fR can nest. 13441fbaed0Stron# .IP "blank lines and comments" 13541fbaed0Stron# Empty lines and whitespace-only lines are ignored, as 13641fbaed0Stron# are lines whose first non-whitespace character is a `#'. 13741fbaed0Stron# .IP "multi-line text" 13841fbaed0Stron# A pattern/action line starts with non-whitespace text. A line that 13941fbaed0Stron# starts with whitespace continues a logical line. 14041fbaed0Stron# TABLE SEARCH ORDER 14141fbaed0Stron# .ad 14241fbaed0Stron# .fi 14341fbaed0Stron# For each line of message input, the patterns are applied in the 14441fbaed0Stron# order as specified in the table. When a pattern is found that matches 14541fbaed0Stron# the input line, the corresponding action is executed and then the 14641fbaed0Stron# next input line is inspected. 14741fbaed0Stron# TEXT SUBSTITUTION 14841fbaed0Stron# .ad 14941fbaed0Stron# .fi 15041fbaed0Stron# Substitution of substrings from the matched expression into the 15141fbaed0Stron# \fIaction\fR 15241fbaed0Stron# string is possible using the conventional Perl syntax 15341fbaed0Stron# (\fB$1\fR, \fB$2\fR, etc.). 15441fbaed0Stron# The macros in the result string may need to be written as \fB${n}\fR 15541fbaed0Stron# or \fB$(n)\fR if they aren't followed by whitespace. 15641fbaed0Stron# 15741fbaed0Stron# Note: since negated patterns (those preceded by \fB!\fR) return a 15841fbaed0Stron# result when the expression does not match, substitutions are not 15941fbaed0Stron# available for negated patterns. 16041fbaed0Stron# ACTIONS 16141fbaed0Stron# .ad 16241fbaed0Stron# .fi 16341fbaed0Stron# Action names are case insensitive. They are shown in upper case 16441fbaed0Stron# for consistency with other Postfix documentation. 165e262b48eSchristos# .IP "\fBBCC \fIuser@domain\fR" 166e262b48eSchristos# Add the specified address as a BCC recipient, and inspect 167e262b48eSchristos# the next input line. The address 168e262b48eSchristos# must have a local part and domain part. The number of BCC 169e262b48eSchristos# addresses that can be added is limited only by the amount 170e262b48eSchristos# of available storage space. 171e262b48eSchristos# 172e262b48eSchristos# Note 1: the BCC address is added as if it was specified with 173e262b48eSchristos# NOTIFY=NONE. The sender will not be notified when the BCC 174e262b48eSchristos# address is undeliverable, as long as all down-stream software 175e262b48eSchristos# implements RFC 3461. 176e262b48eSchristos# 177e262b48eSchristos# Note 2: this ignores duplicate addresses (with the same 178e262b48eSchristos# delivery status notification options). 179e262b48eSchristos# .sp 180e262b48eSchristos# This feature is available in Postfix 3.0 and later. 181e262b48eSchristos# .sp 182e262b48eSchristos# This feature is not supported with smtp header/body checks. 18341fbaed0Stron# \" .IP "\fBDELAY \fItime\fR" 18441fbaed0Stron# \" Place the message into the deferred queue, and delay the 18541fbaed0Stron# \" initial delivery attempt by \fItime\fR. The time value may 18641fbaed0Stron# \" be followed by a one-character suffix that specifies the 18741fbaed0Stron# \" time unit: s (seconds), m (minutes), h (hours), d (days), 18841fbaed0Stron# \" w (weeks). The default time unit is s (seconds). 18941fbaed0Stron# \" .sp 19041fbaed0Stron# \" Limitations: 19141fbaed0Stron# \" .RS 19241fbaed0Stron# \" .IP \(bu 19341fbaed0Stron# \" This action affects all the recipients of the message. 19441fbaed0Stron# \" .IP \(bu 19541fbaed0Stron# \" The delay value has no effect with remote file systems that 19641fbaed0Stron# \" don't correctly emulate UNIX local file system semantics. 19741fbaed0Stron# \" In that case, the delay will be half of $queue_run_delay 19841fbaed0Stron# \" on average. 19941fbaed0Stron# \" .IP \(bu 20041fbaed0Stron# \" Mail will still be delivered with "sendmail -q", "postfix 20141fbaed0Stron# \" flush" or "postqueue -f". 20241fbaed0Stron# \" .IP \(bu 20341fbaed0Stron# \" Delayed mail increases the amount of disk I/O during deferred 20441fbaed0Stron# \" queue scans. When large amounts of mail are queued for 20541fbaed0Stron# \" delayed delivery it may be preferable to use the HOLD feature 20641fbaed0Stron# \" instead. 20741fbaed0Stron# \" .RE 20841fbaed0Stron# \" .IP 20941fbaed0Stron# \" This feature is available in Postfix 2.3 and later. 21041fbaed0Stron# .IP "\fBDISCARD \fIoptional text...\fR" 21141fbaed0Stron# Claim successful delivery and silently discard the message. 212e262b48eSchristos# Do not inspect the remainder of the input message. 21341fbaed0Stron# Log the optional text if specified, otherwise log a generic 21441fbaed0Stron# message. 21541fbaed0Stron# .sp 21641fbaed0Stron# Note: this action disables further header or body_checks inspection 21741fbaed0Stron# of the current message and affects all recipients. 21841fbaed0Stron# To discard only one recipient without discarding the entire message, 21941fbaed0Stron# use the transport(5) table to direct mail to the discard(8) service. 22041fbaed0Stron# .sp 22141fbaed0Stron# This feature is available in Postfix 2.0 and later. 222ff6d749dStron# .sp 223ff6d749dStron# This feature is not supported with smtp header/body checks. 22441fbaed0Stron# .IP \fBDUNNO\fR 22541fbaed0Stron# Pretend that the input line did not match any pattern, and inspect the 22641fbaed0Stron# next input line. This action can be used to shorten the table search. 22741fbaed0Stron# .sp 22841fbaed0Stron# For backwards compatibility reasons, Postfix also accepts 22941fbaed0Stron# \fBOK\fR but it is (and always has been) treated as \fBDUNNO\fR. 23041fbaed0Stron# .sp 23141fbaed0Stron# This feature is available in Postfix 2.1 and later. 23241fbaed0Stron# .IP "\fBFILTER \fItransport:destination\fR" 233e262b48eSchristos# Override the content_filter parameter setting, and inspect 234e262b48eSchristos# the next input line. 23528e9a2d2Stron# After the message is queued, send the entire message through 23628e9a2d2Stron# the specified external content filter. The \fItransport\fR 23728e9a2d2Stron# name specifies the first field of a mail delivery agent 23828e9a2d2Stron# definition in master.cf; the syntax of the next-hop 23928e9a2d2Stron# \fIdestination\fR is described in the manual page of the 24028e9a2d2Stron# corresponding delivery agent. More information about 24128e9a2d2Stron# external content filters is in the Postfix FILTER_README 24228e9a2d2Stron# file. 24341fbaed0Stron# .sp 24428e9a2d2Stron# Note 1: do not use $\fInumber\fR regular expression 24528e9a2d2Stron# substitutions for \fItransport\fR or \fIdestination\fR 24628e9a2d2Stron# unless you know that the information has a trusted origin. 24728e9a2d2Stron# .sp 24828e9a2d2Stron# Note 2: this action overrides the main.cf \fBcontent_filter\fR 24928e9a2d2Stron# setting, and affects all recipients of the message. In the 25028e9a2d2Stron# case that multiple \fBFILTER\fR actions fire, only the last 25128e9a2d2Stron# one is executed. 25228e9a2d2Stron# .sp 25328e9a2d2Stron# Note 3: the purpose of the FILTER command is to override 25428e9a2d2Stron# message routing. To override the recipient's \fItransport\fR 25528e9a2d2Stron# but not the next-hop \fIdestination\fR, specify an empty 25628e9a2d2Stron# filter \fIdestination\fR (Postfix 2.7 and later), or specify 25728e9a2d2Stron# a \fItransport:destination\fR that delivers through a 25828e9a2d2Stron# different Postfix instance (Postfix 2.6 and earlier). Other 25928e9a2d2Stron# options are using the recipient-dependent \fBtrans\%port\%_maps\fR 26028e9a2d2Stron# or the sen\%der-dependent 26128e9a2d2Stron# \fBsender\%_de\%pen\%dent\%_de\%fault\%_trans\%port\%_maps\fR 26228e9a2d2Stron# features. 26341fbaed0Stron# .sp 26441fbaed0Stron# This feature is available in Postfix 2.0 and later. 265ff6d749dStron# .sp 266ff6d749dStron# This feature is not supported with smtp header/body checks. 26741fbaed0Stron# .IP "\fBHOLD \fIoptional text...\fR" 26841fbaed0Stron# Arrange for the message to be placed on the \fBhold\fR queue, 26941fbaed0Stron# and inspect the next input line. The message remains on \fBhold\fR 27041fbaed0Stron# until someone either deletes it or releases it for delivery. 27141fbaed0Stron# Log the optional text if specified, otherwise log a generic 27241fbaed0Stron# message. 27341fbaed0Stron# 27441fbaed0Stron# Mail that is placed on hold can be examined with the 27541fbaed0Stron# \fBpostcat\fR(1) command, and can be destroyed or released with 27641fbaed0Stron# the \fBpostsuper\fR(1) command. 27741fbaed0Stron# .sp 27841fbaed0Stron# Note: use "\fBpostsuper -r\fR" to release mail that was kept on 27941fbaed0Stron# hold for a significant fraction of \fB$maximal_queue_lifetime\fR 28041fbaed0Stron# or \fB$bounce_queue_lifetime\fR, or longer. Use "\fBpostsuper -H\fR" 28141fbaed0Stron# only for mail that will not expire within a few delivery attempts. 28241fbaed0Stron# .sp 28341fbaed0Stron# Note: this action affects all recipients of the message. 28441fbaed0Stron# .sp 28541fbaed0Stron# This feature is available in Postfix 2.0 and later. 286ff6d749dStron# .sp 287ff6d749dStron# This feature is not supported with smtp header/body checks. 28841fbaed0Stron# .IP \fBIGNORE\fR 28941fbaed0Stron# Delete the current line from the input, and inspect 290*f3bc92a4Schristos# the next input line. See \fBSTRIP\fR for an alternative 291*f3bc92a4Schristos# that logs the action. 292ff6d749dStron# .IP "\fBINFO \fIoptional text...\fR 293ff6d749dStron# Log an "info:" record with the \fIoptional text...\fR (or 294ff6d749dStron# log a generic text), and inspect the next input line. This 295ff6d749dStron# action is useful for routine logging or for debugging. 296ff6d749dStron# .sp 297ff6d749dStron# This feature is available in Postfix 2.8 and later. 298*f3bc92a4Schristos# .IP "\fBPASS \fIoptional text...\fR" 299*f3bc92a4Schristos# Log a "pass:" record with the \fIoptional text...\fR (or 300*f3bc92a4Schristos# log a generic text), and turn off header, body, and Milter 301*f3bc92a4Schristos# inspection for the remainder of this message. 302*f3bc92a4Schristos# .sp 303*f3bc92a4Schristos# Note: this feature relies on trust in information that is 304*f3bc92a4Schristos# easy to forge. 305*f3bc92a4Schristos# .sp 306*f3bc92a4Schristos# This feature is available in Postfix 3.2 and later. 307*f3bc92a4Schristos# .sp 308*f3bc92a4Schristos# This feature is not supported with smtp header/body checks. 30941fbaed0Stron# .IP "\fBPREPEND \fItext...\fR" 31041fbaed0Stron# Prepend one line with the specified text, and inspect the next 31141fbaed0Stron# input line. 31241fbaed0Stron# .sp 31341fbaed0Stron# Notes: 31441fbaed0Stron# .RS 31541fbaed0Stron# .IP \(bu 31641fbaed0Stron# The prepended text is output on a separate line, immediately 31741fbaed0Stron# before the input that triggered the \fBPREPEND\fR action. 31841fbaed0Stron# .IP \(bu 31941fbaed0Stron# The prepended text is not considered part of the input 32041fbaed0Stron# stream: it is not subject to header/body checks or address 32141fbaed0Stron# rewriting, and it does not affect the way that Postfix adds 32241fbaed0Stron# missing message headers. 32341fbaed0Stron# .IP \(bu 32441fbaed0Stron# When prepending text before a message header line, the prepended 32541fbaed0Stron# text must begin with a valid message header label. 32641fbaed0Stron# .IP \(bu 32741fbaed0Stron# This action cannot be used to prepend multi-line text. 32841fbaed0Stron# .RE 32941fbaed0Stron# .IP 33041fbaed0Stron# This feature is available in Postfix 2.1 and later. 331ff6d749dStron# .sp 332ff6d749dStron# This feature is not supported with milter_header_checks. 33341fbaed0Stron# .IP "\fBREDIRECT \fIuser@domain\fR" 33441fbaed0Stron# Write a message redirection request to the queue file, and 33541fbaed0Stron# inspect the next input line. After the message is queued, 33641fbaed0Stron# it will be sent to the specified address instead of the 33741fbaed0Stron# intended recipient(s). 33841fbaed0Stron# .sp 33941fbaed0Stron# Note: this action overrides the \fBFILTER\fR action, and affects 34041fbaed0Stron# all recipients of the message. If multiple \fBREDIRECT\fR actions 34141fbaed0Stron# fire, only the last one is executed. 34241fbaed0Stron# .sp 34341fbaed0Stron# This feature is available in Postfix 2.1 and later. 344ff6d749dStron# .sp 345ff6d749dStron# This feature is not supported with smtp header/body checks. 34641fbaed0Stron# .IP "\fBREPLACE \fItext...\fR" 34741fbaed0Stron# Replace the current line with the specified text, and inspect the next 34841fbaed0Stron# input line. 34941fbaed0Stron# .sp 35041fbaed0Stron# This feature is available in Postfix 2.2 and later. The 35141fbaed0Stron# description below applies to Postfix 2.2.2 and later. 35241fbaed0Stron# .sp 35341fbaed0Stron# Notes: 35441fbaed0Stron# .RS 35541fbaed0Stron# .IP \(bu 35641fbaed0Stron# When replacing a message header line, the replacement text 35741fbaed0Stron# must begin with a valid header label. 35841fbaed0Stron# .IP \(bu 35941fbaed0Stron# The replaced text remains part of the input stream. Unlike 36041fbaed0Stron# the result from the \fBPREPEND\fR action, a replaced message 36141fbaed0Stron# header may be subject to address rewriting and may affect 36241fbaed0Stron# the way that Postfix adds missing message headers. 36341fbaed0Stron# .RE 36441fbaed0Stron# .IP "\fBREJECT \fIoptional text...\fR 365e262b48eSchristos# Reject the entire message. Do not inspect the remainder of 366e262b48eSchristos# the input message. Reply with \fIoptional text...\fR when 367e262b48eSchristos# the optional text is specified, otherwise reply with a 368e262b48eSchristos# generic error message. 36941fbaed0Stron# .sp 37041fbaed0Stron# Note: this action disables further header or body_checks inspection 37141fbaed0Stron# of the current message and affects all recipients. 37241fbaed0Stron# .sp 37341fbaed0Stron# Postfix version 2.3 and later support enhanced status codes. 37441fbaed0Stron# When no code is specified at the beginning of \fIoptional 37541fbaed0Stron# text...\fR, Postfix inserts a default enhanced status code of 37641fbaed0Stron# "5.7.1". 377ff6d749dStron# .sp 378ff6d749dStron# This feature is not supported with smtp header/body checks. 379*f3bc92a4Schristos# .IP "\fBSTRIP \fIoptional text...\fR" 380*f3bc92a4Schristos# Log a "strip:" record with the \fIoptional text...\fR (or 381*f3bc92a4Schristos# log a generic text), delete the input line from the input, 382*f3bc92a4Schristos# and inspect the next input line. See \fBIGNORE\fR for a 383*f3bc92a4Schristos# silent alternative. 384*f3bc92a4Schristos# .sp 385*f3bc92a4Schristos# This feature is available in Postfix 3.2 and later. 38641fbaed0Stron# .IP "\fBWARN \fIoptional text...\fR 387ff6d749dStron# Log a "warning:" record with the \fIoptional text...\fR (or 388ff6d749dStron# log a generic text), and inspect the next input line. This 38941fbaed0Stron# action is useful for debugging and for testing a pattern 39041fbaed0Stron# before applying more drastic actions. 39141fbaed0Stron# BUGS 39241fbaed0Stron# Empty lines never match, because some map types mis-behave 39341fbaed0Stron# when given a zero-length search string. This limitation may 39441fbaed0Stron# be removed for regular expression tables in a future release. 39541fbaed0Stron# 39641fbaed0Stron# Many people overlook the main limitations of header and body_checks 39741fbaed0Stron# rules. 39841fbaed0Stron# .IP \(bu 39941fbaed0Stron# These rules operate on one logical message header or one body 40041fbaed0Stron# line at a time. A decision made for one line is not carried over 40141fbaed0Stron# to the next line. 40241fbaed0Stron# .IP \(bu 40341fbaed0Stron# If text in the message body is encoded 40441fbaed0Stron# (RFC 2045) then the rules need to be specified for the encoded 40541fbaed0Stron# form. 40641fbaed0Stron# .IP \(bu 40741fbaed0Stron# Likewise, when message headers are encoded (RFC 40841fbaed0Stron# 2047) then the rules need to be specified for the encoded 40941fbaed0Stron# form. 41041fbaed0Stron# .PP 41141fbaed0Stron# Message headers added by the \fBcleanup\fR(8) daemon itself 41241fbaed0Stron# are excluded from inspection. Examples of such message headers 41341fbaed0Stron# are \fBFrom:\fR, \fBTo:\fR, \fBMessage-ID:\fR, \fBDate:\fR. 41441fbaed0Stron# 41541fbaed0Stron# Message headers deleted by the \fBcleanup\fR(8) daemon will 41616d67a18Stron# be examined before they are deleted. Examples are: \fBBcc:\fR, 41741fbaed0Stron# \fBContent-Length:\fR, \fBReturn-Path:\fR. 41841fbaed0Stron# CONFIGURATION PARAMETERS 41941fbaed0Stron# .ad 42041fbaed0Stron# .fi 42141fbaed0Stron# .IP \fBbody_checks\fR 42241fbaed0Stron# Lookup tables with content filter rules for message body lines. 42341fbaed0Stron# These filters see one physical line at a time, in chunks of 42441fbaed0Stron# at most \fB$line_length_limit\fR bytes. 42541fbaed0Stron# .IP \fBbody_checks_size_limit\fP 42641fbaed0Stron# The amount of content per message body segment (attachment) that is 42741fbaed0Stron# subjected to \fB$body_checks\fR filtering. 42841fbaed0Stron# .IP \fBheader_checks\fR 42941fbaed0Stron# .IP "\fBmime_header_checks\fR (default: \fB$header_checks\fR)" 43041fbaed0Stron# .IP "\fBnested_header_checks\fR (default: \fB$header_checks\fR)" 43141fbaed0Stron# Lookup tables with content filter rules for message header lines: 43241fbaed0Stron# respectively, these are applied to the initial message headers 43341fbaed0Stron# (not including MIME headers), to the MIME headers anywhere in 43441fbaed0Stron# the message, and to the initial headers of attached messages. 43541fbaed0Stron# .sp 43641fbaed0Stron# Note: these filters see one logical message header at a time, even 43741fbaed0Stron# when a message header spans multiple lines. Message headers that 43841fbaed0Stron# are longer than \fB$header_size_limit\fR characters are truncated. 43941fbaed0Stron# .IP \fBdisable_mime_input_processing\fR 44041fbaed0Stron# While receiving mail, give no special treatment to MIME related 44141fbaed0Stron# message headers; all text after the initial message headers is 44241fbaed0Stron# considered to be part of the message body. This means that 44341fbaed0Stron# \fBheader_checks\fR is applied to all the initial message headers, 44441fbaed0Stron# and that \fBbody_checks\fR is applied to the remainder of the 44541fbaed0Stron# message. 44641fbaed0Stron# .sp 44741fbaed0Stron# Note: when used in this manner, \fBbody_checks\fR will process 44841fbaed0Stron# a multi-line message header one line at a time. 44941fbaed0Stron# EXAMPLES 45041fbaed0Stron# .ad 45141fbaed0Stron# .fi 45241fbaed0Stron# Header pattern to block attachments with bad file name 45341fbaed0Stron# extensions. For convenience, the PCRE /x flag is specified, 45441fbaed0Stron# so that there is no need to collapse the pattern into a 45541fbaed0Stron# single line of text. The purpose of the [[:xdigit:]] 45641fbaed0Stron# sub-expressions is to recognize Windows CLSID strings. 45741fbaed0Stron# 45841fbaed0Stron# .na 45941fbaed0Stron# .nf 46041fbaed0Stron# /etc/postfix/main.cf: 46141fbaed0Stron# header_checks = pcre:/etc/postfix/header_checks.pcre 46241fbaed0Stron# 46341fbaed0Stron# /etc/postfix/header_checks.pcre: 464e262b48eSchristos# /^Content-(Disposition|Type).*name\es*=\es*"?([^;]*(\e.|=2E)( 46541fbaed0Stron# ade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|dll|exe| 46641fbaed0Stron# hlp|ht[at]| 46741fbaed0Stron# inf|ins|isp|jse?|lnk|md[betw]|ms[cipt]|nws| 46841fbaed0Stron# \e{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\e}| 46941fbaed0Stron# ops|pcd|pif|prf|reg|sc[frt]|sh[bsm]|swf| 47041fbaed0Stron# vb[esx]?|vxd|ws[cfh]))(\e?=)?"?\es*(;|$)/x 47141fbaed0Stron# REJECT Attachment name "$2" may not end with ".$4" 47241fbaed0Stron# .ad 47341fbaed0Stron# .fi 47441fbaed0Stron# 47541fbaed0Stron# Body pattern to stop a specific HTML browser vulnerability exploit. 47641fbaed0Stron# 47741fbaed0Stron# .na 47841fbaed0Stron# .nf 47941fbaed0Stron# /etc/postfix/main.cf: 48041fbaed0Stron# body_checks = regexp:/etc/postfix/body_checks 48141fbaed0Stron# 48241fbaed0Stron# /etc/postfix/body_checks: 48341fbaed0Stron# /^<iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0>$/ 48441fbaed0Stron# REJECT IFRAME vulnerability exploit 48541fbaed0Stron# SEE ALSO 48641fbaed0Stron# cleanup(8), canonicalize and enqueue Postfix message 48741fbaed0Stron# pcre_table(5), format of PCRE lookup tables 48841fbaed0Stron# regexp_table(5), format of POSIX regular expression tables 48941fbaed0Stron# postconf(1), Postfix configuration utility 49041fbaed0Stron# postmap(1), Postfix lookup table management 49141fbaed0Stron# postsuper(1), Postfix janitor 49241fbaed0Stron# postcat(1), show Postfix queue file contents 49341fbaed0Stron# RFC 2045, base64 and quoted-printable encoding rules 49441fbaed0Stron# RFC 2047, message header encoding for non-ASCII text 49541fbaed0Stron# README FILES 49641fbaed0Stron# .ad 49741fbaed0Stron# .fi 49841fbaed0Stron# Use "\fBpostconf readme_directory\fR" or 49941fbaed0Stron# "\fBpostconf html_directory\fR" to locate this information. 50041fbaed0Stron# .na 50141fbaed0Stron# .nf 50241fbaed0Stron# DATABASE_README, Postfix lookup table overview 50341fbaed0Stron# CONTENT_INSPECTION_README, Postfix content inspection overview 50441fbaed0Stron# BUILTIN_FILTER_README, Postfix built-in content inspection 50541fbaed0Stron# BACKSCATTER_README, blocking returned forged mail 50641fbaed0Stron# LICENSE 50741fbaed0Stron# .ad 50841fbaed0Stron# .fi 50941fbaed0Stron# The Secure Mailer license must be distributed with this software. 51041fbaed0Stron# AUTHOR(S) 51141fbaed0Stron# Wietse Venema 51241fbaed0Stron# IBM T.J. Watson Research 51341fbaed0Stron# P.O. Box 704 51441fbaed0Stron# Yorktown Heights, NY 10598, USA 515e262b48eSchristos# 516e262b48eSchristos# Wietse Venema 517e262b48eSchristos# Google, Inc. 518e262b48eSchristos# 111 8th Avenue 519e262b48eSchristos# New York, NY 10011, USA 52041fbaed0Stron#-- 521