Manual Pages for UNIX Darwin command on man header_checks
MyWebUniversity

Manual Pages for UNIX Darwin command on man header_checks

HEADERCHECKS(5) HEADERCHECKS(5)

NAME

headerchecks - Postfix built-in header/body inspection

SYNOPSIS

hheeaaddeerrcchheecckkss == ppccrree:://eettcc//ppoossttffiixx//hheeaaddeerrcchheecckkss mmiimmeehheeaaddeerrcchheecckkss == ppccrree:://eettcc//ppoossttffiixx//mmiimmeehheeaaddeerrcchheecckkss nneesstteeddhheeaaddeerrcchheecckkss == ppccrree:://eettcc//ppoossttffiixx//nneesstteeddhheeaaddeerrcchheecckkss bbooddyycchheecckkss == ppccrree:://eettcc//ppoossttffiixx//bbooddyycchheecckkss

ppoossttmmaapp -ffqq ""string"" ppccrree:://eettcc//ppoossttffiixx//filename

ppoossttmmaapp -ffqq - ppccrree:://eettcc//ppoossttffiixx//filename

DESCRIPTION

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 implemented by the Postfix cclleeaannuupp(8) server.

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

Postfix header or bodychecks are designed to stop a flood of mail from worms or viruses; they do not decode attachments, and they do not unzip

archives. See the documents referenced below in the README FILES sec-

tion if you need more sophisticated content analysis.

Postfix supports four built-in content inspection classes:

hheeaaddeerrcchheecckkss These are applied to initial message headers (except for the headers that are processed with mmiimmeehheeaaddeerrcchheecckkss).

mmiimmeehheeaaddeerrcchheecckkss (default: $$hheeaaddeerrcchheecckkss)

These are applied to MIME related message headers only. This feature is available in Postfix 2.0 and later.

nneesstteeddhheeaaddeerrcchheecckkss (default: $$hheeaaddeerrcchheecckkss)

These are applied to message headers of attached email messages (except for the headers that are processed with mmiimmeehheeaaddeerrcchheecckkss). This feature is available in Postfix 2.0 and later. bbooddyycchheecckkss

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 content. Note: message headers are examined one logical header at a time, even

when a message header spans multiple lines. Body lines are always exam-

ined one line at a time. TTAABBLLEE FFOORRMMAATT This document assumes that header and bodychecks rules are specified in the form of Postfix regular expression lookup tables. Usually the

best performance is obtained with ppccrree (Perl Compatible Regular Expres-

sion) tables, but the slower rreeggeexxpp (POSIX regular expressions) support

is more widely available. Use the command ppoossttccoonnff -mm to find out what

lookup table types your Postfix system supports. The general format of Postfix regular expression tables is given below. For a discussion of specific pattern or flags syntax, see ppccrreettaabbllee(5) or rreeggeexxppttaabbllee(5), respectively. //pattern//flags action When pattern matches the input string, execute the corresponding action. See below for a list of possible actions. !!//pattern//flags action

When pattern does nnoott match the input string, execute the corre-

sponding action. iiff //pattern//flags eennddiiff Match the input string against the patterns between iiff and eennddiiff, if and only if the input string also matches pattern. The iiff..eennddiiff can nest. Note: do not prepend whitespace to patterns inside iiff..eennddiiff. iiff !!//pattern//flags eennddiiff Match the input string against the patterns between iiff and eennddiiff, if and only if the input string does nnoott match pattern. The iiff..eennddiiff 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. TTAABBLLEE SSEEAARRCCHH OORRDDEERR 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. TTEEXXTT SSUUBBSSTTIITTUUTTIIOONN Substitution of substrings from the matched expression into the action

string is possible using the conventional Perl syntax ($1, $2, etc.).

The macros in the result string may need to be written as ${n} or $(n)

if they aren't followed by whitespace. Note: since negated patterns (those preceded by !!) return a result when the expression does not match, substitutions are not available for negated patterns. AACCTTIIOONNSS Action names are case insensitive. They are shown in upper case for consistency with other Postfix documentation. DDIISSCCAARRDD optional text... Claim successful delivery and silently discard the message. Log the optional text if specified, otherwise log a generic message.

Note: this action disables further header or bodychecks inspec-

