Re: [spfbis] RFC7208 4.6.4 Interpretation - MX Lookup Count Inconsistencies

Scott Kitterman <spf2@kitterman.com> Sun, 15 January 2023 21:25 UTC

Return-Path: <spf2@kitterman.com>
X-Original-To: spfbis@ietfa.amsl.com
Delivered-To: spfbis@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 1314CC14F747 for <spfbis@ietfa.amsl.com>; Sun, 15 Jan 2023 13:25:58 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.098 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=kitterman.com header.b="W23ocDyN"; dkim=pass (2048-bit key) header.d=kitterman.com header.b="TAipRMDe"
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 FJ4yywlY397v for <spfbis@ietfa.amsl.com>; Sun, 15 Jan 2023 13:25:53 -0800 (PST)
Received: from interserver.kitterman.com (interserver.kitterman.com [IPv6:2604:a00:6:1039:225:90ff:feaa:b169]) (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 657ECC14F744 for <spfbis@ietf.org>; Sun, 15 Jan 2023 13:25:53 -0800 (PST)
Received: from interserver.kitterman.com (unknown [IPv6:2604:a00:6:1039:225:90ff:feaa:b169]) by interserver.kitterman.com (Postfix) with ESMTPS id 59E23F801E0 for <spfbis@ietf.org>; Sun, 15 Jan 2023 16:19:16 -0500 (EST)
DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/simple; d=kitterman.com; i=@kitterman.com; q=dns/txt; s=201903e; t=1673817541; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type : from; bh=ZgSqDRT8iQB/2YDTQi7FVgPV4kFddnsuv9MuAYcq5UU=; b=W23ocDyNRHzyY6psVTvlBTYabS5QRqBYD2Oh6AbKTj6XItaBXRmmW8T4Pqai6/qHUaoNM LxIVhTxyCt7vpXEDw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kitterman.com; i=@kitterman.com; q=dns/txt; s=201903r; t=1673817541; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type : from; bh=ZgSqDRT8iQB/2YDTQi7FVgPV4kFddnsuv9MuAYcq5UU=; b=TAipRMDeKZaIUnPiiLSIf7x1ceC1nOfFnGgv3TgKofZ/DWX08b24ZHbvh6Up88jYWDcNW loWzuX3LvEJDiI6NTvtw2IR/lwAhcpJjDDg8KmlBencNz0XznujGKPVaiGnOMdqJagz87uK tOg1mbMrTYX7oHP89sHNWk5yX3g7HJ5p/eTza4rCBKHBwPyV+YHdWfCtzg7CPVEeomi8orZ KBbAQdMCi0qHtVa8H1R1keHBZhJ9MweSbSVPRirCowckDwcsuFWpemRP9OK5Nppy+GFlfLb O+aSPgotsMZSNbs+dRBWtfpWGwyyGCt7oQQ3AFfZvz4lCmSNduxARf7Jlsvw==
Received: from localhost.localnet (static-72-81-252-22.bltmmd.fios.verizon.net [72.81.252.22]) by interserver.kitterman.com (Postfix) with ESMTP id 32AB2F8016D for <spfbis@ietf.org>; Sun, 15 Jan 2023 16:19:01 -0500 (EST)
From: Scott Kitterman <spf2@kitterman.com>
To: spfbis@ietf.org
Date: Sun, 15 Jan 2023 16:18:57 -0500
Message-ID: <2052933.pCZHq2v93S@localhost>
In-Reply-To: <79ac443e-b0ee-6598-cec0-9cf32c3dc1d1@tekmarc.com>
References: <79ac443e-b0ee-6598-cec0-9cf32c3dc1d1@tekmarc.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"
Archived-At: <https://mailarchive.ietf.org/arch/msg/spfbis/rX-C_yJd7oNQKjRiJslYcHgl6Sw>
Subject: Re: [spfbis] RFC7208 4.6.4 Interpretation - MX Lookup Count Inconsistencies
X-BeenThere: spfbis@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: SPFbis discussion list <spfbis.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/spfbis>, <mailto:spfbis-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/spfbis/>
List-Post: <mailto:spfbis@ietf.org>
List-Help: <mailto:spfbis-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/spfbis>, <mailto:spfbis-request@ietf.org?subject=subscribe>
X-List-Received-Date: Sun, 15 Jan 2023 21:25:58 -0000

Comments inline.

On Friday, January 13, 2023 3:09:03 PM EST Mark Alley wrote:
> Hi all, I have two questions about section 4.6.4 regarding "mx" 
> mechanism DNS lookup counts during SPF evaluation that I would like some 
> guidance on. I haven't been able to find anything regarding this topic 
> specifically in the ML archive aside from one niche topic relating to 
> the MX AAAA ipv6 queries counting as void lookups.
> 
> ------------------------------------
> 
> First, checking logic implementations of the "mx" mechanism DNS lookup 
> count of various SPF validator tools compared to the logic described in 
> section 4.6.4, I discovered implementation inconsistencies that have led 
> me to question what the "correct" logic is for counting MX lookups in an 
> SPF record. There are 12 SPF validators on the internet that seem to 
> skip over this during lookup counting (many from well-established 
> vendors), and only 3 that do not.
> 
> So, given this, based on the below information, which is the correct 
> counting interpretation?
> 
> There is a domain - katrinafox.com - which has an SPF record that looks 
> like this:
> 
> /v=spf1 +a +mx +ip4:35.213.205.66 include:_spf.mailspamprotection.com ~all/
> 
> Breaking down DNS lookups manually, we get this:
> 
> 1 - "a" mechanism
> 
> 4 - "mx" mechanism (1 initial MX record lookup, +3 A/AAAA MX names
> returned)
 
> 4 - "include" mechanism (1 initial include lookup, +3 recursive includes)
> 
> Per the first paragraph of section 4.6.4, it reads as such: "/When 
> evaluating the "mx" mechanism, the number of "MX" resource//records 
> queried is included in the overall limit of 10 mechanisms///modifiers 
> that cause DNS lookups as described above."/
> 
> My interpretation is that the language is clear; the MX names (A/AAAA 
> RRs) returned by the MX query are counted against the overall 10 lookup 
> count of the evaluated SPF record. Leaving this domain's SPF record with 
> a total of 9 lookups. However, the overwhelming majority of SPF 
> validator tools (and I haven't even started researching receiver-side 
> logic implementations of this yet) seem to implement this /skipping/ the 
> MX query returned names as part of the lookup count, which leaves the 
> lookup count for this domain at 6.

First, some history.  In the predecessor document, RFC 4408, the processing 
limits were in security considerations, not in the main specification (Section 
10.1).  There are some changes between RC 4408 and RFC 7208 in this area that 
may account for some differences, but I don't think this is correct for either 
version of the limits.

Moving forward, here's the full text specific to MX from RFC 7208, Section 
4.6.4:

>    When evaluating the "mx" mechanism, the number of "MX" resource
>    records queried is included in the overall limit of 10 mechanisms/
>    modifiers that cause DNS lookups as described above.  In addition to
>    that limit, the evaluation of each "MX" record MUST NOT result in
>    querying more than 10 address records -- either "A" or "AAAA"
>    resource records.  If this limit is exceeded, the "mx" mechanism MUST
>    produce a "permerror" result.

In the example you gave, only the +mx lookup counts against the overall limit.  
"MX" resource records are exactly that.  The address records (A/AAAA) are 
counted separately as clearly indicated in the sentence after the one you 
quoted.  

The change from RFC 4408 to RFC 7208 is in how the second limit (no more than 
10 address records) is addressed.  As you can see, RFC 7208 specifies an error 
if that number is exceeded.  RFC 4408 specified to truncate lookups at 10 
without error.  We changed this for RFC 7208 because the silent truncation 
specified by RFC 4408 left a risk of inconsistent results (if there are more 
than 10, there's no guarantee of the order they are returned in, so an 
identical message might pass one time and not another).

MX records with more than 10 address records are relatively rare, so it would 
not surprise me if some implementers did not consider this a change worth 
spending the money to make.


> ------------------------------------
> 
> Second, addressing the second sentence of the second paragraph in 4.6.4 
> (which continues the context of the last above question): "/In addition 
> to that limit, the evaluation of each "MX" record MUST NOT result in 
> querying more than 10 address records -- either "A" or "AAAA" resource 
> records./"
> 
> There seems to be the same inconsistencies among SPF validator tools for 
> this logic as well. Three tools, one being MXtoolbox, say this domain 
> has "too many IP addresses returned from the MX query" (of which there 
> are well over 10 total), which results in their evaluation returning 
> "permerror".
> 
> It seems some implementors have interpreted the "10 address records" 
> phrase to mean "/the number of IP address records //resulting //from an 
> MX name A/AAAA RR query/", rather than "/the total sum of the MX names 
> themselves/", as would seem described by the section's language. Of my 
> interpretation from this section's language, it would seem this domain 
> should exceed neither the SPF lookup count, nor the MX A/AAAA query count.
> 
> Which is the most accurate interpretation of this section?

See above.  Yes.  "address records" and "IP address records" are synonymous.  
If a record has multiple "MX" mechanisms, each one can have up to 10 address 
records (A/AAAA).  The assigned names fo A/AAAA are "a host address"/"IP6 
Address" [1], so I don't see how it could be anything else.

Also, as mentioned above, if some validators raise an error and some don't, 
that's a result of the change going to RFC 7208 from RFC 4408 that I mentioned 
above.

I think you need to go back and revisit you assessment of how these work as I 
don't think it's correct.  We struggled with this in the SPFbis working group 
as it was very difficult to come up with clear and accurate language, so I'm not 
surprised to see it's not immediately obvious what we meant.

Scott K

[1] https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4