KeyTrap
KeyTrap
497
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
resolver implementation, and can be up to 16 hours, see Table 4. For 1 for(i=0; i<num; i++) {
2
comparison, a recently proposed NRDelegation attack [2] which 3 /* see if key matches keytag and algo */
exploited vulnerabilities in DNS to create multiple referral requests, 4 if(algo != dnskey_get_algo(dnskey, i) ||
would require 1569 DNS packets to cause a comparable increase 5 tag != dnskey_calc_keytag(dnskey, i))
6 continue;
in CPU instruction count, which our attacks achieve with a single 7
packet. We find that all DNSSEC validating DNS software, DNS 8 numchecked ++;
9
libraries and public DNS services on our dataset are vulnerable to 10 /* see if key verifies */
our attacks; see list in Table 1. 11 sec = dnskey_verify_rrset_sig(env, ve, rrset, dnskey,
↩→ i, sig_idx);
Flaws in DNSSEC. We find that the flaws in DNSSEC specifica- 12
1 https://datatracker.ietf.org/doc/html/rfc4035#section-5.3.
1,https://datatracker.ietf.org/doc/html/rfc4034#appendix-B 2 https://datatracker.ietf.org/doc/html/rfc2535#page-46
498
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
The vulnerabilities have been in the wild since at least August Kaminsky’s demonstration, despite the concerns, the vendors did
2000 in Bind9 DNS resolver3 and were introduced into the code4 of not consider this a practical threat. Following Kaminsky’s attack,
Unbound DNS resolver in August 2007. Using Unbound as an exam- all the vendors quickly patched their DNS resolvers to send DNS
ple, the vulnerable code performs loops over keys and signatures, requests from unpredictable ports. This and other examples show
as shown by Listings 1 and 2. that to improve security a deep understanding of the problem at
Although the vulnerabilities have existed in the standard for hand is required, in order to find a way to weaponize it, so that it
about 25 years and in the wild for 24 years, they have not been then becomes an attack. This was also the case with key trap, after
noticed by the community. This is not surprising since the complex- we found a way to demonstrate for the first time that key trap was
ity of the DNSSEC validation requirements made it challenging to a practical threat, all the vendors immediately issued patches.
identify the flaws. The exploit requires a combination of a number Contributions. We make the following contributions:
of requirements, which made it not trivial even for DNS experts • Conceptually, we find that the aim to ensure validation at any
to notice. The security community made similar experiences with cost in DNSSEC standard exposes the DNS resolvers to attacks.
much simpler vulnerabilities, such as Heartbleed or Log4j [5, 7] We analyze the DNSSEC standards in §4, and identify flaws in the
which were there but no one could see them, and they took years DNSSEC standards which enable complexity attacks.
to notice and fix. Unfortunately, in contrast to these vulnerabilities, • We combine the flaws in the RFCs to develop the first algo-
the vulnerabilities we find in this work are not simple to resolve, rithmic complexity attacks that exploit vulnerabilities in DNSSEC.
since they are fundamentally rooted in the design philosophy of We find experimentally that all standard-compliant DNS imple-
DNSSEC, and are not just mere software implementation bugs. mentations support the flawed recommendations and hence are
Flaws are challenging to mitigate. The flaws in DNSSEC val- vulnerable to our attacks.
idation are not simple to solve. There are legitimate situations in • We analyze the code of popular DNS implementations to iden-
which nameservers may return multiple keys, e.g., to account for tify the effects of the stalling on, e.g., caching, pending DNS requests
potential failures. For instance, some domains may be experiment- or inbound/pending DNS packets. We use our observations to pro-
ing with new ciphers, not yet supported by all the resolvers and vide recommendations for adapting the architecture of the resolvers
there are keys-rollover. To avoid failures the nameservers should to improve the robustness to failures and attacks.
return all the cryptographic material. Similarly, to ensure successful • We performed ethical disclosure of our vulnerabilities to the
validation, the resolvers should not fail on the first unsuccessful major DNS vendors, DNS/CDN/cloud operators and standardizers
validation, but should try all the material until validation succeeds. on November 2, 2023. Since then, we have been intensively working
Indeed, the experience we made since we have started working with this group on developing patches and regularly communicating
on the patches with the developers shows that these flaws can be with the developers within a closed chat group. We provided to the
substantially mitigated, but cannot be completely solved. Attacks developers our attack vectors encoded in DNS zonefiles and set up a
against the final patch still result in heavy CPU load caused by high test environment for evaluation of vulnerabilities in DNSSEC, which
attacker traffic, but at least DNS packet loss is prevented. Solving alleviates the need for manual setup and enables quick evaluation of
these issues fundamentally requires to reconsider the basics of the the attacks against the proposed patches. We provide a timeline for
design philosophy of the Internet. disclosure and of the patches development process. Our discovered
The importance of understanding and weaponizing vul- vulnerabilities were assigned an umbrella CVE in December 2023.
nerabilities. While there were concerns in the community that Organization. We compare our research to related work in §2.
key tag collisions could introduce a weakness5 and even a bach- We provide an overview of DNS and DNSSEC in §3. We analyze
elor project attempted to find an attack6 , no compelling method the recommendations in the DNS standard specification in §4. We
to weaponize the key tag and demonstrate an attack was found. construct the attacks in §5 and evaluate them against major DNS
Therefore, the collisions were not regarded as a practical threat implementations and services in §6. Disclosure and the process of
and vendors did not issue patches. Understanding how to exploit developing mitigations are in §7. We discuss ethical considerations
and weaponize a vulnerability and the ability to demonstrate it to in §8 and conclude in §9.
the community is critical. There are numerous examples where the
ability to understand and realize a threat led to improvements in
the security landscape. One such example in DNS is that of port 2 Related Work
randomization. Initially the DNS resolvers were using predictable In Distributed Denial of Service (DDoS) attacks adversaries flood a
or fixed source ports for their requests, until a security expert victim resource, e.g., a network bandwidth or a buffer, with a large
Kaminsky found a way to weaponize and demonstrated a practical volume of packets loading the target victim beyond its available ca-
DNS cache poisoning attack [10]. Although predictable DNS source pacity and causing packet loss [12]. DNS is often a victim of DDoS,
ports were seen by many experts in the community as a threat, this either as a target or as a reflector to flood other victims. Since DNS
was not fixed until a practical attack was demonstrated7 . Prior to responses are larger than DNS requests, reflected DNS responses
3 https://github.com/isc-projects/bind9/commit/ amplify the load generated by the attacker’s requests. The amplifi-
6f17d90364f01c3e81073a9ffb40b0093878c8e2 cation factor is exacerbated with DNSSEC, whose signatures and
4 https://github.com/NLnetLabs/unbound/commit/
keys further increase the sizes of DNS responses [16]. An amplifi-
8f58908f45d69178f8a30125d8ebcedf3c6f6761 cation effect can also be achieved by exploiting vulnerabilities in
5 https://ripe78.ripe.net/presentations/5-20190520-RIPE-78-DNS-wg-Keytags.pdf
6 https://essay.utwente.nl/78777/1/Research_paper.pdf protocol implementations or vulnerabilities in the processing of
7 https://makezine.com/article/technology/djbdns-dns-exploits-bernstein/ DNS records [4, 14]. NXNSAttack [1] exploited a vulnerability that
499
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
generated a flood of queries between the recursive resolver and hours (depending on the resolver software) with a single DNS re-
the authoritative server creating a load on them both. Recently, [2] sponse packet. All the resolvers we tested were found vulnerable
demonstrated a complexity attack on DNS which causes a victim to our attacks. We evaluate how DNS implementations react to the
resolver to issue multiple queries, following delegation responses load created by the attack and find that certain design choices can
by a malicious authoritative server. The victim resolver issues the enable faster recovery from our DoS attacks.
queries to nameservers which do not respond, eventually exhaust- Our work is also related to downgrade attacks against DNSSEC,
ing its resources. DNSSEC [9]. The DNSSEC-downgrade attacks however focus on
The NRDelegation attack in [2] is shown to achieve a 5600x in- disabling DNSSEC validation, but do not have adverse effects on
crease in CPU instructions between the attack requests and benign the availability of the victim resolvers.
DNS requests. In contrast, our KeyTrap attack in this work achieves
a 2000000x increase in CPU instruction count. 3 Overview of DNSSEC
To compare the impact between both attacks on the CPU instruc-
DNSSEC [RFC4033-4035] ensures origin authenticity and data in-
tion count, we set up a benign and a malicious signed domains. We
tegrity in DNS. To gain security benefits the domain owners should
set up an Unbound resolver in an isolated environment and run
digitally sign the records in their domains, and should upgrade the
Linux perf to measure CPU instruction count. We first measure the
nameservers to serve DNSSEC-signed DNS responses. The DNS
CPU instruction count of a request to a benign DNSSEC signed
resolvers should validate the received DNS records against the dig-
domain. To ensure reliability we average out the instruction count
ital signatures. To validate the public keys the resolvers should
over five measurements. Further, we set up the attack domain on
construct a validation path from the root zone to the target domain.
the same DNS server. The measurements are conducted on Ubuntu
If validation fails, the resolver must not deliver the bogus records
22.04 LTS with Unbound 1.19.0 DNS software. In our test setup, we
to the client and instead signal an error by sending a SERVFAIL
find that a benign request on a signed DNSSEC domain requires
response. If DNSSEC validation is successful, the resolver should
approx. 811.500 CPU instructions on Unbound. In contrast, we
return the requested records to the client and cache them.
find a significantly higher instruction count for the resolution of
DNSSEC signatures are conveyed in RRSIG-type DNS records.
the KeyTrap attack domain. To resolve and validate the domain,
An RRSIG record is associated with the set of records (RRset) it
Unbound takes approximately 1.725.000.000.000 CPU instruc-
covers by name, class, and the record type indicated by an RRSIG-
tions. Comparing to the benign request, the attack thus leads to
specific record field. The public keys used to validate the signatures
a 2.000.000x increase in CPU instruction count, compared to the
are sent in DNSKEY-type records.
5600x increase in NR delegation. Directly comparing the CPU in-
There are two types of keys: Zone-Signing-Key (ZSK) and Key-
structions count of [2], we find that NR delegation attack requires
Signing-Key (KSK). The ZSKs are used to sign records in the zone
1569 queries to result in the same increase in CPU instruction count
and are authenticated with a KSK. DNSKEY records contain multiple
as a single request with our KeyTrap attack. Hence, a KeyTrap
fields, including usage-indicating flags, the protocol and algorithm
request leads to the same load as approx. 2 million benign requests.
specifiers, and the key bytes. From these record data the key tag
Van Rijswijk-Deij et al. [15] explored the performance of ECC
can be calculated. The KSKs and all ZSKs of a zone are included
vs RSA on Bind9 and Unbound. They evaluated the load on the
into a DNSKEY set which is signed by at least one KSK. Signature
Bind9 and Unbound resolvers when sending multiple signatures and
records covering the DNSKEY set need to reference the key tag of a
found that the ECC algorithms do not impose too much additional
KSK. Only after the DNSKEY set is validated can the ZSK be used to
CPU load on the two resolvers in contrast to RSA. To create load the
validate signatures covering other records (RRs). To support simple
authors made the resolver request a large number of non-existent
DNSSEC setups, KSK and ZSK can be identical.
records (NSEC3), causing many DNS responses, each carrying up to
DS records from a parent zone are used to authenticate individual
three NSEC3 records plus one SOA, with one signature validation
KSK type DNSKEY records in a child zone. This is done to delegate
per record. In effect, the victim resolver was validating four RRSIG
trust from a parent zone public key to a child zone public key.
records per response. While the responses sent by [15] caused
DS records use the same triple (zone name, algorithm, key tag) as
the resolver to perform 4 validations, equivalent to the number
RRSIGs to identify a subset of candidate DNSKEYs.
of signatures their nameserver returned (an order of O (𝑛)), our
DNS records contain mappings from DNS names to resources.
specially crafted records trigger more than 500K validations per
In this work, we use the DNS A record in the evaluations of our
DNS response (an order of O (𝑛 2 )). Our attack scales quadratically
attacks. The A record contains the mapping of a domain name in
with the number of keys returned to the resolver.
the zone to an IPv4 address. The A record includes a TTL value,
In contrast to previous work our KeyTrap attacks do not require
which specifies the validity period for caching. The A-type record is
multiple packets, instead we exploit algorithmic complexity vulner-
queried by a resolver when resolving a domain name. For instance,
abilities in the DNSSEC validation in DNS resolvers as a building
an A record may map the domain www-x.attack.er to the IP address
block to develop CPU based DoS attacks. Our complexity attacks
6.6.6.6. We explain the functionality of DNS and DNSSEC with
are triggered by feeding the DNS resolvers with specially crafted
concrete examples in §5.
DNSSEC records, which are constructed in a way that exploits vali-
dation vulnerabilities in cryptographic validation logic. When the
DNS resolvers attempt to validate the DNSSEC records they receive 4 Analysis of DNSSEC Specification
from our nameserver, they get stalled. Our attacks are extremely In the following, we illustrate the validation recommendations in
stealthy, being able to stall resolvers between 170 seconds and 16 the DNSSEC standard relevant to the KeyTrap attacks.
500
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
Associating keys with signatures. A domain can use multiple records. For examples, see the the validation routines in Unbound8 .
different keys, see [RFC6840, §6.2]. This is required for instance In this work we show that these requirements are vulnerable. We
to support new stronger cryptographic ciphers but also to offer develop KeyTrap algorithmic complexity attacks that exploit the
weaker ciphers for other non-supporting resolvers, or to support specification weaknesses in the association process described above
stronger and weaker keys of same cipher, or during key rollover. to forge a DNSKEY set of cardinality 𝑘, conforming to a single key
In such a situation the DNS records are signed with all those tag 𝑡𝑘 , and to create a large number 𝑠 of invalid RRSIG records,
keys and the resolver receives the keys and signatures in a DNS which all reference these DNSKEYs. In consequence, the resolver
response. needs to check all 𝑠 signatures against all 𝑘 keys – a procedure with
To authenticate an RRset the RRSIG covering it needs to be asso- asymptotic complexity in O (𝑛 2 ).
ciated with the DNSKEY record carrying the corresponding public
key. This is done by matching the Signer’s Name in the RRSIG 5 Resource Exhaustion Attacks
record data field with the name of the DNSKEY record and the Our attacks consist of a module for sending queries to the target
algorithm fields. Additionally, the value of the Key Tag field in the resolver, malicious nameservers and the zonefiles that encode the
RRSIG must match the key tag value of the DNSKEY. Note that KeyTrap attack vectors. We exploit algorithmic complexity vulner-
the DNSKEY record data format does not specify a Key Tag field. abilities in standard requirements to develop different variants of
Instead, the key tag value is calculated by resolvers as an unsigned KeyTrap resource exhaustion attacks: KeySigTrap, SigJam, Lock-
16-bit integer sum over all two-octet words in the DNSKEY record Cram, and HashTrap. To initiate the attacks our adversary causes
data (ignoring carry and allowing overflow). As highlighted by the victim resolver to look up a record in its malicious domain. The
[RFC4034, §B], the key tag is not a unique identifier, but a mecha- attacker’s nameserver responds to the DNS queries with malicious
nism to efficiently identify a subset of DNSKEYs possibly matching record sets (RRsets), according to the specific attack vector and
the RRSIG to be validated. In consequence, to successfully authen- zone configuration.
ticate an RRset covered by an RRSIG, the resolver MUST try all
DNSKEYs in this subset until it succeeds to validate the signature 5.1 Threat Model
using one of the candidate public keys or runs out of keys to try
In our work we consider a low-resource attacker who is capable
[RFC4035, §5.3.1].
of hosting a DNSSEC-signed domain with a secure delegation and
Moreover, the DNSSEC key tag is not a crytographic fingerprint
who can attract a victim to resolve a name in this domain. Hosting
of the public key. Representing an unsigned integer sum over the
a signed domain with a secure delegation is a straightforward, field-
record data the key tag does not provide a cryptographic collision
proven administrative process: It can be achieved simply by renting
resistance. In §5 we develop an attack LockCram which exploits the
the domain, setting up the delegation as well as an open-source
requirement to associate keys with signatures.
authoritative DNS server, and configuring it with the zone files
Resolvers are endorsed to try all signatures. To support a
following the outline in this section. To attract the victim resolver
variety of domain-side key and algorithm roll-over schemes, as
the attacker can take various approaches, e.g., by embedding image
well as to increase robustness against cache-induced inconsisten-
URLs in HTML documents and distributing them via e-mail or ad
cies in the Internet-wide DNS state, resolvers must be tolerant in
network, or by sending bogus e-mail to an SMTP server configured
case individual signatures do not validate. Besides ignoring any
to deliver bounce messages [RFC5321]. The specific approach taken
RRSIGs, which do not match any authenticated DNSKEY, resolvers
is out of scope of this document. The resources required by the
are endorsed by specification (SHOULD) to try all RRSIGs covering
attacker are generally low. Specifically, the attacker does not require
an RRset until a valid one is found. Only if all signatures fail to
any potent hardware, since the attacks utilize only a limited number
authenticate the RRset should the resolver mark it invalid. When
of network transactions (the most potent one requiring only a single
multiple RRSIGs cover a given RRset, [RFC6840, §5.4] suggests that
attack packet). Fruthermore, the cryptographic material, which
a resolver SHOULD accept any valid RRSIG as sufficient, and only
the victim resolver will be busy validating, is invalid by design,
determine that an RRset is bogus if all RRSIGs fail validation.
rendering it computationally trivial to generate.
The explanation is that if a resolver adopts a more restrictive
policy, there is a danger that properly signed data might unnec-
5.2 DNSSEC Setup
essarily fail validation. . Furthermore, certain zone management
techniques, like the Double Signature Zone Signing Key Rollover The attack vectors are encoded in a zonefile in the domain controlled
method described in [RFC6781, §4.1.1], will not work reliably. by the adversary. For the attack to be effective, the adversary needs
Resolvers try to authenticate all DNSKEYs with all DS to register a domain under a signed parent.
hashes. The DNSSEC standard is not clear on the requirement of Zonefile. The attack vectors are encoded in the zonefiles in
DS hashes authentication. This vagueness left it for developers to Figure 1. In addition to the DNSSEC records, the zones also feature
decide how to implement the DS validation. We experimentally DNS records.
find that all the resolvers in our dataset validate all the DS hashes. Chain of trust. Although there is no explicit requirement in the
RFC-compliant resolvers are vulnerable. We find experimen- DNSSEC standard how validation of signed DNS records should
tally that all the resolvers in our dataset adhere to RFC specifications, proceed, the standard specification suggests that it should be done
validating all signatures with all DNSSEC keys they received from top down. The validator should construct the chain of trust top
the attack server and validate all DS hashes against all the DNSKEY 8 https://github.com/NLnetLabs/unbound/blob/master/validator/val_sigcrypt.c
lines 641 and 704.
501
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
502
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
all the matching ZSKs in the zone. In the example zone the resolver Name Vuln. Comment
Akamai CacheServe DoS 186s
thus tries to validate every signature with every ZSK, leading to BIND9 DoS 58632s
an immense amount of signature validations, until the resolver Knot Resolver DoS 51s (Limited DNS key
concludes that the DNS record could not be authenticated. buffer size)
PowerDNS Recursor DoS 177s
Unbound DoS 1014s (Retries increase du-
Server Software
ration)
Windows Server 2022 DoS 131s
Windows Server 2019 DoS 134s
unwind (from OpenBSD7.3) DoS 29s (Limited msg-buffer
5.6 HashTrap (Many Keys x Many Hashes) size)
Technitium DoS 411s
While mitigations may be introduced to limit signature validations, dnsmasq 2.80 DoS 2s (Limited msg-buffer
it is important to note that complexity attacks can also be achieved size)
stubby 0.4.3 DoS 184s
through hash computations. The concept of the attack, we dub Hash- Cloudflare Confirmed by Developers
Service
Trap, is illustrated in the example zone in Figure 1d. In DNSSEC, Google Confirmed by Developers
DS records from a parent zone are used to authenticate individual OpenDNS Confirmed by Developers
Quad9 Confirmed by Developers
DNSKEY records in a child zone. This is done to delegate trust from dig 9.16.1 # No DNSSEC validation
a parent zone public key to a child zone public key. DS records kdig 2.7.8 # No DNSSEC validation
delv 9.16.1 Validation logic from Bind9
use the same triple (owner name, algorithm, key tag) as RRSIGs
Tool
DNSViz 0.9.4 (latest) Crashes with exception after
do to identify a subset of candidate DNSKEYs. Only by validating attack
that the hash in the DS record matches the digest of the DNSKEY ldns-verify-zone uses vulnerable ldns library
kzonechek shipped with Knot DNS au-
can the resolver determine that a pair of DS and DNSKEY records thoritative server
actually belong together, which is an operation with worst-case named-checkzone # does not validate signatures
quadratic increase in validation complexity, similar to the algorithm dnspython -
Libs getdns used by stubby
exploited in 5.5. We construct a CPU resource consumption attack, ldns -
which abuses this DNSSEC protocol inefficiency. The attacker cre- libunbound used by Unbound
ates additional child zones of the attacker zone, represented as Table 1: Vulnerable DNS implementations.
sub-x.attack.er in Figure 1d. For each of these sub-zones, in step 1
the attacker provides numerous DS records referring to the same 6 Evaluation of the Attacks
key tag (5353), algorithm and signer name of the DNSKEYs in the
Through experimental evaluations we found all the major DNS
child. Our attacker utilizes unique digest values to ensure the DS
implementations on our dataset to be vulnerable to KeyTrap at-
records in the record set are not de-duplicated at the resolver. Since
tacks. The stalling interval caused by the attacks depends on the
these hashes are purposefully invalid, the attacker can select arbi-
specific resolver implementation. Our list of DNS software includes
trary values. The record set containing all the hashes is signed with
recursive DNS resolvers, public resolvers9 , DNS tooling, and DNS
a single signature by a ZSK of the attack.er zone.
libraries; see details in Table 1. We consider a resolver vulnerable
The resolver needs to authenticate the DNSKEY records before
if we achieve full DoS with traffic <10 req/s. All evaluations were
using the keys to validate the signatures [RFC4035]. Before authen-
conducted on an Intel Core i7-8650U quad-core processor with up
ticating the signature over the DNSKEY set the resolver first needs
to 4.2 GHz single core frequency. We describe the setup, our test
to find the DNSKEY that matches a DS record from attack.er. This is
methodology, and the cryptographic ciphers we use in our research
exploited in the attack. The attacker creates many unique DNSKEYs
zonefiles. We then evaluate the effectiveness and the impact of the
2 , all with the identical name, algorithm, and key tag (5353). To
attacks. An overview over the different DNS resolver components
find the correct key to validate with a given DS hash in the parent
relevant to the attack is given in Table 5. Note that Knot, unwind,
zone, the resolver has to iterate over all colliding keys, calculate the
and dnsmasq have tight response buffer size limitations, uninten-
hash and compare it to the hash in the DS record. This is repeated
tionally reducing the impact of the attack. In fact, this side effect
with all DS hashes in the parent zone and all DNSKEYs in the child
was recognized as a bug in Knot and fixed in the patched version
zone, which is an operation with worst-case asymptotic complexity
of the resolver 10 .
in O (𝑛 2 ), leading to a substantial amount of hash calculations that
mount severe computational load on the resolver. The resolver can 6.1 Setup
only conclude that none of the DNSKEYs can be used to authen-
ticate the signature 3 after all the hashes were calculated. Our Unless mentioned otherwise, all evaluations are run on a single
experimental evaluations show that, by means of exploiting of this CPU core. This allows us to compare between different resolvers
attack vector, hash computation is sufficiently resource intensive with various multi-threading standard configurations. We set up a
to inflict excessive load on a resolver. test environment with a number of components.
The HashTrap attack is thus constructed by leading the resolver Components. We set up resolvers and DNS servers in an iso-
to calculate many hashes for validating many colliding DNSKEYs lated environment. This ensures that attack requests are not prop-
against many DS hash records. Notice that attack variants, similar to agated to validating upstream DNS resolvers. We develop scripts
SigJam and LockCram, can also be constructed with the DS hashes 9 Tested against an instance set up by the operator for this purpose
10 https://github.com/CZ-NIC/knot-resolver/commit/
instead of signatures. However, hashes are less effective, reducing
adversary’s motivation to do that. 0b8012c2d68b7d59a55a0dca1d3f0c3042016ae9
503
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
Keys Signatures Validations different algorithm suites11 : RSA based and Elliptic Curve Cryp-
Cipher
tography (ECC) based cryptographic algorithms. We evaluate both
ED448 907 454 411 778
ED25519 1 391 696 968 136 suites and find that the ECC based cryptographic algorithms exhibit
ECDSAP384SHA384 589 519 305 691 a significantly higher load than RSA based algorithms and surpass
ECDSAP256SHA256 828 696 576 288
RSA-512 788 696 548 448 RSA by over an order of magnitude, even when considering RSA
RSA-1024 444 413 183 372 keys with the most inefficient selection of exponents allowed by the
RSA-2048 237 228 54 036
RSA-4096 122 119 14 518 DNSSEC specification. This is consistent with previous work [15].
Table 2: Max. DNSKEYs, RRSIGs, and validations per response. ECC-based algorithms are thus better suited to maximize the im-
pact of our attacks on resolvers. We therefore focus on ECC-based
for automated dynamic generation of zonefiles and records upon algorithms in the following evaluations of the attacks.
each query, and scripts for automated construction of the DNSSEC Comparison of computation load of ECC algorithms. We
chain of trust. Generating the zonefiles dynamically enables us to evaluate if validation of different ECC algorithms results in different
use a virtually infinite number of zones and records required for processing times on different DNS resolvers. For the evaluation,
testing the attacks, which would have otherwise quickly cluttered we set up all major DNS resolvers (see Table 3) on an identical
the zone files and hampered investigations. The nameservers host hardware machine. We evaluated all resolvers by running a full
the domains used for testing the resolvers and exchanges DNS resolution with 2500 validations. Times were average over 10 at-
messages with them according to protocol specifications and spe- tempts to ensure consistency. Measuring the validation time of the
cific test semantics. Each test is hosted in a separate subdomain message instead of only measuring the validation procedure allows
consisting of one or multiple zones. This prevents cache-induced a more accurate view of the behavior of the resolvers for different
interference between consecutive executions of tests and reduces algorithms, as overall processing times might also be influenced by
implementation complexity of the investigations. Test configura- components outside the validation procedure. The measurements
tions are pre-generated from configuration templates, which we illustrate different processing times between resolvers, indicating
define using a small domain-specific language. This allows efficient differing efficiencies of the implementation. Some efficiency diver-
variations over the signature algorithms or the specific number gence is expected, as a large amount of signature validations on a
of RRSIGs and DNSKEYs in responses, which are provisioned for single RRset is not an expected use-case for resolvers and thus, it
attacking validation routines. We conduct tests by sending queries is expected that resolvers are not optimized for it. This is clearly
to the resolvers, causing them to interact with our nameservers visible in the validation times of Bind9, which supersede the other
according to the test configurations. When a nameserver receives a resolvers due to an inefficient implementation of key selection in
query it parses it, matches it against a pre-defined set of rules and the case of colliding keys.
generates a response. The rule set is loaded from a configuration The table illustrates that all resolvers take the longest validation
file upon startup, and determines which tests can be conducted, as time for signature created with algorithm 14, which is ECDSA Curve
well as the specific test semantics. A "test" specifies, e.g., a set of P-384/SHA-384. Thus, algorithm 14 is the most suited for the attacks
domains with specific DNSSEC algorithms, numbers of DNSKEYs on all resolvers, achieving maximum impact with the available
and signatures over records to validate against these DNSKEYs. maximum buffer size. Using the 384bit key size of algorithm 14, and
Transport protocol. DNS responses are typically delivered over constructing the theoretical minimal size DNS message transporting
UDP. When DNS responses are too large, e.g., exceeding the EDNS the keys, an attacker could fit up to 589 colliding DNS keys into a
size in EDNS(0) OPT header, the nameservers fall back to TCP to single DNS message. Similarly, using minimal DNS overhead, an
avoid fragmentation. Our attacks can be implemented either over attacker could fit up to a maximum of 519 signatures into a single
UDP or TCP. We implement TCP as the transport protocol between DNS message. Thus, with one resolution request with algorithm 14,
the resolvers and our nameservers. The maximum size of a DNS an attacker could theoretically trigger 589*519 = 305691 signature
message sent over TCP is dictated by [RFC1035], stating that a validations in the DNS resolver, leading to significant processing
DNS message over TCP must have a length value prefixed to the effort on the resolver. Table 2 shows the theoretical maximum
message with 2-octets size. Resulting from the size limitation of values for all commonly supported DNSSEC algorithm. Theoretical
this field, DNS payload sent in a response from the nameserver maxima are calculated by choosing the minimal possible size for all
to the resolver can have a maximum size of 216 − 1 = 65535 bytes. fields in the DNS message. In practice, the exact value of signatures
Depending on the Maximal Transmission Unit (MTU), this payload and keys that can fit into a single message is limited by the attacker
will be sent in one or more TCP segments. Therefore, the attack setup. DNSSEC messages contain additional information besides
payload (i.e., DNS/DNSSEC records) in a DNS response is limited the raw bytes of the signature or key, like the signer name, leading
to 65K bytes. to the lower number of entries in real-world attack setup. In our
evaluation setup, we make a conservative approximation on the
6.2 Identifying the Optimal Cipher for Attacks practical size of the fields in the messages, using 582 DNSKEYs per
Different DNSSEC algorithms vary in the mathematical computa- message and 340 signatures per message.
tion logic and the complexity of mathematical operations. Therefore,
the computation of DNSSEC validation for different algorithms dif-
fers in the amount of computation time. This means that the load
created by our attacks is determined also by the cryptographic ci- 11 https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-
phers the adversarial domain uses. DNSSEC generally supports two alg-numbers.xhtml
504
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
Figure 2: KeySigTrap attack on Unbound with single request. Figure 4: HashTrap attack with two requests per second.
505
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
to SigJam, we do not see intermediate replies while the attack is requests. The requests are stored in the OS buffer, which eventually
running. The reason is that LockCram attack requires much lower fills, resulting in loss of subsequent inbound packets.
I/O effort than SigJam. In the first attack request of the evaluation, Note that packets may also get lost even if the buffer is not full.
the resolver needs to download and validate the RRSet containing all We find that PowerDNS discards old packets by default. When
colliding keys. In subsequent requests, the resolver already has the depleting the OS UDP buffer after the attack is over, PowerDNS
keys cached and only needs to download one signature. Thus, the discards any packets older than 2s. This means that during the
resolver spends much less time idling during the attack, preventing KeyTrap attack, any benign request arriving at PowerDNS earlier
it from answering benign requests while waiting for attack I/O. than 2s before the end of the attack does not get answered. If the
On average, a LockCram request is able to displace 815 benign OS buffer fills up more than 2s before the attack is over, the OS
requests, i.e. a LockCram request causes 815x load compared to drops the packets that PowerDNS would still answer to, resulting
benign requests. in PowerDNS not sending out any replies to benign requests after
HashTrap. We evaluate the HashTrap attack using digests of the attack is over.
type 2 (SHA256) as it requires the largest amount of time to compute
on a 64-bit system. Since the calculation time of the hashes does 6.5 Effect on Clients
not depend on the key size, we chose the smallest possible DNSSEC We also monitor the responses sent by the resolver to a benign DNS
keys, fitting as many keys as possible in one DNS message and client during the attack. The client continuously requests unique un-
thereby maximizing the number of hash calculations. The smallest cached records from the tested resolver and logs when it receives
key size of common DNSSEC algorithms is given by algorithm an answer. With this setup, we can evaluate if the resolver still
15, using 256-bit keys. Using 256-bit keys allows us to fit 1357 DS answers to benign requests while busy validating the signatures
records, and 1357 DNSKEYs in one attack request, resulting in 1357 from the attack request.
* 1357 = 1.841.449 hash calculations per request. The impact is illustrated in Figure 7. In Unbound as well as in
We start the evaluation with 1 attack request per second and all other resolvers we investigated, the resolver does not answer to
increase the rate until we observe no further increase in lost benign client requests while busy validating the signatures of the attacker
requests at 2 attack requests per second. As can be seen in Figure request. This can be seen in the graph, showing the amount of
4 the attack leads to 98% lost benign request. The 2% queries still answers the client receives over time. Once the attack request is
answered are again caused by I/O operations of the resolver, allow- sent at two seconds, the resolver stops answering to any benign
ing it to answer some benign queries. We find a greater impact on requests. Only after it finishes processing the attacker request, the
maximum throughput, with one HashTrap request displacing 1254 resolver again answers to benign queries at around 25s. The graph
benign requests. illustrates that the impact of the attack is severe, as it results in a
full DoS of the resolver while the attack is running.
6.4 Effect on Inbound/Pending DNS Packets
When resolvers are stalled from our attacks, they can neither pro- 6.6 Multi-Threading
cess pending requests nor respond to clients queries, even for Multi-threading is supported by all major DNS resolvers and in-
records that could otherwise be responded from the cache. We fluences how KeyTrap attacks affects their response behavior. To
find that a query that arrives during the time that a resolver is investigate the influence of multi-threading, we set up all resolvers
stalled is generally not discarded but is placed in a buffer for later with multi-threading enabled. Figure 6 illustrates the influence
processing. In normal operation, the resolver continuously reads of multi-threading on the attack. When using additional threads,
requests from the buffer and processes them, either by replying the resolver is still able to answer to some benign requests, even
from cache or with a recursive DNS resolution. During a KeyTrap while busy validating the signatures. Code review shows that the
attack, resolvers are stalled in validation and do not process new resolvers do not consider the load on a thread for scheduling, which
explains why approximately half of the requests are still scheduled
Name DoS Duration on a thread that is busy validating signatures. These requests are
Unbound 1014s lost. Answering benign requests while validating signatures ex-
Bind9 58632s
Knot 51s* tends the duration that the resolver takes to complete validation by
Akamai 186s a short amount, in the case of Unbound by about 20s. Note that due
PowerDNS 170s
Stubby 184s to inherent pseudo-randomness in the scheduling of requests to the
Table 4: DoS duration with single attack request.
threads, and the scheduling of different threads to run by the OS, a
*Knot has a limited buffer for DNSSEC keys (126 keys), allowing for a smaller attack small fluctuation of the percentage of lost requests can be observed
payload. in the graph. We observe similar fluctuations in all resolvers. We
506
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
Figure 6: KeyTrap attack on Unbound with 1 request and 2 threads. Figure 8: KeyTrap attack on Unbound with 5 requests and 5 threads.
find one resolver, Cacheserve by Akamai, that does not lose parts 6.7 Cached Entries
of its traffic when multi-threading is deployed. The reason is that it DNS resolvers implement a cache to answer recently requested en-
considers thread load in the allocation of new requests to worker tries without recursive resolution. This greatly improves efficiency
threads, leading to no lost benign requests while Cacheserve has of the resolver, as certain domains are requested more frequently,
open threads not busy validating attack signatures. like domains of commonly used websites. However, since all the
The attacker can circumvent the supposed protection from multi- resolvers, except CacheServe, handle replies to cached entries on
threading by sending multiple requests to the resolver. In the case of the same thread as recursive resolution and validation, caching does
Akamai, the scheduling algorithm that considers the load of threads not mitigate the attack. In contrast, since CacheServe implements
still allows the attacker to fill all threads with the attack. Since every a separate thread for answering cached entries, the effect of the
new attacker request will be scheduled to a free thread, the attacker attack is partially mitigated.
only needs to send as many attacker requests as there are threads
in Cacheserve. No request will be scheduled to an already busy 6.8 Continuous KeySigTrap Attack
thread. In contrast, for all other resolvers, the success of the attack Using the insights gained from the previous sections, we construct
is influenced by the pseudo-random scheduling algorithm. Since a continuous attack on resolvers. In the initial phase of the attack,
allocation of requests to threads is not known to the attacker, the the attacker sends multiple KeySigTrap requests simultaneously.
attacker needs to send more requests than there are threads in Sending multiple requests ensures that the resolver gets stalled for
victim resolver to ensure all threads are hit, even if the scheduling a substantial amount of time and, in the case of multi-threading, all
algorithm, by chance, schedules multiple attack requests to the same threads get hit with an attack and are busy validating signatures.
thread. In the case of fully random scheduling, the average amount The DNS implementations we tested in this work use 2-6 resolution
of attack requests needed to fill all victim threads can be calculated threads, depending on the resolver and the size of the deployment.
by 𝐸 = 𝑛 × 𝑛𝑖=1 1𝑖 where n is the number of threads in the resolver.
Í
Creating a real-world scenario, we thus evaluate our continuous
Since schedulers are usually optimized to distribute systematically attack on an Unbound instance running with 4 resolution threads.
to the threads, the real world average number of requests required The requests should be timed in such a way that new requests
to hit all threads will generally be lower than the random value. The are always already in the buffer once a request from the previous
effect of sending multiple queries can be seen in Figure 8. The graph batch finishes. Using the validation time of a single attack request
shows a scenario where the attacker sends five attacker requests to in Unbound, not considering re-tries, we find a single request ap-
an instance of Unbound running with five worker threads on five proximately stalls a thread for about 176s (see Table 4). We choose
CPU cores. As seen in the graph, the five requests do not suffice an interval half of this duration. We further send 12, three requests
to saturate the threads, as one threads remains active in replying per thread of the resolver, to ensure all validation threads are hit
to benign queries, leading to approximately 80% lost requests. The with the attack. The attack uses the following steps:
fact that two attacker requests were scheduled to the same thread
can be observed in the second half of the plot. While the validation 1. Send a batch of 12 initial attack requests
finishes in three threads, reducing the rate of lost requests by 60%, 2. Wait 1s to ensure the batch has been read
one thread continues validating signatures for almost twice as long, 3. Send batch of 12 follow-up request + buffer filler
4. Wait 90s
indicating that two requests were scheduled to a single thread.
5. Go back to 3.
These observations show that multi-threading is no sufficient
protection against the attack, as the attacker, when sending a suffi- The result of this attack is plotted in Figure 9. The attack achieves
cient amount of attack requests, can hit all threads of the resolver, a complete DoS of the resolver for the entire 2h measurement
leading to a comprehensive DoS of the resolver. It also illustrates duration, with 99.999% of benign requests lost. All 4 processor
that one attack request is not sufficient for a complete DoS of the cores continuously run on 100% CPU utilization, validating the
resolver when multi-threading is used. signatures. The attacker only requires traffic of 13 request per 90s,
i.e., on average one request every 6.9s. This attack rate is low enough
to prevent any rate-limiting mechanisms from blocking follow up
attacker requests in a real-world setting.
This evaluation demonstrates that KeySigTrap is a practical at-
tack, achieving a continuous DoS even on a multi-threaded resolver.
Even a small-scale attacker can exploit KeySigTrap to fully stall
DNS resolution in the resolver for other clients for an indefinite
Figure 7: Impact on benign requests in Unbound under attack. amount of time.
507
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
Figure 9: Continuous KeyTrap attack on 4-threaded Unbound. Figure 11: HashTrap attack on patched Bind9 with 10req/s.
508
The Harder You Try, The Harder You Fail:
The KeyTrap Denial-of-Service Algorithmic Complexity Attacks on DNSSEC CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA
Figure 12: ANY-type derivation of SigJam on Akamai. Figure 13: ANY type attack with 10req/s on patched Akamai.
tags. We find that limiting key tag collisions to 4 will not impact load. Notice however that we are still closely working with the
normal operation of the resolver. Using data from the Tranco Top1M developers on testing the patches and their performance during
domains, we find experimentally that only two zones have colliding attack and during normal operation.
DNSKEYS, with no zone using more than two colliding keys.
Limiting key tag collisions proved successful in protecting against
7.2 Improving Resilience of Architecture
HashTrap. The combination of both patches was nevertheless still
vulnerable to a variant of the SigJam attack (§5.3). The attack works To understand the impact of the attacks on various DNS function-
with a single DNSSEC key and many signatures, but requires no ality, including caching, pending DNS requests or inbound DNS
signature validation failures, thereby circumventing the protection packets from the clients as well as from the nameservers, we per-
offered by the patch. We use ANY type responses, which contain form code analysis and evaluations. Our observations from the
many different record sets, each signed with a different signature. analyses can be used to enhance the robustness to failures and
We can create arbitrary numbers of different record sets, so that on attacks of implementations:
the one hand the number of signatures is maximized, and on the Multi-threading. Using code analysis and experimental eval-
other hand, the response still fits into one DNS packet. We vary uation of the multi-threading architecture of the DNS implemen-
over the type number field on an A-type record to create a large tations, we find that load of processes is generally not considered
number of small, unallocated-type record sets, each covered by an in scheduling new DNS requests, leading to substantial loss of re-
individual, valid signature. In our tests with standard DNS software, quests even if not all threads of a resolver are busy. Further, we
we created DNS responses with 313 different record sets. Following find resolvers do not consider the computational effort of a given
[RFC6840, §4.2] the resolver MUST validate the signatures on all request, leading to loss of benign requests, if a single request creates
the record sets. Since all signatures are valid, the resolver does a large load on the resolver. We contribute the architectural recom-
not fail from the imposed limit on validation failures and instead mendation that resolvers should de-prioritize DNS requests that
continues the validation until all signatures on the unallocated-type cause substantial computational load, allowing the resolver to still
records have been checked. We found this attack to be effective answer benign clients even under attacks. This de-prioritization
against all patches that limit cryptographic failures. The success of is in line with previous work recommendations on mitigations of
the attack on a patched Akamai is illustrated in Figure 12. In the complexity attacks, like presented by Atre et al. [3].
evaluation, the attacker sends 4 ANY type requests per second, a OS buffers. We find that the resolvers generally only deplete
rate at which the attacker is able to completely DoS the resolver the OS UDP buffer after a batch of tasks has been finished. This
after a few seconds. Running the attack for 60s, we were able to causes the buffer to fill up when the resolver is busy, leading to
achieve over 90% lost benign queries. The attack can thus DoS the lost benign requests. We recommend to adapt the architecture of
resolver, circumventing the patch. The attack that exploits ANY resolvers to allocate a separate thread for reading from the OS buffer
type records illustrates that limiting only the cryptographic failures and placing pending requests in a dynamic internal buffer.
is not a sufficient mitigation against the complexity attacks. Thread for cached records. Further, since many benign queries
Limiting all validations. The first working patch capable of by users can be answered from cache, additionally allocating a
protecting against all variants of our attack was implemented by separate thread for answering to cached entries can reduce the
Akamai. Additionally to limiting key collisions to 4, and limiting impact of stalling of resolution threads.
cryptographic failures to 16, the patch also limits total validations
in ANY requests to 8. Evaluating the efficacy of the patch, we find 7.3 Implementation Challenges
the patched resolver does not lose any benign request even under The experience we made working with the developers on designing
attack with > 10 requests per second. Illustrated in Figure 13, the and evaluating the patches showed that the vulnerabilities we found
load on the resolver does not increase to problematic levels under were challenging to patch. We not only showed that patches could
the ANY type attack with 10 req/s, and the resolver does not lose any be circumvented with different variants of our attack, but also dis-
benign traffic. It thus appears that the patch successfully protects covered problems in the implementations themselves. We provide
against all variations of KeyTrap attacks. Nevertheless, although here examples from two major implementations: Knot and Bind9.
these patches prevent packet loss, they still do not fully mitigate During the evaluations we found that a patch for Knot, that was
the increase in CPU instruction load during the attack. The reason supposed to limit requests to 32 failed validations per resolution,
that the mitigations do not fully prevent the effects of the KeyTrap was not working as intended. While the patch reduced the number
attacks is rooted in the design philosophy of DNSSEC. For example, of validations resulting from a single attacker request, it did not
we find that in a patched Unbound, an attacker request can still sufficiently protect against an attacker sending multiple requests
displace the processing equivalent of 8 benign requests under full in a short time frame. With 10 attacker requests per second, the
509
CCS ’24, October 14–18, 2024, Salt Lake City, UT, USA Elias Heftrig, Haya Schulmann, Niklas Vogel, and Michael Waidner
Acknowledgements
This work has been co-funded by the German Federal Ministry of
Education and Research and the Hessen State Ministry for Higher
Education, Research and Arts within their joint support of the
National Research Center for Applied Cybersecurity ATHENE and
Figure 14: KeyTrap against patched Knot. by the Deutsche Forschungsgemeinschaft (DFG, German Research
Foundation) SFB 1119.
14 https://stats.labs.apnic.net/dnssec/XA
510