Re: [dmarc-ietf] Why does DKIM fail when SPF succeeds (was: DMARC2 & SPF Dependency Removal)

OLIVIER HUREAU <olivier.hureau@univ-grenoble-alpes.fr> Mon, 24 July 2023 09:20 UTC

Return-Path: <olivier.hureau@univ-grenoble-alpes.fr>
X-Original-To: dmarc@ietfa.amsl.com
Delivered-To: dmarc@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DDC89C151999 for <dmarc@ietfa.amsl.com>; Mon, 24 Jul 2023 02:20:57 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.094
X-Spam-Level:
X-Spam-Status: No, score=-7.094 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=unavailable autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=univ-grenoble-alpes.fr
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id saXqZeTVXbrR for <dmarc@ietfa.amsl.com>; Mon, 24 Jul 2023 02:20:52 -0700 (PDT)
Received: from zm-mta-out-3.u-ga.fr (zm-mta-out-3.u-ga.fr [152.77.200.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 7B0C9C15199A for <dmarc@ietf.org>; Mon, 24 Jul 2023 02:20:51 -0700 (PDT)
Received: from mailhub.u-ga.fr (mailhub-1.u-ga.fr [129.88.178.98]) by zm-mta-out-3.u-ga.fr (Postfix) with ESMTP id C019A40215; Mon, 24 Jul 2023 11:20:49 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=univ-grenoble-alpes.fr; s=2020; t=1690190449; bh=o/URqlI0pM0G98Q9p/up5CZQyqE6GiZ4Z2OSbD0feI0=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=a2pknKuHHDHKWg/9AmWj2K30mwYiPxsk/RFXTcSOEOZl7mgTAVAgBwVUtdTdrIHkN Tq1HAF4Hsnk8Cjd07bQ5CsTtJOeAGhdQfLBCva/rQTCnMUwnCKY7MB7IG025xcDy7V 7UEuMc9FarV1p8aW+6dU0nyt4za8pdu9Hs8iRixxp5nB0EhYG3ShHDhdyI3BUxhYSA p7MP/8loGms1Yb2J6nEhMzOy8W8dArN1hYgmqVhqzjQooWSZglYtuNeFac24AsFV1c 7k53vf7IjoTpoeburTamhsASWN3jlWroUTdrOU6z8NMKxT/5he/KDr5DlAOxbZFbaN t2r+EXBFU0nkQ==
Received: from mailhost.u-ga.fr (mailhost2.u-ga.fr [129.88.177.242]) by mailhub.u-ga.fr (Postfix) with ESMTP id BD8BB10005A; Mon, 24 Jul 2023 11:20:49 +0200 (CEST)
Received: from zm-mbx02.u-ga.fr (zm-mbx02.u-ga.fr [152.77.200.16]) by mailhost.u-ga.fr (Postfix) with ESMTP id B841760066; Mon, 24 Jul 2023 11:20:49 +0200 (CEST)
Date: Mon, 24 Jul 2023 11:20:49 +0200
From: OLIVIER HUREAU <olivier.hureau@univ-grenoble-alpes.fr>
To: Matthäus Wander <mail=40wander.science@dmarc.ietf.org>
Cc: dmarc <dmarc@ietf.org>
Message-ID: <1464307464.1412046.1690190449708.JavaMail.zimbra@univ-grenoble-alpes.fr>
In-Reply-To: <dd0661c0-e476-62b4-fe7a-8ec4d1a62818@wander.science>
References: <30BB83B2-B454-41B8-992B-8E2569802D9C@1und1.de> <D225D7FC-C570-4B63-A694-9F16DB1F33E1@kitterman.com> <CALaySJKwuOK-81dW2H9dtURxa5mLQDUNo+MWcs+Hho8N+yP9qg@mail.gmail.com> <2817813.dRqVH37e0G@localhost> <CALaySJJbPFBAV_7mZaARYWuMzuX+74r2Cm0jD+z92_iuFRn_MQ@mail.gmail.com> <dd0661c0-e476-62b4-fe7a-8ec4d1a62818@wander.science>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=_e03a6ed2-be9b-41bb-9457-f0ec57bd8045"
X-Originating-IP: [129.88.52.186]
X-Mailer: Zimbra 8.8.15_GA_4545 (ZimbraWebClient - GC112 (Linux)/8.8.15_GA_4545)
Thread-Topic: Why does DKIM fail when SPF succeeds (was: DMARC2 & SPF Dependency Removal)
Thread-Index: WoFGO8q5YOJTdYF4Leqp04sZF8TTPw==
X-Greylist: Whitelist-UGA MAILHOST (SMTP non authentifie) depuis 152.77.200.16
Archived-At: <https://mailarchive.ietf.org/arch/msg/dmarc/ouSBtpMhD5KJp2osPfUXJktuoMQ>
Subject: Re: [dmarc-ietf] Why does DKIM fail when SPF succeeds (was: DMARC2 & SPF Dependency Removal)
X-BeenThere: dmarc@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: "Domain-based Message Authentication, Reporting, and Compliance \(DMARC\)" <dmarc.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dmarc>, <mailto:dmarc-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dmarc/>
List-Post: <mailto:dmarc@ietf.org>
List-Help: <mailto:dmarc-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dmarc>, <mailto:dmarc-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 24 Jul 2023 09:20:58 -0000

Hi, 

> c) There is a pattern of similar looking reports, which omit the <dkim> 
> element in the <auth_results> altogether and always report 
> <dkim>fail</dkim> in the policy result. I suspect a product, which makes 
> it a bit too easy to enable DMARC validation without also enabling DKIM 
> verification, but I wasn't able to identify the product yet. 

I have also discovered that some report sender does not send valid aggregate reports because the DKIM and SPF auth Result type are not in the right position. 

According to the RFC 7489 XSD, Auth Result type is as follows: 

<xs:complexType name="AuthResultType"> 
<xs:sequence> 
<!-- There may be no DKIM signatures, or multiple DKIM 
signatures. --> 
<xs:element name="dkim" type="DKIMAuthResultType" minOccurs="0" maxOccurs="unbounded"/> 
<!-- There will always be at least one SPF result. --> 
<xs:element name="spf" type="SPFAuthResultType" minOccurs="1" maxOccurs="unbounded"/> 
</xs:sequence> 
</xs:complexType> 

According to XML definitions, the position cannot be swapped and the DKIMAuthResultType (if there is one) must appear before the SPFAuthResultType. 
However, some reporter does not follow this implementation. 

E.g: the no longer maintained Linkedin dmarc-sys : 
[ https://github.com/LinkedInAttic/dmarc-msys/blob/master/dmarc_report.py#L240 | https://github.com/LinkedInAttic/dmarc-msys/blob/master/dmarc_report.py#L240 ] where SPFAuthResultType appears before DKIMAuthResultType . 

Are you talking about the same error? 

Best, 
Olivier 



De: "Matthäus Wander" <mail=40wander.science@dmarc.ietf.org> 
À: "dmarc" <dmarc@ietf.org> 
Envoyé: Dimanche 23 Juillet 2023 22:05:44 
Objet: [dmarc-ietf] Why does DKIM fail when SPF succeeds (was: DMARC2 & SPF Dependency Removal) 

Barry Leiba wrote on 2023-06-10 01:50: 
> That's interesting and disturbing if it remains consistent. 
> Theoretically, DKIM should *never* fail when SPF succeeds, so if 
> that's happening it means there is: 
> 1. bad signing software, 
> 2. bad verifying software, 
> 3. misconfiguration somewhere, 
> ...or a combination of those three. 
> 
> I would *really* like to see a current study of this, because I think 
> it's critical for the future viability of DMARC, whether or not we 
> accept the proposal to remove SPF. 
Not a study, but some data points I've observed: 

a) Signing with 3072-bit RSA leads to DKIM verification failures, 
because a popular mail gateway product (Cisco ESA) does not support RSA 
key lengths larger than 2048 bit. 

b) Messages are generated by an automated system without a Date header 
and signed by a central MTA. An outgoing mail gateway then adds the 
missing Date header (Postfix option 'always_add_missing_headers'), thus 
invalidating the DKIM signature. 

Such misconfigurations go unnoticed for years until someone checks the 
DMARC reports. While aggregate reports are incredibly helpful, it is 
still difficult to identify the cause of subtle DKIM failures. I'd wish 
that the <human_result> field would be filled by reporting software with 
the DKIM verification error message ('body hash did not verify', etc.) 
to aid with troubleshooting. 

Contacting the report <email> or postmaster address has never worked for 
me: if they don't bounce, nobody replies. 

c) There is a pattern of similar looking reports, which omit the <dkim> 
element in the <auth_results> altogether and always report 
<dkim>fail</dkim> in the policy result. I suspect a product, which makes 
it a bit too easy to enable DMARC validation without also enabling DKIM 
verification, but I wasn't able to identify the product yet. 

Regards, 
Matt 

_______________________________________________ 
dmarc mailing list 
dmarc@ietf.org 
https://www.ietf.org/mailman/listinfo/dmarc