Fragmentation Avoidance in DNS
Kazunori Fujiwara
Japan Registry Services Co., Ltd.
Chiyoda First Bldg. East 13F, 3-8-1 Nishi-Kanda
Chiyoda-ku, Tokyo
101-0065
Japan
+81 3 5215 8451
fujiwara@jprs.co.jp
Paul Vixie
AWS Security
11400 La Honda Road
Woodside, CA
94062
United States of America
+1 650 393 3994
paul@redbarn.org
22 August 2022
operations
Internet-Draft
EDNS0 enables a DNS server to send large responses using UDP and is widely deployed. Large DNS/UDP responses are fragmented, and IP fragmentation has exposed weaknesses in application protocols. It is possible to avoid IP fragmentation in DNS by limiting response size where possible, and signaling the need to upgrade from UDP to TCP transport where necessary. This document proposes to avoid IP fragmentation in DNS.
Introduction
DNS has EDNS0 [RFC6891] mechanism. It enables a DNS server to send large responses using UDP. EDNS0 is now widely deployed, and DNS (over UDP) is said to be the biggest user of IP fragmentation.
Fragmented DNS UDP responses have systemic weaknesses, which expose the requestor to DNS cache poisoning from off-path attackers. (See Appendix A for references and details.)
[RFC8900] summarized that IP fragmentation introduces fragility to Internet communication. The transport of DNS messages over UDP should take account of the observations stated in that document.
TCP avoids fragmentation using its Maximum Segment Size (MSS) parameter, but each transmitted segment is header-size aware such that the size of the IP and TCP headers is known, as well as the far end's MSS parameter and the interface or path MTU, so that the segment size can be chosen so as to keep the each IP datagram below a target size. This takes advantage of the elasticity of TCP's packetizing process as to how much queued data will fit into the next segment. In contrast, DNS over UDP has little datagram size elasticity and lacks insight into IP header and option size, and so must make more conservative estimates about available UDP payload space.
This document proposes to set "Don't Fragment flag (DF) bit" [RFC0791] on IPv4 and not to use "Fragment header" [RFC8200] on IPv6 in DNS/UDP messages in order to avoid IP fragmentation, and describes how to avoid packet losses due to DF bit and small MTU links.
Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP14 [RFC8174] when, and only when, they appear in all capitals, as shown here.
"Requestor" refers to the side that sends a request. "Responder" refers to an authoritative, recursive resolver or other DNS component that responds to questions. (Quoted from EDNS0 [RFC6891])
"Path MTU" is the minimum link MTU of all the links in a path between a source node and a destination node. (Quoted from [RFC8201])
In this document, the term "Path MTU discovery or similar methods" includes Classical Path MTU discovery [RFC1191], [RFC8201], Packetization Layer Path MTU discovery [RFC8899] and similar methods. For example, application layer fallback to smaller advertised EDNS requestor's UDP payload size.
In this document, the term "Don't Fragment" way implies to set "Don't Fragment flag (DF) bit" [RFC0791] on IPv4 and not to use "Fragment header" [RFC8200] on IPv6.
Many of the specialized terms used in this document are defined in DNS Terminology [RFC8499].
Proposal to avoid IP fragmentation in DNS
The methods to avoid IP fragmentation in DNS are described below:
Recommendations for UDP responders
- UDP responders SHOULD send DNS responses with "Don't Fragment" way.
- If the UDP responder detects immediate error that the UDP packet cannot be sent beyond the path MTU size (EMSGSIZE), the UDP responder MAY recreate response packets fit in path MTU size, or TC bit set.
- UDP responders MAY perform "Path MTU discovery or similar methods" per destination.
- UDP responders SHOULD compose UDP responses that result in IP packets that do not exceed the path MTU to the requestor.
- UDP responders SHOULD limit response size when UDP responders are located on small MTU (<1500) networks.
The cause and effect of the TC bit is unchanged from EDNS0 [RFC6891].
Recommendations for UDP requestors
- UDP requestors SHOULD send DNS requests with "Don't Fragment" way.
- UDP requestors SHOULD perform "Path MTU discovery or similar methods" per destination. Then, calculate their maximum DNS/UDP payload size as the reported path MTU minus IPv4/IPv6 header size (20 or 40) minus UDP header size (8). If the path MTU discovery failed or is impossible, use the default maximum DNS/UDP payload size 1400.
- UDP requestors SHOULD use the requestor's payload size as the calculated or the default maximum DNS/UDP payload size.
- UDP requestors MAY drop fragmented DNS/UDP responses without IP reassembly to avoid cache poisoning attacks.
- DNS responses may be dropped by IP fragmentation. Upon a timeout, to avoid name resolution fails, UDP requestors MAY retry using TCP or UDP with smaller maximum DNS/UDP payload size per local policy.
Request to zone operators and DNS server operators
Large DNS responses are the result of zone configuration. Zone operators SHOULD seek configurations resulting in small responses. For example,
- Use smaller number of name servers (13 may be too large)
- Use smaller number of A/AAAA RRs for a domain name
- Use 'minimal-responses' configuration: Some implementations have 'minimal responses' configuration that causes DNS servers to make response packets smaller, containing only mandatory and required data (Appendix C).
- Use smaller signature / public key size algorithm for DNSSEC. Notably, the signature size of ECDSA or EdDSA is smaller than RSA.
Considerations
Protocol compliance
In prior research ([Fujiwara2018] and dns-operations mailing list discussions), there are some authoritative servers that ignore EDNS0 requestor's UDP payload size, and return large UDP responses.
It is also well known that there are some authoritative servers that do not support TCP transport.
Such non-compliant behavior cannot become implementation or configuration constraints for the rest of the DNS. If failure is the result, then that failure must be localized to the non-compliant servers.
IANA Considerations
This document has no IANA actions.
Security Considerations
When avoiding fragmentation, a DNS/UDP requestor behind a small-MTU network may experience UDP timeouts which would reduce performance and which may lead to TCP fallback. This would indicate prior reliance upon IP fragmentation, which is universally considered to be harmful to both performance and stability of applications, endpoints, and gateways. Avoiding IP fragmentation will improve operating conditions overall, and the performance of DNS/TCP has increased and will continue to increase.
Acknowledgments
The author would like to specifically thank Paul Wouters, Mukund Sivaraman, Tony Finch, Hugo Salgado, Peter van Dijk, Brian Dickson, Puneet Sood, Jim Reid, Petr Spacek, Peter van Dijk, Andrew McConachie, Joe Abley, Daisuke Higashi and Joe Touch for extensive review and comments.

