Re: [DNSOP] Clarification question: compression pointers always to names earlier in the packet?

Shane Kerr <shane@time-travellers.org> Wed, 24 October 2018 09:22 UTC

Return-Path: <shane@time-travellers.org>
X-Original-To: dnsop@ietfa.amsl.com
Delivered-To: dnsop@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 6D31C130EDB for <dnsop@ietfa.amsl.com>; Wed, 24 Oct 2018 02:22:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5BNegduerOsF for <dnsop@ietfa.amsl.com>; Wed, 24 Oct 2018 02:22:13 -0700 (PDT)
Received: from time-travellers.org (c.time-travellers.nl.eu.org [IPv6:2a02:2770::21a:4aff:fea3:eeaa]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 902B7130F26 for <dnsop@ietf.org>; Wed, 24 Oct 2018 02:22:13 -0700 (PDT)
Received: from [2001:470:78c8:2:15ed:fde8:14a8:fa4] by time-travellers.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <shane@time-travellers.org>) id 1gFFMq-0003lq-Di for dnsop@ietf.org; Wed, 24 Oct 2018 09:22:20 +0000
To: dnsop@ietf.org
References: <BC2CDF40-4FF0-4111-88B7-04969491D2E0@dukhovni.org>
From: Shane Kerr <shane@time-travellers.org>
Message-ID: <7b8761b0-4a77-3abe-870a-8f35e2946931@time-travellers.org>
Date: Wed, 24 Oct 2018 11:22:10 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1
MIME-Version: 1.0
In-Reply-To: <BC2CDF40-4FF0-4111-88B7-04969491D2E0@dukhovni.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/dnsop/HHqffziOKS73F6ZrrfzVMk2JRoM>
Subject: Re: [DNSOP] Clarification question: compression pointers always to names earlier in the packet?
X-BeenThere: dnsop@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: IETF DNSOP WG mailing list <dnsop.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dnsop>, <mailto:dnsop-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dnsop/>
List-Post: <mailto:dnsop@ietf.org>
List-Help: <mailto:dnsop-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dnsop>, <mailto:dnsop-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 24 Oct 2018 09:22:19 -0000

Viktor,

On 24/10/2018 11.01, Viktor Dukhovni wrote:
> 
> My reading of RFC 1035 is that DNS name "compression"
> via "pointers" is restricted to name strictly earlier
> in the DNS message:
> 
>     4.1.4. Message compression
> 
>     In order to reduce the size of messages, the domain system utilizes a
>     compression scheme which eliminates the repetition of domain names in a
>     message.  In this scheme, an entire domain name or a list of labels at
>     the end of a domain name is replaced with a pointer to a prior occurance
>                                                              ---------------
>     of the same name.
> 
> And yet, here and there I see mention of having to take care to avoid "loops",
> but loops are impossible in a monotone strictly decreasing sequence.

I think the concern is something like this:

offset  octet
100     3
101     'f'
102     'o'
103     'o'
104     192
105     100


104 and 105 together point to offset 100, which will cause a loop even 
though they point to an earlier label.

> Is there a later RFC that relaxes the constraint and allows pointers to names
> later in the message?  I'm having a bit of trouble finding the later text...
> 
> Secondarily, can the pointer point to some odd-ball location earlier in the
> message that is not semantically a label in its original context, but just
> happens to carry data that decodes as the desired label?  Or, are pointers
> only valid to prior locations that are corresponding labels in their original
> context?

I have seen code which does this (there was an early version of the Knot 
authoritative server which used non-label offsets if it happened to have 
the correct data). Certainly it is easily possible that RDATA contains 
valid labels which could be used to by compression.

I think that for performance reasons most DNS software producing packets 
will maintain some data structure of prior labels & names in a packet 
and only reference those in compression. However, anything consuming DNS 
packets should probably be prepared for arbitrary pointers to previous 
locations in the packet - and also handle loops somehow (the usual 
options apply: either explicitly recording locations visited in 
traversal or just maintaining a counter and failing at some point).

Cheers,

--
Shane