amavisd-new

amavisd-new is a high-performance interface between mailer (MTA) and content checkers: virus scanners, and/or SpamAssasin. It is written in Perl for maintainability, without paying a significant price for speed. It talks to MTA via (E)SMTP or LMTP, or by using helper programs. Best with Postfix, works with Exim, sendmail/milter, or with any MTA as a SMTP relay. 'Howto' for qmail available as well.

Introduction

amavisd-new is a high-performance and reliable interface between mailer (MTA) and one or more content checkers: virus scanners, and/or Mail::SpamAssasin Perl module. It is written entirely in Perl, assuring high reliability, portability and maintainability. It talks to MTA via (E)SMTP or LMTP, or by using helper programs. No timing gaps exist in the design, which could cause a mail loss.

It is normally positioned at or near a central mailer, not necessarily where user's mailboxes and final delivery takes place. If you are looking for a per-user and low-message-rate solution to be placed at the final stage of mail delivery (e.g. called from procmail or in place of local delivery agent), there may be other solutions more appropriate for your needs.

When calling of Mail::SpamAssassin is enabled, it calls SA only once per message (regardless of the number of recipients), and tries very hard to correctly honor per-recipient preferences, such as pass/reject, and inserting spam-related mail header fields.

amavisd-new benefits from the use of Perl module Net::Server, which offers a fast pre-forked multichild environment. amavisd-new provides rfc2821-compliant SMTP server, rfc2033-compliant LMTP server, SMTP client, and generates rfc1892/rfc1894-compliant (non-)delivery status notifications. This makes it suitable for mail anti-virus and/or anti-spam checking on a busy mail gateways, that care for reliability and standards compliance.

amavisd-new grew out of amavisd(-snapshot) (which in turn is a daemonized version of amavis-perl), but over the year of development turned into a separate product, hardly resembling its origin. The code is about three times the size of its predecessor, yet faster in throughput, richer in features, compliant to standards, includes optional support for spam detection, and makes virus scanning optional. Compatibility with helper programs from amavisd(-snapshot) is retained.

All the modifications since the original amavisd done by Mark Martinec, with contribution of ideas and reports from amavis-user mailing list community.

News

amavisd-new-20030314-p1 (patch1) released (March 21, 2003). Please see the release notes. It seems to be as stable as amavisd-new-20021227, and fixes few long-standing problems (which did not affect many users, but still).

If currently using SpamAssassin 2.50 with Bayes enabled, and upgrading to SpamAssassin 2.51, the SA patches in http://spamassassin.kluge.net/patches/ must be applied, and the command sa-learn --force-expire must be manually run, before starting amavisd-new. This is because SA 2.50 didn't do bayes expirations on-the-fly, and without patches all amavisd-new child processes would try to run expire at the same time, causing lock contention and timeouts.

There is an updated README.chroot on the web page, which mentions some FreeBSD specifics and fixes some typos.

Older News

amavisd-new-20030314 is out.

The version 0.85 of Net::Server Perl module from March 7 2003 is breaking amavisd-new, causing 421 4.3.2 Service shutting down, closing channel. Please upgrade to amavisd-new-20030314 or stick with Net::Server 0.84 if using an older version.

Please see Security warning below.

There is an updated README.postfix on the web page, which takes into account the new recommended move of virtual alias mappings from (pre-)cleanup into regular cleanup Postfix service, as documented in the Postfix 2.0.3 ./README_FILES/FILTER_README.

qmail setup howto - see link in the documentation section.

Security warning

A security problem in Unix utility program file(1) has recently been found by iDEFENSE Labs. It permits a specially crafted message to access the system as a user running amavisd-new, typically amavis or vscan. As recommended in the setup instructions, this UID and GID should be dedicated to amavisd-new (possibly shared with virus scanners), so the extent of possible damage is limited. Furthermore, the problem does not affect setups where amavisd-new is not doing virus or banned file scanning, (e.g. serves only as an interface to SpamAssassin), or if $bypass_decode_parts is true. Nevertheless, it is heartly recommended to upgrade to the latest version of file(1), available from ftp://ftp.astron.com/pub/file/file-3.41.tar.gz

It is suspected that all versions up to and including file 3.39 are vulnerable.

More information: http://www.idefense.com/advisory/03.04.03.txt, http://www.securityfocus.org/archive/1/313837/2003-03-02/2003-03-08/0

For general security information regarding amavisd-new please see the section Security considerations below.

Download

amavisd-new-20030314-p1.tar.gz (md5 sum)
latest version of amavisd-new, with patch1-A and patch1-B already applied (for reference: patch1-A (mandatory), patch1-B (ldap), plus some documentation changes, and a new file bad_headers.patch for playing. Patches are described in the current RELEASE NOTES). Appears to be at least as stable as the previous release.

amavisd-new-20021227-p2.tar.gz (md5 sum)
previous version of amavisd-new (includes patch1 and patch2) (stable)
amavisd-new-20021116.tar.gz (md5 sum)
(a new features release, its mandatory patches: p1, p2, p3, p4, p5)
amavisd-new-20020630.tar.gz (md5 sum)
(mostly a development and new features release)
amavisd-new-20020517.tar.gz (md5 sum)
(with SpamAssasin optional support)

There are also packaged versions available, provided and supported only by their respective authors/maintainers:

FreeBSD port
in the System security software ports section (/usr/ports/security/amavisd-new). The latest port maintained by Blaz Zupan is based on amavisd-new-20021227-p2, previous port was based on amavisd-new-20020517.
Debian package amavisd-new 20021227p2-2
maintained by Brian May and Henrique de Moraes Holschuh, available at: http://packages.debian.org/unstable/mail/amavisd-new.html
Red Hat RPM packages AMaViS (amavisd and amavisd-new (older!) )
by Ramiro Morales, available at: http://www.rmorales.com.ar/rpms/amavis/

There may be other packaged version around, please let me know.

Note that the packaged versions may not be based on the most recent amavisd-new version.

Documentation

Besides this web page at http://www.ijs.si/software/amavisd/, the following files comprise the amavisd-new documentation. The web page documents may be more recent than the documentation distributed with the program.

How-to

Support

Check the amavis-user mailing list. Its archives are at http://marc.theaimsgroup.com/?l=amavis-user .

For questions about packaged versions please contact their maintainers and/or their bug-tracking mechanisms.

Features

-- general

-- performance

-- interfaces to MTA

-- user individuality, quarantine

-- anti-virus

Since amavisd-new-20021227 it is easier to individually enable/disable virus checking and spam checking.

-- anti-spam

Since amavisd-new-20021227 it is easier to individually enable/disable virus checking and spam checking.

-- other

Known problems

Recommended version of SpamAssassin is 2.50. It fixes known problems with 2.44 which caused cpu loops or process hangs when called from amavisd-new. Make sure to also apply patches (below) to Razor2 if using it from SpamAssassin, otherwise some taint-related failures can occur,

See below for problems with recognizing Yaha.K virus.

Versions of amavisd-new before 20030314 did not know how to override a locale settings, so a non-English locale would produce a non-RFC2822 -compliant date format (used in Received and Date header fields). Please set the environment variable LC_TIME to "C" before starting amavisd-new daemon, otherwise an illegal mail header field may be produced. This problem does not affect amavisd-new-20030314.

Tips and FAQ -- general

Tips and FAQ -- mail transfer agents (MTA)

Tips and FAQ -- virus scanners

Tips and FAQ -- spam scanners (Mail::SpamAssassin)

Tips and FAQ -- Net::Server

Security considerations

Security considerations for the host running amavisd-new

amavisd-new accepts mail from MTA, calls external Perl modules and forks external programs to decompress and decode message, classify its content, then the checked mail is either passed to MTA for delivery, or rejected and quarantined.

Any component of a program that comes in contact with unpredictable and possibly malicious mail/document content, must be careful not to let the content have any uncontrolled effect on the operation of the program, or its environment.

amavisd-new is written entirely in Perl, with taint mode Perl checking enabled. This in itself is a strong argument that the processing within amavisd-new (and Perl modules it calls) is not likely to be subject to buffer overruns, stack smashing, and other problems that are common source of security problems in programs written in languages like C.

Information coming from external world like SMTP envelope information, mail header and body contents, suggested MIME file names, etc., is only used by amavisd-new for operations that do not influence the program environment. For example, names of created temporary files are internally generated and never depend on suggested file names from MIME header. Mail addresses or other tainted information is never passed through shell to an external program.

The external Perl modules called by amavisd-new have not been thoroughly screened for possible security implications. They still benefit from the Perl environment, and the Perl taint mode checking is never turned off even when other Perl modules are executing, including SpamAssassin if enabled (which is a relatively complex piece of software). Perl modules that deal with decoding and checking of mail contents may be targets for malicious mail content, especially if they include code written in C, like decoding and uncompressing libraries, e.g. zlib and uudeview (Convert::UUlib).

External programs that get forked from amavisd-new to perform some decoding/uncompressing or classifying task, are the greatest potential threat to the safe operation of the host running amavisd-new. Some of these programs that are used to decode certain archive formats are quite complex, old or not maintained, and/or written by less security conscious authors. E.g. a recently discovered vulnerability is present in Unix utility file(1) - please upgrade file to 3.41 !!!

There is a tradeoff in deciding whether to call some external decoder: calling it may open a vulnerability at the host running amavisd-new; not calling it (and not decoding certain types of document) may cause virus checker to miss a malicious mail contents, increasing danger for the mail recipient, while reducing risk for the host running checks.

While it may be true that only powered-down computer, locked in a basement and disconnected from the network, is a completely secure computer, this is not practical to get any job done. Besides choosing your content filtering program to be written in Perl and using taint mode checks, there are other things one may do to reduce security threats to the computer running content filter:

Security considerations for the mail clients being protected

