Mail::SpamAssassin::PlUser:Contributed PerlMail::SpamAssassin::Plugin::DKIM(3)
NAME
Mail::SpamAssassin::Plugin::DKIM - perform DKIM verification tests
SYNOPSIS
loadplugin Mail::SpamAssassin::Plugin::DKIM [/path/to/DKIM.pm]
Taking into account signatures from any signing domains:
full DKIM_SIGNED eval:check_dkim_signed()
full DKIM_VALID eval:check_dkim_valid()
full DKIM_VALID_AU eval:check_dkim_valid_author_sig()
full DKIM_VALID_EF eval:check_dkim_valid_envelopefrom()
Taking into account signatures from specified signing domains only:
(quotes may be omitted on domain names consisting only of letters,
digits, dots, and minus characters)
full DKIM_SIGNED_MY1 eval:check_dkim_signed('dom1','dom2',...)
full DKIM_VALID_MY1 eval:check_dkim_valid('dom1','dom2',...)
full DKIM_VALID_AU_MY1 eval:check_dkim_valid_author_sig('d1','d2',...)
full __DKIM_DEPENDABLE eval:check_dkim_dependable()
Author Domain Signing Practices (ADSP) from any author domains:
header DKIM_ADSP_NXDOMAIN eval:check_dkim_adsp('N')
header DKIM_ADSP_ALL eval:check_dkim_adsp('A')
header DKIM_ADSP_DISCARD eval:check_dkim_adsp('D')
header DKIM_ADSP_CUSTOM_LOW eval:check_dkim_adsp('1')
header DKIM_ADSP_CUSTOM_MED eval:check_dkim_adsp('2')
header DKIM_ADSP_CUSTOM_HIGH eval:check_dkim_adsp('3')
Author Domain Signing Practices (ADSP) from specified author domains
only:
header DKIM_ADSP_MY1 eval:check_dkim_adsp('*','dom1','dom2',...)
describe DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid
describe DKIM_VALID Message has at least one valid DKIM or DK signature
describe DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain
describe DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain
describe __DKIM_DEPENDABLE A validation failure not attributable to truncation
describe DKIM_ADSP_NXDOMAIN Domain not in DNS and no valid author domain signature
describe DKIM_ADSP_ALL Domain signs all mail, no valid author domain signature
describe DKIM_ADSP_DISCARD Domain signs all mail and suggests discarding mail with no valid author domain signature, no valid author domain signature
describe DKIM_ADSP_CUSTOM_LOW adsp_override is CUSTOM_LOW, no valid author domain signature
describe DKIM_ADSP_CUSTOM_MED adsp_override is CUSTOM_MED, no valid author domain signature
describe DKIM_ADSP_CUSTOM_HIGH adsp_override is CUSTOM_HIGH, no valid author domain signature
For compatibility with pre-3.3.0 versions, the following are synonyms:
OLD: eval:check_dkim_verified = NEW: eval:check_dkim_valid
OLD: eval:check_dkim_signall = NEW: eval:check_dkim_adsp('A')
OLD: eval:check_dkim_signsome = NEW: redundant, semantically always true
The __DKIM_DEPENDABLE eval rule deserves an explanation. The rule
yields true when signatures are supplied by a caller, OR ELSE when
signatures are obtained by this plugin AND either there are no
signatures OR a rule __TRUNCATED was false. In other words:
__DKIM_DEPENDABLE is true when failed signatures can not be attributed
to message truncation when feeding a message to SpamAssassin. It can
be consulted to prevent false positives on large but truncated messages
with poor man's implementation of ADSP by hand-crafted rules.
DESCRIPTION
This SpamAssassin plugin implements DKIM lookups as described by the
RFC 4871, as well as historical DomainKeys lookups, as described by RFC
4870, thanks to the support for both types of signatures by newer
versions of module Mail::DKIM.
It requires the "Mail::DKIM" CPAN module to operate. Many thanks to
Jason Long for that module.
TAGS
The following tags are added to the set, available for use in reports,
header fields, other plugins, etc.:
_DKIMIDENTITY_
Agent or User Identifier (AUID) (the 'i' tag) from valid signatures;
_DKIMDOMAIN_
Signing Domain Identifier (SDID) (the 'd' tag) from valid signatures;
_DKIMSELECTOR_
DKIM selector (the 's' tag) from valid signatures;
Identities and domains from signatures which failed verification are
not included in these tags. Duplicates are eliminated (e.g. when there
are two or more valid signatures from the same signer, only one copy
makes it into a tag). Note that there may be more than one signature
in a message - currently they are provided as a space-separated list,
although this behaviour may change.
SEE ALSO
"Mail::DKIM" Mail::SpamAssassin::Plugin(3)
http://dkimproxy.sourceforge.net/
https://tools.ietf.org/rfc/rfc4871.txt
https://tools.ietf.org/rfc/rfc4870.txt
https://tools.ietf.org/rfc/rfc5617.txt
https://datatracker.ietf.org/group/dkim/about/
USER SETTINGS
whitelist_from_dkim author AT example.com [signing-domain]
Works similarly to whitelist_from, except that in addition to
matching an author address (From) to the pattern in the first
parameter, the message must also carry a valid Domain Keys
Identified Mail (DKIM) signature made by a signing domain (SDID,
i.e. the d= tag) that is acceptable to us.
Only one whitelist entry is allowed per line, as in
"whitelist_from_rcvd". Multiple "whitelist_from_dkim" lines are
allowed. File-glob style characters are allowed for the From
address (the first parameter), just like with
"whitelist_from_rcvd".
The second parameter (the signing-domain) does not accept full
file-glob style wildcards, although a simple '*.' (or just a '.')
prefix to a domain name is recognized and implies any subdomain of
the specified domain (but not the domain itself).
If no signing-domain parameter is specified, the only acceptable
signature will be an Author Domain Signature (sometimes called
first-party signature) which is a signature where the signing
domain (SDID) of a signature matches the domain of the author's
address (i.e. the address in a From header field).
Since this whitelist requires a DKIM check to be made, network
tests must be enabled.
Examples of whitelisting based on an author domain signature
(first-party):
whitelist_from_dkim joe AT example.com
whitelist_from_dkim *@corp.example.com
whitelist_from_dkim *@*.example.com
Examples of whitelisting based on third-party signatures:
whitelist_from_dkim jane AT example.net example.org
whitelist_from_dkim rick AT info.net example.net
whitelist_from_dkim *@info.example.net example.net
whitelist_from_dkim *@* mail7.remailer.example.com
whitelist_from_dkim *@* *.remailer.example.com
def_whitelist_from_dkim author AT example.com [signing-domain]
Same as "whitelist_from_dkim", but used for the default whitelist
entries in the SpamAssassin distribution. The whitelist score is
lower, because these are often targets for abuse of public mailers
which sign their mail.
unwhitelist_from_dkim author AT example.com [signing-domain]
Removes an email address with its corresponding signing-domain
field from def_whitelist_from_dkim and whitelist_from_dkim tables,
if it exists. Parameters to unwhitelist_from_dkim must exactly
match the parameters of a corresponding whitelist_from_dkim or
def_whitelist_from_dkim config option which created the entry, for
it to be removed (a domain name is matched case-insensitively);
i.e. if a signing-domain parameter was specified in a whitelisting
command, it must also be specified in the unwhitelisting command.
Useful for removing undesired default entries from a distributed
configuration by a local or site-specific configuration or by
"user_prefs".
adsp_override domain [signing-practices]
Currently few domains publish their signing practices (RFC 5617 -
ADSP), partly because the ADSP rfc is rather new, partly because
they think hardly any recipient bothers to check it, and partly for
fear that some recipients might lose mail due to problems in their
signature validation procedures or mail mangling by mailers beyond
their control.
Nevertheless, recipients could benefit by knowing signing practices
of a sending (author's) domain, for example to recognize forged
mail claiming to be from certain domains which are popular targets
for phishing, like financial institutions. Unfortunately, as
signing practices are seldom published or are weak, it is hardly
justifiable to look them up in DNS.
To overcome this chicken-or-the-egg problem, the "adsp_override"
mechanism allows recipients using SpamAssassin to override
published or defaulted ADSP for certain domains. This makes it
possible to manually specify a stronger (or weaker) signing
practices than a signing domain is willing to publish (explicitly
or by default), and also save on a DNS lookup.
Note that ADSP (published or overridden) is only consulted for
messages which do not contain a valid DKIM signature from the
author's domain.
According to RFC 5617, signing practices can be one of the
following: "unknown", "all" and "discardable".
"unknown": The domain might sign some or all email - messages from
the domain may or may not have an Author Domain Signature. This is
a default if a domain exists in DNS but no ADSP record is found.
"all": All mail from the domain is signed with an Author Domain
Signature.
"discardable": All mail from the domain is signed with an Author
Domain Signature. Furthermore, if a message arrives without a
valid Author Domain Signature, the domain encourages the
recipient(s) to discard it.
ADSP lookup can also determine that a domain is "out of scope",
i.e., the domain does not exist (NXDOMAIN) in the DNS.
To override domain's signing practices in a SpamAssassin
configuration file, specify an "adsp_override" directive for each
sending domain to be overridden.
Its first argument is a domain name. Author's domain is matched
against it, matching is case insensitive. This is not a regular
expression or a file-glob style wildcard, but limited wildcarding
is still available: if this argument starts by a "*." (or is a sole
"*"), author's domain matches if it is a subdomain (to one or more
levels) of the argument. Otherwise (with no leading asterisk) the
match must be exact (not a subdomain).
An optional second parameter is one of the following keywords
(case-insensitive): "nxdomain", "unknown", "all", "discardable",
"custom_low", "custom_med", "custom_high".
Absence of this second parameter implies "discardable". If a domain
is not listed by a "adsp_override" directive nor does it explicitly
publish any ADSP record, then "unknown" is implied for valid
domains, and "nxdomain" for domains not existing in DNS. (Note:
domain validity is only checked with versions of Mail::DKIM 0.37 or
later (actually since 0.36_5), the "nxdomain" would never turn up
with older versions).
The strong setting "discardable" is useful for domains which are
known to always sign their mail and to always send it directly to
recipients (not to mailing lists), and are frequent targets of
fishing attempts, such as financial institutions. The "discardable"
is also appropriate for domains which are known never to send any
mail.
When a message does not contain a valid signature by the author's
domain (the domain in a From header field), the signing practices
pertaining to author's domain determine which of the following
rules fire and contributes its score: DKIM_ADSP_NXDOMAIN,
DKIM_ADSP_ALL, DKIM_ADSP_DISCARD, DKIM_ADSP_CUSTOM_LOW,
DKIM_ADSP_CUSTOM_MED, DKIM_ADSP_CUSTOM_HIGH. Not more than one of
these rules can fire for messages that have one author (but see
below). The last three can only result from a 'signing-practices'
as given in a "adsp_override" directive (not from a DNS lookup),
and can serve as a convenient means of providing a different score
if scores assigned to DKIM_ADSP_ALL or DKIM_ADSP_DISCARD are not
considered suitable for some domains.
RFC 5322 permits a message to have more than one author - multiple
addresses may be listed in a single From header field. RFC 5617
defines that a message with multiple authors has multiple signing
domain signing practices, but does not prescribe how these should
be combined. In presence of multiple signing practices, more than
one of the DKIM_ADSP_* rules may fire.
As a precaution against firing DKIM_ADSP_* rules when there is a
known local reason for a signature verification failure, the
domain's ADSP is considered 'unknown' when DNS lookups are disabled
or a DNS lookup encountered a temporary problem on fetching a
public key from the author's domain. Similarly, ADSP is considered
'unknown' when this plugin did its own signature verification
(signatures were not passed to SA by a caller) and a metarule
__TRUNCATED was triggered, indicating the caller intentionally
passed a truncated message to SpamAssassin, which was a likely
reason for a signature verification failure.
Example:
adsp_override *.mydomain.example.com discardable
adsp_override *.neversends.example.com discardable
adsp_override ebay.com
adsp_override *.ebay.com
adsp_override ebay.co.uk
adsp_override *.ebay.co.uk
adsp_override paypal.com
adsp_override *.paypal.com
adsp_override amazon.com
adsp_override ealerts.bankofamerica.com
adsp_override americangreetings.com
adsp_override egreetings.com
adsp_override bluemountain.com
adsp_override hallmark.com all
adsp_override *.hallmark.com all
adsp_override youtube.com custom_high
adsp_override google.com custom_low
adsp_override gmail.com custom_low
adsp_override googlemail.com custom_low
adsp_override yahoo.com custom_low
adsp_override yahoo.com.au custom_low
adsp_override yahoo.se custom_low
adsp_override junkmailerkbw0rr.com nxdomain
adsp_override junkmailerd2hlsg.com nxdomain
# effectively disables ADSP network DNS lookups for all other domains:
adsp_override * unknown
score DKIM_ADSP_ALL 2.5
score DKIM_ADSP_DISCARD 25
score DKIM_ADSP_NXDOMAIN 3
score DKIM_ADSP_CUSTOM_LOW 1
score DKIM_ADSP_CUSTOM_MED 3.5
score DKIM_ADSP_CUSTOM_HIGH 8
dkim_minimum_key_bits n (default: 1024)
The smallest size of a signing key (in bits) for a valid signature
to be considered for whitelisting. Additionally, the eval function
check_dkim_valid() will return false on short keys when called with
explicitly listed domains, and the eval function
check_dkim_valid_author_sig() will return false on short keys
(regardless of its arguments). Setting the option to 0 disables a
key size check.
Note that the option has no effect when the eval function
check_dkim_valid() is called with no arguments (like in a rule
DKIM_VALID). A mere presence of some valid signature on a message
has no reputational value (without being associated with a
particular domain), regardless of its key size - anyone can prepend
its own signature on a copy of some third party mail and re-send
it, which makes it no more trustworthy than without such signature.
This is also a reason for a rule DKIM_VALID to have a near-zero
score, i.e. a rule hit is only informational.
ADMINISTRATOR SETTINGS
dkim_timeout n (default: 5)
How many seconds to wait for a DKIM query to complete, before
scanning continues without the DKIM result. A numeric value is
optionally suffixed by a time unit (s, m, h, d, w, indicating
seconds (default), minutes, hours, days, weeks).
perl v5.26.3 2021-04-0Mail::SpamAssassin::Plugin::DKIM(3)