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

Shane Kerr <> Wed, 24 October 2018 09:22 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 6D31C130EDB for <>; Wed, 24 Oct 2018 02:22:15 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.901
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id 5BNegduerOsF for <>; Wed, 24 Oct 2018 02:22:13 -0700 (PDT)
Received: from ( [IPv6:2a02:2770::21a:4aff:fea3:eeaa]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 902B7130F26 for <>; Wed, 24 Oct 2018 02:22:13 -0700 (PDT)
Received: from [2001:470:78c8:2:15ed:fde8:14a8:fa4] by with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from <>) id 1gFFMq-0003lq-Di for; Wed, 24 Oct 2018 09:22:20 +0000
References: <>
From: Shane Kerr <>
Message-ID: <>
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: <>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <>
Subject: Re: [DNSOP] Clarification question: compression pointers always to names earlier in the packet?
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: IETF DNSOP WG mailing list <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Wed, 24 Oct 2018 09:22:19 -0000


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).