Running a virus checking content filter for each mail before it reaches the mail reader is an important line of defense against virus outbreaks and in protecting the (possibly not security conscious) recipients, or their mail readers or computer environment.

Not all malware is passed by e-mail. Several viruses or worms use multiple mechanisms to propagate itself, including WWW, sharing disks or 'content', social engineering, or even a floppy or CD carried in a back-pocket or distributed by magazines and software publishing houses.

Even in e-mail, malware may be carried in encrypted or scrambled form, or simply as a plain text, using social engineering techniques to persuade recipient to fetch or activate malware.

It is not possible to prevent user shooting himself in the foot, or to prevent a dedicated user to transfer malware. There should be a tradeoff in keeping e-mail useful, and protecting against threats.

The first line of defense (mail content filtering, firewall) must be complemented by defense mechanisms at the local user's desktop computer. This includes virus scanners run on PCs, keeping software up-to-date, doing backups, and educating users.

Malware does not have to play by the rules. There is nothing to prevent malware to generate a syntactically incorrect mail, to send it directly to some mailer and supplying forged SMTP informations, to poison DNS, perhaps even to use forged source IP address.

Content filter with virus scanner tries to decide if the mail under consideration will, or can, cause any bad effects on the recipient computer, often without knowing what mail reading software or what computer is used by recipients. This implies that while some mail may be decoded (by adhering to standards) into a harmless text, it might be decoded my some broken MUA into a virus or exploit, or cause MUA bug to be triggered during decoding/displaying the message. See Malformed email project for example.

Solving this problem would require content filter with virus scanner to emulate all known (and unknown?!) mail readers in the way they respond to malformed mail. While amavisd-new and other content filters try to anticipate some common problems, especially the ones practiced by currently known viruses, there is no guarantee that this approach is always successful.

Even now there are combinations of viruses and virus scanners (e.g. Yaha.K + Sophos) that fail to be detected due to a malformed MIME header, which gets decoded differently (and correctly, considering standards!) by MIME::Parser, yet certain mail readers decode it differently, forming up a virus. It sometimes helps to use more than one virus scanner (e.g. clamd along with some commercial virus scanner).

RFC 2046 defines a way to split sending one document into several e-mail messages, which can then be reassembled (automatically or manually) by MUA. The Content-Type values to look for are message/partial (and also message/external-body). Checking mail fragments individually for viruses can not reliably detect viruses, which only get reassembled into a recognizable form by the recipient's mail reader. Most virus scanners at the MTA level (including amavisd-new and all other variants of amavis*) check each mail independently from other messages, so the only protection to this threat is to ban these MIME content-types (see $banned_filename_re setting in amavisd.conf), or by disabling auto-reassembly at mail readers.

Protection against denial-of-service (DoS) attacks

Because amavisd-new tries to recursively unpack and decode each mail as deeply as possible, this may be abused by malware. The so-called mail bomb, e.g. 42.zip, is an example of such a malware. Such mail message, when fully decoded, can exceed available disk size several times, or consume a lot of time for decoding. Unless decoding is stopped at an earlier stage, it could cause the message to be retried over and over again, each time either hitting the disk full condition, or exceeding the allowed time limit.

amavisd-new has several configurable mechanism for limiting the amount of space consumed during decoding - see Section VI - Resource limitations in file amavisd.conf. When a message decoding exceeds the storage quota, the decoding stops, the virus scanning is not performed, but a header field is inserted, telling MTA to place the message 'on hold', or just pass it - the action depends on MTA configuration. This works well with Postfix, but may not be configurable with some other mailers.

Protection against mail loss

When a content filter is positioned in relation to MTA as a mail relay, accepting mail from MTA, and passing all checked mail to MTA for final delivery (e.g. Postfix, or non-milter sendmail setup), there are only two possible approaches that can prevent mail loss when unpredictable things happen:

amavisd-new chooses the second approach. Several alternative mail content filtering solutions based on Perl module Net::Server::SMTP can not guarantee not losing mail under certain circumstances, because they confirm mail reception before being in position to ensure a mail delivery or bounce.

Besides taking care of not losing mail, it is important the mail contents is not unintentionally changed, as could happen for example when disk is full, or communication or I/O errors occur. amavisd-new is very thorough in always checking the status of operations, e.g. all I/O operations, creating/deleting files, calling external programs, checking all SMTP response codes, etc. When a problem occur, amavisd-new tries to produce an error report in its log file that is as informative as practical. When the situation can not be corrected, a temporary failure (EX_TEMPFAIL, or 450 SMTP response) is generated, telling MTA to try again later.

The amavisd-new policy is to either deliver the mail, or to make sure the sender gets a non-delivery notification. It is possible to configure amavisd-new to disobey this policy for certain unwanted contents, e.g. only to quarantine spam and not generate bounces - but such a setting is not in the spirit of not losing mail.

amavisd-new may modify mail headers, but it never modifies mail body, even if configured to call SpamAssassin.


mm
Last updated: 2003-03-24

Valid HTML 4.0!