[GH-ISSUE #4242] Built-in DNS server ignores buffer size - implement truncate and compress #8305

Open
opened 2026-08-05 01:17:17 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @hurricanehrndz on GitHub (Jul 29, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4242

Describe the problem

The built in DNS server does not scrub messages prior to writing replies to clients. Client by default will communicate the buffer size and the server should either truncate or compress messages when the buffer has overflown, the message is simply written via the dns pkg.

Default UDP buffer by some client is 512, when supporting edns0 it is usually 1232. The server should also support TCP for client like dig that will retry with TCP when messages are truncated.

https://datatracker.ietf.org/doc/html/rfc7766

To Reproduce

Steps to reproduce the behavior:


; <<>> DiG 9.20.9 <<>> @100.122.255.254 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20515
;; flags: qr rd ra; QUERY: 1, ANSWER: 10, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;github-cloud.s3.amazonaws.com. IN      A

;; ANSWER SECTION:
github-cloud.s3.amazonaws.com. 24095 IN CNAME   s3-1-w.amazonaws.com.
s3-1-w.amazonaws.com.   131     IN      CNAME   s3-w.us-east-1.amazonaws.com.
s3-w.us-east-1.amazonaws.com. 2 IN      A       52.216.210.145
s3-w.us-east-1.amazonaws.com. 2 IN      A       52.217.119.1
s3-w.us-east-1.amazonaws.com. 2 IN      A       52.216.107.124
s3-w.us-east-1.amazonaws.com. 2 IN      A       3.5.16.19
s3-w.us-east-1.amazonaws.com. 2 IN      A       3.5.27.209
s3-w.us-east-1.amazonaws.com. 2 IN      A       16.15.176.156
s3-w.us-east-1.amazonaws.com. 2 IN      A       3.5.29.79
s3-w.us-east-1.amazonaws.com. 2 IN      A       52.217.125.73

;; Query time: 31 msec
;; SERVER: 100.122.255.254#53(100.122.255.254) (UDP)
;; WHEN: Tue Jul 29 15:16:46 MDT 2025
;; MSG SIZE  rcvd: 535

Expected behavior
expected either TC flag to be set and retry to occur on TCP, but netbird lacks a TCP listener, or for the message above to have been compressed. In all reality the example above should have had compression enable, as most upstream servers would have done so.

i.e.

❯ dig @8.8.8.8 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com

; <<>> DiG 9.20.9 <<>> @8.8.8.8 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4052
;; flags: qr rd ra; QUERY: 1, ANSWER: 10, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;github-cloud.s3.amazonaws.com. IN      A

;; ANSWER SECTION:
github-cloud.s3.amazonaws.com. 20461 IN CNAME   s3-1-w.amazonaws.com.
s3-1-w.amazonaws.com.   1       IN      CNAME   s3-w.us-east-1.amazonaws.com.
s3-w.us-east-1.amazonaws.com. 1 IN      A       54.231.229.33
s3-w.us-east-1.amazonaws.com. 1 IN      A       52.216.86.163
s3-w.us-east-1.amazonaws.com. 1 IN      A       3.5.21.159
s3-w.us-east-1.amazonaws.com. 1 IN      A       52.217.131.169
s3-w.us-east-1.amazonaws.com. 1 IN      A       52.217.193.201
s3-w.us-east-1.amazonaws.com. 1 IN      A       3.5.25.31
s3-w.us-east-1.amazonaws.com. 1 IN      A       3.5.6.11
s3-w.us-east-1.amazonaws.com. 1 IN      A       52.217.85.116

;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP)
;; WHEN: Tue Jul 29 15:20:52 MDT 2025
;; MSG SIZE  rcvd: 236

Another good test is nat.travisci.net

Are you using NetBird Cloud?
No and N/A

NetBird version

0.52.1

Is any other VPN software installed?

no

Originally created by @hurricanehrndz on GitHub (Jul 29, 2025). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4242 **Describe the problem** The built in DNS server does not [scrub messages](https://github.com/coredns/coredns/blob/master/request/request.go#L216) prior to writing replies to clients. Client by default will communicate the buffer size and the server should either [truncate or compress messages](https://github.com/miekg/dns/blob/master/msg_truncate.go) when the buffer has overflown, the [message is simply written](https://github.com/netbirdio/netbird/blob/main/client/internal/dns/upstream.go#L153) via the [dns pkg](https://github.com/miekg/dns/blob/master/server.go#L748). Default UDP buffer by some client is 512, when supporting edns0 it is usually 1232. The server should also support TCP for client like dig that will retry with TCP when messages are truncated. https://datatracker.ietf.org/doc/html/rfc7766 **To Reproduce** Steps to reproduce the behavior: ```❯ dig @100.122.255.254 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com ; <<>> DiG 9.20.9 <<>> @100.122.255.254 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20515 ;; flags: qr rd ra; QUERY: 1, ANSWER: 10, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;github-cloud.s3.amazonaws.com. IN A ;; ANSWER SECTION: github-cloud.s3.amazonaws.com. 24095 IN CNAME s3-1-w.amazonaws.com. s3-1-w.amazonaws.com. 131 IN CNAME s3-w.us-east-1.amazonaws.com. s3-w.us-east-1.amazonaws.com. 2 IN A 52.216.210.145 s3-w.us-east-1.amazonaws.com. 2 IN A 52.217.119.1 s3-w.us-east-1.amazonaws.com. 2 IN A 52.216.107.124 s3-w.us-east-1.amazonaws.com. 2 IN A 3.5.16.19 s3-w.us-east-1.amazonaws.com. 2 IN A 3.5.27.209 s3-w.us-east-1.amazonaws.com. 2 IN A 16.15.176.156 s3-w.us-east-1.amazonaws.com. 2 IN A 3.5.29.79 s3-w.us-east-1.amazonaws.com. 2 IN A 52.217.125.73 ;; Query time: 31 msec ;; SERVER: 100.122.255.254#53(100.122.255.254) (UDP) ;; WHEN: Tue Jul 29 15:16:46 MDT 2025 ;; MSG SIZE rcvd: 535 ``` **Expected behavior** expected either TC flag to be set and retry to occur on TCP, but netbird lacks a TCP listener, or for the message above to have been compressed. In all reality the example above should have had compression enable, as most upstream servers would have done so. i.e. ``` ❯ dig @8.8.8.8 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com ; <<>> DiG 9.20.9 <<>> @8.8.8.8 +noedns +comments +bufsize=512 github-cloud.s3.amazonaws.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4052 ;; flags: qr rd ra; QUERY: 1, ANSWER: 10, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;github-cloud.s3.amazonaws.com. IN A ;; ANSWER SECTION: github-cloud.s3.amazonaws.com. 20461 IN CNAME s3-1-w.amazonaws.com. s3-1-w.amazonaws.com. 1 IN CNAME s3-w.us-east-1.amazonaws.com. s3-w.us-east-1.amazonaws.com. 1 IN A 54.231.229.33 s3-w.us-east-1.amazonaws.com. 1 IN A 52.216.86.163 s3-w.us-east-1.amazonaws.com. 1 IN A 3.5.21.159 s3-w.us-east-1.amazonaws.com. 1 IN A 52.217.131.169 s3-w.us-east-1.amazonaws.com. 1 IN A 52.217.193.201 s3-w.us-east-1.amazonaws.com. 1 IN A 3.5.25.31 s3-w.us-east-1.amazonaws.com. 1 IN A 3.5.6.11 s3-w.us-east-1.amazonaws.com. 1 IN A 52.217.85.116 ;; Query time: 23 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) (UDP) ;; WHEN: Tue Jul 29 15:20:52 MDT 2025 ;; MSG SIZE rcvd: 236 ``` Another good test is nat.travisci.net **Are you using NetBird Cloud?** No and N/A **NetBird version** 0.52.1 **Is any other VPN software installed?** no
saavagebueno added the triage-needed label 2026-08-05 01:17:17 -04:00
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#8305