Normative References
[RFC0791]

Internet Protocol
J. Postel
September 1981
STD 5
RFC 791
DOI 10.17487/RFC0791
[RFC1191]

Path MTU discovery
J.C. Mogul
S.E. Deering
November 1990
RFC 1191
DOI 10.17487/RFC1191
[RFC2119]

Key words for use in RFCs to Indicate Requirement Levels
S. Bradner
March 1997
BCP 14
RFC 2119
DOI 10.17487/RFC2119
[RFC4035]

Protocol Modifications for the DNS Security Extensions
R. Arends
R. Austein
M. Larson
D. Massey
S. Rose
March 2005
RFC 4035
DOI 10.17487/RFC4035
[RFC8201]

Path MTU Discovery for IP version 6
J. McCann
S. Deering
J. Mogul
R. Hinden, Ed.
July 2017
STD 87
RFC 8201
DOI 10.17487/RFC8201
[RFC6891]

Extension Mechanisms for DNS (EDNS(0))
J. Damas
M. Graff
P. Vixie
April 2013
STD 75
RFC 6891
DOI 10.17487/RFC6891
[RFC8174]

Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words
B. Leiba
May 2017
BCP 14
RFC 8174
DOI 10.17487/RFC8174
[RFC8200]

Internet Protocol, Version 6 (IPv6) Specification
S. Deering
R. Hinden
July 2017
STD 86
RFC 8200
DOI 10.17487/RFC8200
[RFC8499]

DNS Terminology
P. Hoffman
A. Sullivan
K. Fujiwara
January 2019
BCP 219
RFC 8499
DOI 10.17487/RFC8499
[RFC8899]

Packetization Layer Path MTU Discovery for Datagram Transports
G. Fairhurst
T. Jones
M. Tüxen
I. Rüngeler
T. Völker
September 2020
RFC 8899
DOI 10.17487/RFC8899

Informative References
[RFC5155]

DNS Security (DNSSEC) Hashed Authenticated Denial of Existence
B. Laurie
G. Sisson
R. Arends
D. Blacka
March 2008
RFC 5155
DOI 10.17487/RFC5155
[RFC7739]

Security Implications of Predictable Fragment Identification Values
F. Gont
February 2016
RFC 7739
DOI 10.17487/RFC7739
[RFC8085]

UDP Usage Guidelines
L. Eggert
G. Fairhurst
G. Shepherd
March 2017
BCP 145
RFC 8085
DOI 10.17487/RFC8085
[RFC8900]

IP Fragmentation Considered Fragile
R. Bonica
F. Baker
G. Huston
R. Hinden
O. Troan
F. Gont
September 2020
BCP 230
RFC 8900
DOI 10.17487/RFC8900
[Brandt2018]

Domain Validation++ For MitM-Resilient PKI
Markus Brandt
Fraunhofer Institute for Secure Information Technology SIT, Darmstadt, Germany
Tianxiang Dai
Fraunhofer Institute for Secure Information Technology SIT, Darmstadt, Germany
Amit Klein
Fraunhofer Institute for Secure Information Technology SIT, Darmstadt, Germany
Haya Shulman
Fraunhofer Institute for Secure Information Technology SIT, Darmstadt, Germany
Michael Waidner
Fraunhofer Institute for Secure Information Technology SIT, Darmstadt, Germany
2018
Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security
[Herzberg2013]

Fragmentation Considered Poisonous
Amir Herzberg
Haya Shulman
2013
IEEE Conference on Communications and Network Security
[Hlavacek2013]

IP fragmentation attack on DNS
Tomas Hlavacek
cz.nic
2013
RIPE 67 Meeting
[Fujiwara2018]

Measures against cache poisoning attacks using IP fragmentation in DNS
Kazunori Fujiwara
JPRS
2019
OARC 30 Workshop
[DNSFlagDay2020]

DNS flag day 2020
n.d.
[Huston2021]

Measuring DNS Flag Day 2020
Geoff Huston
APNIC Labs
Joao Damas
APNIC Labs
February 2021
OARC 34 Workshop
Weaknesses of IP fragmentation
"Fragmentation Considered Poisonous" [Herzberg2013] proposed effective off-path DNS cache poisoning attack vectors using IP fragmentation. "IP fragmentation attack on DNS" [Hlavacek2013] and "Domain Validation++ For MitM-Resilient PKI" [Brandt2018] proposed that off-path attackers can intervene in path MTU discovery [RFC1191] to perform intentionally fragmented responses from authoritative servers. [RFC7739] stated the security implications of predictable fragment identification values.
DNSSEC is a countermeasure against cache poisoning attacks that use IP fragmentation. However, DNS delegation responses are not signed with DNSSEC, and DNSSEC does not have a mechanism to get the correct response if an incorrect delegation is injected. This is a denial-of-service vulnerability that can yield failed name resolutions. If cache poisoning attacks can be avoided, DNSSEC validation failures will be avoided.
In Section 3.2 (Message Side Guidelines) of UDP Usage Guidelines [RFC8085] we are told that an application SHOULD NOT send UDP datagrams that result in IP packets that exceed the Maximum Transmission Unit (MTU) along the path to the destination.
A DNS message receiver cannot trust fragmented UDP datagrams primarily due to the small amount of entropy provided by UDP port numbers and DNS message identifiers, each of which being only 16 bits in size, and both likely being in the first fragment of a packet, if fragmentation occurs. By comparison, TCP protocol stack controls packet size and avoid IP fragmentation under ICMP NEEDFRAG attacks. In TCP, fragmentation should be avoided for performance reasons, whereas for UDP, fragmentation should be avoided for resiliency and authenticity reasons.
Details of maximum DNS/UDP payload size discussions
There are many discussions for default path MTU size and maximum DNS/UDP payload size.
- The minimum MTU for an IPv6 interface is 1280 octets (see Section 5 of [RFC8200]). Then, we can use it as default path MTU value for IPv6. The corresponding minimum MTU for an IPv4 interface is 68 (60 + 8) [RFC0791].
- Most of the Internet and especially the inner core has an MTU of at least 1500 octets. Maximum DNS/UDP payload size for IPv6 on MTU 1500 ethernet is 1452 (1500 minus 40 (IPv6 header size) minus 8 (UDP header size)). To allow for possible IP options and distant tunnel overhead, authors' recommendation of default maximum DNS/UDP payload size is 1400.
- [RFC4035] defines that "A security-aware name server MUST support the EDNS0 message size extension, MUST support a message size of at least 1220 octets". Then, the smallest number of the maximum DNS/UDP payload size is 1220.
- In order to avoid IP fragmentation, [DNSFlagDay2020] proposed that the UDP requestors set the requestor's payload size to 1232, and the UDP responders compose UDP responses fit in 1232 octets. The size 1232 is based on an MTU of 1280, which is required by the IPv6 specification [RFC8200], minus 48 octets for the IPv6 and UDP headers.
- [Huston2021] analyzed the result of [DNSFlagDay2020], reported that their measurements suggest that in the interior of the Internet between recursive resolvers and authoritative servers the prevailing MTU is at 1,500 and there is no measurable signal of use of smaller MTUs in this part of the Internet, and proposed that their measurements suggest setting the EDNS0 Buffer size to IPv4 1472 octets and IPv6 1452 octets.
Minimal-responses
Some implementations have 'minimal responses' configuration that causes a DNS server to make response packets smaller, containing only mandatory and required data.
Under the minimal-responses configuration, DNS servers compose response messages using only RRSets corresponding to queries. In case of delegation, DNS servers compose response packets with delegation NS RRSet in authority section and in-domain (in-zone and below-zone) glue in the additional data section. In case of non-existent domain name or non-existent type, the start of authority (SOA RR) will be placed in the Authority Section.
In addition, if the zone is DNSSEC signed and a query has the DNSSEC OK bit, signatures are added in answer section, or the corresponding DS RRSet and signatures are added in authority section. Details are defined in [RFC4035] and [RFC5155].