The email virus filter wrapper for ClamAV, clamassassin
, appends its headers to the message headers.
X-Virus-Status: No
X-Virus-Checker-Version: clamassassin 1.2.4 with clamscan / ClamAV 1.0.3/27134/Mon Dec 25 11:40:06 2023
It would be better that any MTA delivering the message only prepends to the headers, as RFC 5322, 3.6 suggests:
However, for the purposes of this specification, header fields SHOULD NOT be reordered when a message is transported or transformed. More importantly, the trace header fields and resent header fields MUST NOT be reordered, and SHOULD be kept in blocks prepended to the message. See sections 3.6.6 and 3.6.7 for more information.
For instance, spamassassin
prepends its X-Spam-*
headers above the existing headers. Why clamassassin
does not do the same, and how to alter this behaviour? If, e.g., the .procmailrc
had the following I would expect these headers to appear in the same place.
:0 fw
| clamassassin
:0 fw
| spamassassin
Reasons
The
clamassassin
is an old shell script that was developed between 2003 and 2007 whereas RFC 5322 is more recent, dating back to 2008. Therefore, the author ofclamassassin
, James Lick, might not have been aware of such demands.Furthermore,
clamassassin
utilizes Procmail'sformail(1)
mail (re)formatter for adding the headers. Asformail
only has-a
,-A
,-i
&-I
that all appends to the headers it is impossible to alter this behaviour without a major rewrite of the script.Workaround
As a workaround, I wrote a small script,
mail-prepender.sh
, that can be used to replaceformail
for the use case ofclamassassin
. It simply prepends all the headers given as any of those flags and keeps everything else intact. The flags-x
&-X
are also implemented asclamassassin
uses-c -x
for extracting theSubject
header from the original headers.On Debian based systems, the script is configurable through
/etc/default/clamassassin
where you can add the path to this script as the path toformail
by adding, e.g.,Results
Tested on Debian 12, where the beginning of the headers now look like this on clean results:
When ClamAV detects something the headers look like this: