[GH-ISSUE #2412] Unexpected ADDITIONAL section for CNAME-related queries #981

Open
opened 2026-03-16 01:09:51 +03:00 by kerem · 1 comment
Owner

Originally created by @PRRIN on GitHub (Sep 3, 2024).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2412

What happened:

When querying a domain name that has a CNAME record, the ADDITIONAL section incorrectly contains records that should not exist or should be in the ANSWER section.

How to reproduce it (as minimally and precisely as possible):

Using the following zone file (a.zone):

a.          500 IN SOA    b.c.d. e.a.d. 3 604800 86400 2419200 604800 
a.          500 IN NS     b.c.d. 
d.a.        500 IN CNAME  e.a.
e.a.        500 IN CNAME  g.a.
g.a.        500 IN A      1.1.1.1

and this zone config (zone.toml):

[[zones]]
zone = "a"
zone_type = "Primary"
file = "a.zone"

Response for querying <d.a. A> and <d.a. CNAME>:

root@6755885182dd:/app/hickory-dns# dig @127.0.0.1 -p 24141 d.a. A +norecurse

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 24141 d.a. A +norecurse
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26395
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
;; QUESTION SECTION:
;d.a.                           IN      A

;; ANSWER SECTION:
d.a.                    500     IN      CNAME   e.a.

;; ADDITIONAL SECTION:
e.a.                    500     IN      CNAME   g.a.
g.a.                    500     IN      A       1.1.1.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#24141(127.0.0.1) (UDP)
;; WHEN: Mon Sep 02 18:13:42 UTC 2024
;; MSG SIZE  rcvd: 81
root@6755885182dd:/app/hickory-dns# dig @127.0.0.1 -p 24141 d.a. CNAME +norecurse

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 24141 d.a. CNAME +norecurse
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8071
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags: do; udp: 1232
;; QUESTION SECTION:
;d.a.                           IN      CNAME

;; ANSWER SECTION:
d.a.                    500     IN      CNAME   e.a.

;; ADDITIONAL SECTION:
e.a.                    500     IN      CNAME   g.a.

;; Query time: 10 msec
;; SERVER: 127.0.0.1#24141(127.0.0.1) (UDP)
;; WHEN: Mon Sep 02 17:07:27 UTC 2024
;; MSG SIZE  rcvd: 65

What you expected to happen:

For query <d.a. A>, the records in ADDITIONAL section should be in ANSWER section, as mentioned in #2099.
For query <d.a. CNAME>, there should be nothing in ADDITIONAL section.

It appears that hickory-dns might not be handling CNAME-related queries correctly. RFC1034 mentions that

CNAME RRs cause special action in DNS software.  When a name server
fails to find a desired RR in the resource set associated with the
domain name, it checks to see if the resource set consists of a CNAME
record with a matching class.  If so, the name server includes the CNAME
record in the response and restarts the query at the domain name
specified in the data field of the CNAME record.  The one exception to
this rule is that queries which match the CNAME type are not restarted.
(see [RFC1034], Section 3.6.2)

Environment:

  • the virsion of hickory-dns: v0.24.1, 6334a01
  • rustc version: 1.69.0
Originally created by @PRRIN on GitHub (Sep 3, 2024). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2412 **What happened:** When querying a domain name that has a CNAME record, the ADDITIONAL section incorrectly contains records that should not exist or should be in the ANSWER section. **How to reproduce it (as minimally and precisely as possible):** Using the following zone file (`a.zone`): ``` a. 500 IN SOA b.c.d. e.a.d. 3 604800 86400 2419200 604800 a. 500 IN NS b.c.d. d.a. 500 IN CNAME e.a. e.a. 500 IN CNAME g.a. g.a. 500 IN A 1.1.1.1 ``` and this zone config (`zone.toml`): ``` [[zones]] zone = "a" zone_type = "Primary" file = "a.zone" ``` Response for querying `<d.a. A>` and `<d.a. CNAME>`: ``` root@6755885182dd:/app/hickory-dns# dig @127.0.0.1 -p 24141 d.a. A +norecurse ; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 24141 d.a. A +norecurse ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26395 ;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 3 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1232 ;; QUESTION SECTION: ;d.a. IN A ;; ANSWER SECTION: d.a. 500 IN CNAME e.a. ;; ADDITIONAL SECTION: e.a. 500 IN CNAME g.a. g.a. 500 IN A 1.1.1.1 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#24141(127.0.0.1) (UDP) ;; WHEN: Mon Sep 02 18:13:42 UTC 2024 ;; MSG SIZE rcvd: 81 ``` ``` root@6755885182dd:/app/hickory-dns# dig @127.0.0.1 -p 24141 d.a. CNAME +norecurse ; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> @127.0.0.1 -p 24141 d.a. CNAME +norecurse ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8071 ;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags: do; udp: 1232 ;; QUESTION SECTION: ;d.a. IN CNAME ;; ANSWER SECTION: d.a. 500 IN CNAME e.a. ;; ADDITIONAL SECTION: e.a. 500 IN CNAME g.a. ;; Query time: 10 msec ;; SERVER: 127.0.0.1#24141(127.0.0.1) (UDP) ;; WHEN: Mon Sep 02 17:07:27 UTC 2024 ;; MSG SIZE rcvd: 65 ``` **What you expected to happen:** For query `<d.a. A>`, the records in ADDITIONAL section should be in ANSWER section, as mentioned in #2099. For query `<d.a. CNAME>`, there should be nothing in ADDITIONAL section. It appears that hickory-dns might not be handling CNAME-related queries correctly. [RFC1034](https://www.rfc-editor.org/rfc/rfc1034) mentions that ``` CNAME RRs cause special action in DNS software. When a name server fails to find a desired RR in the resource set associated with the domain name, it checks to see if the resource set consists of a CNAME record with a matching class. If so, the name server includes the CNAME record in the response and restarts the query at the domain name specified in the data field of the CNAME record. The one exception to this rule is that queries which match the CNAME type are not restarted. (see [RFC1034], Section 3.6.2) ``` **Environment:** - the virsion of hickory-dns: `v0.24.1, 6334a01` - rustc version: 1.69.0
Author
Owner

@djc commented on GitHub (Sep 4, 2024):

Thanks for the report! Happy to provide guidance on how to fix/review a PR, unfortunately I likely won't have time to fix it myself (although I do offer commercial support if that would be of interest to you/your employer).

<!-- gh-comment-id:2328138910 --> @djc commented on GitHub (Sep 4, 2024): Thanks for the report! Happy to provide guidance on how to fix/review a PR, unfortunately I likely won't have time to fix it myself (although I do offer commercial support if that would be of interest to you/your employer).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#981
No description provided.