Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

DKIM verification in 4.70 not working

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


tlyons at ivenue

Nov 18, 2009, 3:48 PM

Post #1 of 3 (759 views)
Permalink
DKIM verification in 4.70 not working

I built the new 4.70 and modified the dkim configuration from the 4.69
style to the new and improved 4.70 style. I'm only doing verification
at the moment. It always thinks the email is not dkim signed. It
never makes it past the first dkim check because it always thinks it
has no signature.

I'm looking for two answers during this email:
1. Why does exim always think an email is unsigned?
2. Feedback on my ACL logic and header construction.

I have set in exim.conf:
acl_smtp_dkim = acl_check_dkim
dkim_verify_signers = *

Then I have an acl (beware of line-wrapping) :
acl_check_dkim:
accept hosts = +relay_from_hosts

accept authenticated = *

accept dkim_status = none
condition = ${if eq {$acl_c_dkim_hdr}{1} {no}{yes}}
set acl_c_dkim_hdr = 1
add_header = :at_start:X-DKIM: Exim 4.70 on
$primary_hostname (no dkim signature)

warn condition = ${if eq {$acl_c_dkim_hdr}{1} {no}{yes}}
set acl_c_dkim_hdr = 1
add_header = :at_start:X-DKIM: Exim 4.70 on $primary_hostname

deny dkim_status = fail
message = Rejected: $dkim_verify_reason

accept dkim_status = invalid
add_header = :at_start:Authentication-Results:
$primary_hostname $dkim_cur_signer ($dkim_verify_status);
$dkim_verify_reason

accept dkim_status = pass
add_header = :at_start:Authentication-Results:
$primary_hostanme; dkim=$dkim_domain, header.i=@$dkim_cur_signer
($dkim_verify_status)

accept

Here are some headers from a test email I sent myself, and you can see
that exim did not think it was signed:

Return-path: <todd [at] mrball>
Envelope-to: aaron [at] ivtestdomain
Delivery-date: Wed, 18 Nov 2009 22:57:56 +0000
X-DKIM: Exim 4.70 on m.test.ivenue.com (no dkim signature)
Received: from mail.mrball.net ([208.89.136.119])
by m.test.ivenue.com with esmtp (Exim 4.70)
(envelope-from <todd [at] mrball>)
id 1NAtTC-0001jP-Bf
for aaron [at] ivtestdomain; Wed, 18 Nov 2009 22:57:55 +0000
Received: from trip.mrball.net (mail.mrball.net [208.89.136.119])
by mail.mrball.net (8.14.2/8.14.2) with ESMTP id nAIMvZA0010306
for <aaron [at] ivtestdomain>; Wed, 18 Nov 2009 14:57:36 -0800
X-DKIM: Sendmail DKIM Filter v2.4.3.dev mail.mrball.net nAIMvZA0010306
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mrball.net; s=test;
t=1258585063; bh=WkNI55heP6q4XyliaoDIH0NyKwrTyZ2dEAWsX5yGMzY=;
h=X-DomainKeys:DomainKey-Signature:Received:Received:Date:From:To:
Message-ID:MIME-Version:Content-Type:Content-Disposition:
Organization:X-message-flag:User-Agent; b=BOkZaaggfIsA861A0P+uTIO8
yPO6jacZaygbBFO/C2nygRMOe9wInD6mCvCsHkmZwfvcL3blK3kG14t6VkgfBQRHDQ6
B0flhAfUGVrxCdgsKgE5KgeWytWTxLOTrnrVv4x0glxTbMMuHXinF8U+cGWgNSlWOKy
LUXzYgIi7giRY=
<snip>

Any feedback is greatly appreciated!

--
Regards... Todd
The best thing about pair programming is that you have the perfect
audience for your genius. -- Kent Beck

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


tom at duncanthrax

Nov 19, 2009, 12:22 AM

Post #2 of 3 (732 views)
Permalink
Re: DKIM verification in 4.70 not working [In reply to]

Todd Lyons wrote:

> dkim_verify_signers = *

This is not correct - it should be set to a list of domains or
identities that acl_smtp_dkim is called for. When unset, this setting
defaults to

dkim_verify_signers = $dkim_signers

which causes acl_smtp_dkim to be called for all domains and identities
that have signed the message.

dkim_verify_signers is expanded each time before it is used, at a point
where header information is available. So you can do several tricks to
dynamically call the DKIM ACL based on envelope or header addresses.

At the moment, it can be useful to statically call acl_smtp_dkim for
"known" all-signers additionally, like:

dkim_verify_signers = $dkim_signers:paypal.com:gmail.com

And then in the ACL:

warn log_message = DKIM: Unsigned message from $sender_address_domain
sender_domains = gmail.com:paypal.com
dkim_signers = gmail.com:paypal.com
dkim_status = none

This would catch (or in this case, only warn about) crap like:

Nov 19 01:36:04 [exim] 2009-11-19 01:36:04 1NAv0G-0005v1-Fl
H=mail.kelantan.gov.my [210.187.31.8] Warning: DKIM: Unsigned message
from gmail.com

Such a check will also be mailing-list safe, because they would not have
gmail.com as the envelope sender.

> acl_check_dkim:
> accept hosts = +relay_from_hosts
> accept authenticated = *

You can also set "control = dkim_disable_verify" somewhere in an earlier
ACL to turn off verification processing entirely. Doing it here won't
save the overhead of doing all the calculations.

Concerning the rest of the ACL code: Each message can have several
signatures. Some can be valid, some broken, some expired ... if you want
to flag message that have no valid signature whatsoever, you would need
to set a flag in acl_smtp_dkim when you find a valid signature, then
check for that flag in acl_smtp_data. If it isn't set, you know there
was no valid sig. Of course, that means that $dkim_signers must be in
the dkim_verify_signers list.

I have tried to create an API that allows for a broad range of policies.
Unfortunately that can make things quite complicated :)

/tom



--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


tlyons at ivenue

Nov 19, 2009, 10:00 AM

Post #3 of 3 (739 views)
Permalink
Re: DKIM verification in 4.70 not working [In reply to]

On Thu, Nov 19, 2009 at 12:22 AM, Tom Kistner <tom [at] duncanthrax> wrote:
>
> dkim_verify_signers is expanded each time before it is used, at a point
> where header information is available. So you can do several tricks to
> dynamically call the DKIM ACL based on envelope or header addresses.
>
> At the moment, it can be useful to statically call acl_smtp_dkim for "known"
> all-signers additionally, like:
>
> dkim_verify_signers = $dkim_signers:paypal.com:gmail.com

I changed it to more closely match your suggestion:

# Could do a mysql lookup, memcache lookup via perl, etc
KNOWN_DKIM_SIGNERS = paypal.com : gmail.com
dkim_verify_signers = $dkim_signers : KNOWN_DKIM_SIGNERS

I used a MACRO since it turns out that domainlist expansion is not
performed in dkim_verify_signers. At first I tried setting a
domainlist known_dkim_signers. In my ACL, when I did some debugging,
the first time it checked signer "gmail.com" (correct) and then it
checked signer "+known_dkim_signers" (literal, not expanded). So I
switched it to the MACRO and everything works as expected.

> And then in the ACL:
> warn log_message = DKIM: Unsigned message from $sender_address_domain
>     sender_domains = gmail.com:paypal.com
>     dkim_signers = gmail.com:paypal.com
>     dkim_status = none

I changed it to be more like your example, with one logic addition.
However, I'm a bit confused as to the intention of the dkim_signers
line. What is the difference in the operation of the ACL above with
the dkim_signers line commented out? Looking at the spec.txt, it
seems to require that basically the dkim_signers check should be the
same as sender_domains. But logically it seems like the dkim_signers
line should not be used because you're trying to catch an unsigned
message from that known signing domain. Since the email isn't signed,
at least not by that domain, the dkim_signers check _seems_like_ it
should always fail for every pass through that ACL. What logical
mistake am I making here? (Maybe if I think in my head
"dkim_currently_verifying", it would make more sense? Because the
longer I think about it, the more it seems like you're just iterating
through the dkim_verify_signers setting...)

I was suprised to find out that just changing the message From header
doesn't change the $sender_address_domain. $sender_address_domain is
set to mrball.net when the envelope sender is toddatmrball.net and the
From message header is mrballcbatgmail.com (I expected it to
essentially be ${lc:${domain:$h_from:}} aka gmail.com). So the
example above will catch anybody trying to fake the envelope sender
but allow anything in the header From. Thinking about it, that seems
to be one characteristic that makes it mailing list safe if the
mailinglist strips previous signature headers and adds its own. But
that doesn't necessarily seem _good_.

Now my full ACL looks like this. Is there anything obviously wrong
with it? (commented line aside)

acl_check_dkim:
accept dkim_status = none
sender_domains = KNOWN_DKIM_SIGNERS
dkim_signers = KNOWN_DKIM_SIGNERS
condition = ${if
match_domain{$sender_address_domain}{$dkim_cur_signer} {yes}{no}}
log_message = Possible DKIM Forgery: Unsigned message
from $sender_address_domain
add_header = :at_start:X-DKIM: Exim $version_number on
$primary_hostname (no dkim signature for required domain:
$dkim_cur_signer)

accept dkim_status = none
!sender_domains = KNOWN_DKIM_SIGNERS
!dkim_signers = KNOWN_DKIM_SIGNERS
set acl_m_dkim_hdr = 1
add_header = :at_start:X-DKIM: Exim $version_number on
$primary_hostname (no dkim signature for $dkim_cur_signer)

warn condition = ${if eq {$acl_m_dkim_hdr}{1} {no}{yes}}
set acl_m_dkim_hdr = 1
add_header = :at_start:X-DKIM: Exim $version_number on
$primary_hostname

accept dkim_status = pass : invalid
add_header = :at_start:Authentication-Results:
$primary_hostname; dkim=$dkim_verify_status;
signing_identity="$dkim_cur_signer"; reason="$dkim_verify_reason"

deny dkim_status = fail
condition = ${if eq {$dkim_key_testing}{1} {no}{yes}}
message = Rejected: $dkim_verify_reason

accept

> I have tried to create an API that allows for a broad range of policies.
> Unfortunately that can make things quite complicated :)

That level of configurability is very much appreciated! I've been
following DKIM for a while and building/testing/running dkim-milter on
sendmail for a few years now. Murray is very active in the
development and implementation of DKIM. I very much like his milter's
configurability, and I model somewhat my headers after the headers
that the milter generates. Your API gives me even more customizations
than I'm accustomed to. So...Yay!!!

--
Regards... Todd
The best thing about pair programming is that you have the perfect
audience for your genius. -- Kent Beck

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.