tion of the current message and affects all recipients. This feature is available in Postfix 2.0 and later. DDUUNNNNOO Pretend that the input line did not match any pattern, and inspect the next input line. This action can be used to shorten the table search. For backwards compatibility reasons, Postfix also accepts OOKK but it is (and always has been) treated as DDUUNNNNOO. This feature is available in Postfix 2.1 and later. FFIILLTTEERR transport:destination Write a content filter request to the queue file and inspect the next input line. After the complete message is received it will be sent through the specified external content filter. More information about external content filters is in the Postfix FILTERREADME file. Note: this action overrides the mmaaiinn..ccff ccoonntteennttffiilltteerr setting,

and affects all recipients of the message. In the case that mul-

tiple FFIILLTTEERR actions fire, only the last one is executed. This feature is available in Postfix 2.0 and later. HHOOLLDD optional text... Arrange for the message to be placed on the hhoolldd queue, and inspect the next input line. The message remains on hhoolldd 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 ppoossttccaatt(1) command, and can be destroyed or released with the ppoossttssuuppeerr(1) command. Note: this action affects all recipients of the message. This feature is available in Postfix 2.0 and later. IIGGNNOORREE Delete the current line from the input and inspect the next input line. PPRREEPPEENNDD text... Prepend one line with the specified text and inspect the next input line. Note: the prepended text is output immediately before the input that triggered the PPRREEPPEENNDD action. A body action cannot prepend a message header.

Note: this action cannot be used to prepend multi-line text.

This feature is available in Postfix 2.1 and later. RREEDDIIRREECCTT user@domain 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 FFIILLTTEERR action, and affects all recipients of the message. If multiple RREEDDIIRREECCTT actions fire, only the last one is executed. This feature is available in Postfix 2.1 and later. RREEJJEECCTT optional text... Reject the entire message. Reply with optional text... when the optional text is specified, otherwise reply with a generic error message.

Note: this action disables further header or bodychecks inspec-

tion of the current message and affects all recipients. WWAARRNN optional text...

Log a warning with the optional text... (or log a generic mes-

sage) and inspect the next input line. This action is useful for debugging and for testing a pattern before applying more drastic actions.

BUGS

Many people overlook the main limitations of header and bodychecks 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 (RFC 2045) then

the rules have to specified for the encoded form. Likewise, when mes-

sage headers are encoded (RFC 2047) then the rules need to be specified for the encoded form. Message headers added by the cclleeaannuupp(8) daemon itself are excluded from

inspection. Examples of such message headers are FFrroomm::, TToo::, MMeessssaaggee-

IIDD::, DDaattee::. Message headers deleted by the cclleeaannuupp(8) daemon will be examined

before they are deleted. Examples are: BBcccc::, CCoonntteenntt-LLeennggtthh::, RReettuurrnn-

PPaatthh::. CCOONNFFIIGGUURRAATTIIOONN PPAARRAAMMEETTEERRSS bbooddyycchheecckkss Lookup tables with content filter rules for message body lines. These filters see one physical line at a time, in chunks of at

most $$lliinneelleennggtthhlliimmiitt bytes.

bbooddyycchheecckkssssiizzeelliimmiitt The amount of content per message body segment (attachment) that

is subjected to $$bbooddyycchheecckkss filtering.

hheeaaddeerrcchheecckkss

mmiimmeehheeaaddeerrcchheecckkss (default: $$hheeaaddeerrcchheecckkss)

nneesstteeddhheeaaddeerrcchheecckkss (default: $$hheeaaddeerrcchheecckkss)

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 any-

where in the message, and to the initial headers of attached messages. Note: these filters see one logical message header at a time, even when a message header spans multiple lines. Message headers

that are longer than $$hheeaaddeerrssiizzeelliimmiitt characters are trun-

cated. ddiissaabblleemmiimmeeiinnppuuttpprroocceessssiinngg 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 hheeaaddeerrcchheecckkss is applied to all the initial message headers, and that bbooddyycchheecckkss is applied to the remainder of the message. Note: when used in this manner, bbooddyycchheecckkss will process a

multi-line message header one line at a time.

EEXXAAMMPPLLEESS Header pattern to block attachments with bad file name extensions. /etc/postfix/main.cf: headerchecks = regexp:/etc/postfix/headerchecks /etc/postfix/headerchecks:

/^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: bodychecks = regexp:/etc/postfix/bodychecks /etc/postfix/bodychecks:

/^