[DNS Fundamentals Part 9] DNS Security: Cache Poisoning, DNSSEC, Encrypted DNS, and Operational Gaps

DNS Fundamentals Part 9 DNS Security: Cache Poisoning, DNSSEC, Encrypted DNS, and Operational Gaps DNS

“Do I have to enable DNSSEC?”
“Is it OK to let browsers use DoH inside our company network?”

DNS sits at the entrance of almost every connection, so it is an attractive target for attackers. At the same time, most DNS incidents are not sophisticated attacks. They come from operational gaps such as records nobody remembered to delete, or domains nobody remembered to renew.

In Part 8 we looked at the commands for investigating DNS. In Part 9 we sort out the attacks aimed at DNS and how to defend against them. This part also covers DNSSEC in detail, which was behind the SERVFAIL you saw in Part 8.

▶ This part is also available as a YouTube video (about 22 min) (it is also embedded at the end of this article).


The threat landscape

Let’s start with a list of the threats related to DNS.

Diagram showing where each threat occurs among the device, caching DNS, authoritative DNS, registrar, and attacker: poisoning, eavesdropping and tampering, reflection, random subdomain attacks, tunneling, takeover, expiry, and malicious domains
ThreatWhat is targetedWhat happensMain defenses
Cache poisoningCaching DNSA fake response is remembered and users are sent to a fake sitePort randomization, DNSSEC validation
Eavesdropping and tamperingBetween the device and the caching DNSWhere users browse is leaked, or responses are rewrittenDoT / DoH / DoQ
Reflection attackOpen resolvers, authoritative DNSA flood of responses is sent to a third partyRestrict recursion, RRL
Random subdomain attackAuthoritative DNS, caching DNSOverload from floods of queries for nonexistent namesQuery rate limits, monitoring
DNS tunnelingInternal caching DNSData is carried out inside queriesLog monitoring, DNS firewall
Subdomain takeoverCNAMEs and similar records in your own zoneSomeone else publishes a site under your nameDelete unneeded records, regular inventory
Domain expiry or hijackingRegistrar, NSThe whole domain falls under someone else’s controlAuto-renewal, registrar lock, MFA
Access to malicious domainsUsers’ devicesMalware infection, phishingProtective DNS, RPZ

The top three are attacks on the DNS mechanism itself, and the bottom five are operational gaps and abuse of DNS. Many of the latter can be prevented with configuration and regular inventory, which makes them part of day-to-day operations.


Cache poisoning and the Kaminsky attack

Cache poisoning is an attack that makes a caching DNS server remember a fake response.

Diagram showing an attacker flooding fake responses that pretend to be from the authoritative DNS while guessing the ID and port, the fake data being cached for the TTL if it is accepted before the real one, and how the Kaminsky attack made queries for nonexistent names one after another to take over the NS records

Between the moment the caching DNS sends a query to an authoritative DNS server and the moment the real response arrives, the attacker sends a fake response that pretends to come from the authoritative DNS. If it is accepted first, the fake data is cached for the TTL, and all users are sent to the fake site. To be accepted, the response must match the query on things like the query ID (16 bits).

In the past, opportunities were limited because “a name that is already cached cannot be targeted.” But the Kaminsky attack, published in 2008, was different.

  • It made the resolver query nonexistent names one after another (a001.example.com, a002.example.com…), so the attacker could try as many times as needed
  • It included NS records in the fake response to take over the whole domain

Because this was a weakness in the DNS specification itself, all the major products released fixed versions at the same time.


Defenses against cache poisoning

Diagram showing the defenses that make guessing harder: 16 bits for the ID, about 16 bits for the source port, and bits for each letter of the name with 0x20; that a NAT on the path rewriting ports removes those bits; and that DNSSEC, which verifies the content by signature, is not a guessing problem
  • Source port randomization: Use a random source port every time, which together with the ID (16 bits) makes guessing harder. This was the core of the 2008 fixes, and current products do it by default. However, if a NAT or firewall on the path rewrites ports sequentially, the effect is lost
  • 0x20: Randomly mix upper and lower case in the queried name (wWw.ExAmPle.cOm) and check that the response has the same pattern. Some resolvers implement it
  • Do not accept unrelated records: Do not cache information about domains unrelated to the query
  • Countering SAD DNS (2020): A technique that finds the port by using the OS’s ICMP response rate limit as a clue. It has been addressed by OS and resolver fixes, so keep the OS up to date as well
  • DNS Cookies (RFC 7873): Make spoofed responses easier to spot (Part 4)

But all of these make guessing harder and only lower the odds. Only DNSSEC can confirm that the content of a response is genuine.


How DNSSEC works

DNSSEC (DNS Security Extensions) adds digital signatures to responses so that the receiver can confirm they have not been tampered with. It does not encrypt anything.

RecordWhere it livesRole
DNSKEYSigned zoneThe zone’s public keys: the KSK (key-signing key, flag 257) and the ZSK (zone-signing key, flag 256)
RRSIGSigned zoneA signature for each set of records with the same name and type (an RRset). Has a validity period
DSParent zoneA hash of the child’s KSK. Hands trust from parent to child
NSECSigned zoneProof that “this name or type does not exist.” Points to the next name
NSEC3Signed zoneHashes the names used in NSEC so the names in a zone are harder to enumerate
CDS / CDNSKEYChild zoneLets the child publish the DS it wants registered in the parent
Diagram showing that the DS in the parent zone com matches the KSK of example.com, that the KSK signs the DNSKEY set and the ZSK signs the A set for www.example.com, and that NSEC proves that after a comes www and nothing exists in between

The signatures link upward: data → ZSK → KSK → the parent’s DS.

www.example.com. 300 IN RRSIG A 13 3 300 20261009000000 20260925000000 12345 example.com. (signature)

Read from the left, an RRSIG gives the type covered, the algorithm, the label count, the original TTL, the expiration, the inception time, the key tag, and the signer. Once it expires, validation fails, so automatic re-signing is essential.


The chain of trust and validation

A validating resolver (validator) comes with the root zone’s KSK as a trust anchor from the start.

Diagram showing the chain from the trust anchor (the root KSK) through the DNSKEY of ., the DS for com, the DNSKEY of com, the DS for example.com, and the DNSKEY of example.com to the A record plus RRSIG for www.example.com, with SERVFAIL if the chain breaks and the AD bit if it holds all the way

The resolver verifies the root DNSKEY with this anchor, then the DS for com that the root signed, then the DNSKEY of com that matches it, and so on, walking from parent to child, and finally verifies the RRSIG of www.example.com. This is the chain of trust.

  • If there is an expired signature or a mismatch between a DS and a key somewhere along the way, the response is judged “possibly fake.” Returning it would defeat the purpose of DNSSEC, so the resolver returns no answer and sends SERVFAIL
  • When validation succeeds, the response gets the AD bit, and a client that sets the CD bit can receive the result with validation turned off (+cd in Part 8)
  • A zone with no DS in its parent is treated as “unsigned” and resolves as usual

The validating resolver checks the RRSIG expiration and inception times against its own clock. If the resolver’s clock is badly off, even a correctly signed zone is judged expired (or not yet valid) and returns SERVFAIL. The same kind of clock skew also breaks certificate validation, so keep the resolver’s time synchronized (for example, with NTP).


Algorithms and key management

ItemCurrent recommendation and trends
Algorithm 13 (ECDSA P-256)Mandatory to implement for both signing and validation. Small signatures; the first choice for new signing
Algorithm 15 (Ed25519)Recommended. Small signatures, but check validator support before using it
Algorithm 8 (RSA/SHA-256)Still usable. Used by the root and many TLDs. Larger responses
Algorithms 5 and 7 (RSA/SHA-1)Deprecated for signing by RFC 9905 (2025). Some OSes have stopped validating SHA-1
KSK and ZSKThe KSK signs the DNSKEY set and connects to the parent through the DS. The ZSK signs the zone’s data
Key rolloverA ZSK rollover needs no parent procedure. A KSK rollover requires replacing the DS in the parent and is where incidents are most likely
CDS / CDNSKEYThe parent checks the values the child published and updates the DS automatically (RFC 7344 and 8078; support depends on the registry)
KeyTrap (2024)A DoS that inflates validation work with crafted keys and signatures. Fixed in each product; apply updates

The most incident-prone operation is the KSK rollover.

Diagram showing four steps (add the new KSK to DNSKEY, publish CDS so the parent adds the new DS, wait for the parent DS TTL, then remove the old KSK and old DS) and that skipping step 2 breaks the chain of trust so that the whole domain returns SERVFAIL
  1. Add the new KSK to the DNSKEY set
  2. Publish CDS → the parent adds the DS (sometimes by hand)
  3. Wait for the parent DS’s TTL
  4. Remove the old KSK and the old DS

If you skip step 2 and do step 4, the parent has only the old DS while the child has only the new KSK, so the chain of trust breaks and the whole domain returns SERVFAIL to validating resolvers (EDE 9 in Part 8). The golden rule is to always keep a period where the old and new keys and DS overlap. Also, algorithm recommendations have been managed in an IANA registry since RFC 9904 (2025).


Root KSK rollover (KSK-2024)

The root KSK, the starting point of DNSSEC, is also being rolled over.

Timeline showing KSK-2024 (key tag 38696) generated in April 2024, published in January 2025, the root signing switched to KSK-2024 on October 11, 2026, and KSK-2017 (key tag 20326) revoked and removed in January to March 2027
WhenWhat
April 2024The new KSK (KSK-2024, key tag 38696) is generated
January 2025KSK-2024 is published in the root zone alongside the current KSK-2017 (key tag 20326)
October 11, 2026The root signing switches to KSK-2024
January to March 2027 (planned)KSK-2017 is revoked and removed from the root zone

When this article was written, on September 25, 2026, the root DNSKEY set contained both 20326 and 38696, and signing was done with 20326. After the switch, a validating resolver that does not trust 38696 returns SERVFAIL for every name.

Check whether your validating resolvers have 38696 in their trust anchors:

  • BIND: rndc managed-keys status
  • Unbound: the root.key file
  • Knot Resolver: root.keys
  • Windows Server DNS: Get-DnsServerTrustAnchor -Name .

Many resolvers automatically pick up the new key using the RFC 5011 procedure (they trust a new key after observing it for 30 days). However, if the key store is not writable, or the resolver was started from a VM or image that was stopped for a long time, the key may not have been picked up. Devices that do not use automatic updates must be updated by hand using the trust anchors published by IANA (root-anchors). You can check the current state with dig . DNSKEY +multi (in PowerShell, Resolve-DnsName . -Type DNSKEY).


Reflection attacks and open resolvers

A reflection attack is a DDoS attack that sends floods of small queries with the source IP address forged to be the victim’s to DNS servers, so that the responses go to the victim.

Diagram showing an attacker sending 60-byte queries with a forged source of the victim to several open resolvers, about 50 times larger 3,000-byte responses reaching the victim once per reflector, and the defenses: caching DNS allows recursion only from inside and authoritative DNS uses RRL

Because responses are much larger than queries, the attack volume is amplified dozens of times. Even if the attacker’s line is thin, amplification times the number of reflectors floods the victim.

  • The most common reflectors are open resolvers, which accept recursive queries from anyone. A caching DNS should accept recursion only from inside your organization, and in the cloud should also restrict the source with security groups
  • An authoritative DNS has to answer anyone, so it uses RRL (response rate limiting), which stops it from repeating the same response many times in a short period
  • Queries of type ANY, which return everything, were abused for amplification, so RFC 8482 (2019) allows servers to answer them minimally. You cannot get all the records with dig ANY

This is one of the reasons Part 7 said not to combine authoritative and caching roles on one server.


Random subdomain attacks and DNS tunneling

Diagram showing a random subdomain attack in which a botnet queries floods of nonexistent names such as abc12.example.com to bypass the cache and overload the authoritative DNS, and DNS tunneling in which an infected device embeds data in names sent to the attacker's authoritative DNS and receives instructions in TXT responses
Random subdomain attack (water torture attack)DNS tunneling
MethodQuery floods of nonexistent names such as x7q2k.example.com. The cache is no help, so every query reaches the authoritative DNSEmbed the data to send in a name, and receive data in the response (TXT, etc.)
GoalOverload the authoritative DNS and the caching DNS on the wayGet data out past the firewall, or remotely control malware
SignsA spike of NXDOMAIN for a specific domain, growing waits for responsesLong random names, many queries to a single domain, heavy use of TXT
DefensesQuery rate limits on the resolver, more capacity and anycast for the authoritative DNSMonitor query logs, DNS firewall, forbid direct port 53 traffic to the outside

Both blend in with normal queries when you look at them one at a time, so keeping query logs and knowing your normal volume is the prerequisite for detection. In zones signed with DNSSEC, the mechanism that uses NSEC to answer nonexistent names from the cache (RFC 8198) helps reduce the load.


Subdomain takeover

From here on, we look at “operational gaps.” Subdomain takeover is a problem where someone else can use your subdomain because a DNS record you no longer needed was left behind.

Diagram showing that normally shop.example.com points through a CNAME to your own resource, but if you delete only the resource the CNAME dangles, and when an attacker claims the same name a fake page is shown

A typical sequence looks like this:

  1. shop.example.com pointed through a CNAME to a cloud service’s name (for example, shop-prod.service.example)
  2. You deleted only the resource on the service side and left the CNAME in place
  3. An attacker claims the same name on the service and can publish a fake page at shop.example.com

Because the page appears on your own domain, it can be abused for phishing and cookie theft, and an attacker can even obtain a certificate. The same applies to an A record that points to a released IP address, and to an NS record that points to a deleted zone.

The defenses are to follow the order delete the DNS record before you delete the resource, and to inventory where records point on a regular basis. DNS records are not removed automatically when you delete the resource.


Domain expiry and hijacking

Diagram showing the stages of expiry from a missed renewal by the registrant, registrar account takeover, transfer or NS change at the registry, and expiry of the domain used for NS, together with defenses such as auto-renewal, MFA, registrar lock, and cleaning up old delegations
  • Expiry from a missed renewal: An expired domain can be registered by a third party, and the website, incoming email, and past links all become someone else’s. Prevent it with auto-renewal, multiple billing and notification contacts, and a ledger of expiration dates
  • Expiry of another company’s domain used for NS: If a domain such as ns1.old-provider.example used for NS expires, whoever registers it can decide the zone’s responses freely. Do not leave unused delegations or old NS records in place
  • Cancelled DNS service at the delegated destination: If NS still points to a DNS service whose contract has ended, someone else may be able to create the same zone on that service. Large-scale abuse of this technique was reported in 2024 as well
  • Registrar account takeover: If NS can be rewritten, the whole domain is taken. Set up multi-factor authentication (MFA), limited access, and change notifications
  • Registrar lock and registry lock: Locks that block transfers and NS changes. For important domains, also consider a registry lock, which adds human confirmation to changes

To check the status, use WHOIS or RDAP to look at the expiration date and lock status (clientTransferProhibited, etc.) (Part 2). Whichever stage is taken over, the whole domain falls under someone else’s control.


Encrypting DNS (DoT, DoH, DoQ)

MethodStandardTransportCharacteristics
DoT (DNS over TLS)RFC 7858 (2016)TLS, TCP 853Easy to tell apart by its dedicated port and easy to control with a firewall
DoH (DNS over HTTPS)RFC 8484 (2018)HTTPS, TCP 443 (UDP for HTTP/3)Blends in with web traffic. Browsers led the way in implementing it
DoQ (DNS over QUIC)RFC 9250 (2022)QUIC, UDP 853Fast connections and less affected by retransmission delays. Support is still spreading
DDR (Discovery of Designated Resolvers)RFC 9462 (2023)SVCB for _dns.resolver.arpaAutomatically discovers whether the configured DNS server supports encryption
Diagram contrasting that the path between the device and the caching DNS is encrypted with DoT, DoH, and DoQ to stop eavesdropping, while the path between the caching DNS and the authoritative DNS is mostly still plaintext, and that DNSSEC verifies that what the authoritative DNS published is genuine

Encryption mainly protects the path between the device and the caching DNS, and the path between the caching DNS and the authoritative DNS is mostly still plaintext. Encryption also prevents eavesdropping and tampering in transit, but it does not verify that what the authoritative DNS published is correct. That is DNSSEC’s job.

This is the answer to the opening question, “Do I have to enable DNSSEC?” Encryption protects the path and DNSSEC protects the content. Neither one alone is enough, and they complement each other.

DoT and DoH rely on the same TLS mechanism (the handshake and the server certificate) that secures HTTPS.


OS and browser support, and bypassing internal DNS

TargetSupport for encrypted DNSEnterprise control
Windows 11, Windows Server 2022 and laterThe DNS client supports DoH (add the server to the list of known servers to use it)Group Policy “Configure DNS over HTTPS (DoH) name resolution”
Windows Server 2025 DNS serverSince the June 2026 update (KB5094125), it can accept DoH from clientsTraffic to forwarders and zone transfers are not encrypted
macOS 11 and laterDoH and DoT through configuration profiles. macOS 13 and later also support DDRDistribute profiles with MDM (device management)
Chrome and Edge“Secure DNS.” Switches automatically if the OS’s DNS server supports DoHThe DnsOverHttpsMode policy (off / automatic / secure). On managed devices, DoH is not used if the policy is unset
FirefoxDoH by default in the US, Canada, and some other countriesThe DNSOverHTTPS policy, canary domain
Diagram showing that when a browser on the internal network uses an external DoH server directly on port 443, it bypasses the internal DNS filters and logs, internal names cannot be resolved, and split horizon stops working, and that this is controlled with policy and use-application-dns.net

This is the other question from the beginning. If a browser uses an external DoH server directly, it bypasses your internal DNS, and the following problems occur:

  • Internal names cannot be resolved
  • Split horizon does not work
  • Filters and logs are bypassed

DoH uses port 443, the same as the web, so it is hard to stop by port. Control it with device settings instead. Set it explicitly by policy, and for Firefox, return NXDOMAIN for use-application-dns.net (this works only when DoH is enabled by default).


Protective DNS, RPZ, and DNS firewalls

Finally, let’s look at using DNS as a “defensive tool.” Because DNS is used at the start of almost every connection, you can stop connections to malicious domains right there.

Diagram showing that when a device looks up malware.example, the caching DNS with RPZ returns NXDOMAIN or the IP of a block page to stop the connection, that query logs help find infected devices, and that DoH and direct port 53 or 853 traffic to the outside pass through and must be restricted at the egress firewall
  • Protective DNS: A caching DNS service that answers queries for domains known as malware distribution sources, phishing sites, or command-and-control servers with NXDOMAIN or the IP address of a block page
  • RPZ (Response Policy Zone): A mechanism for doing the same thing on your own caching DNS. You write the names to block and the action to take as a zone and distribute it by zone transfer. BIND, Unbound, and others support it
  • DNS firewall: The form in which this is offered in the cloud (Route 53 Resolver DNS Firewall, Part 10)

Because it stops at the name lookup, the connection never even starts. Query logs can also help you find infected devices. However, DoH and direct connections pass through, so combine this with restrictions on outbound traffic to ports 53 and 853.


Think about it

  1. How can you check whether your organization’s validating caching DNS has kept up with the root KSK rollover? What would happen if it had not?
  2. You are going to delete a test cloud environment. What do you check on the DNS side before and after the deletion?
  3. You find that browsers on internal devices are using an external DoH server. What problems does this cause, and how do you control it?

Hint: “Root KSK rollover,” “Subdomain takeover,” and “Bypassing internal DNS” in this article lead to the answers.


Summary

  • Defenses that make guessing harder only lower the odds. Only DNSSEC can confirm that the content is genuine
  • DNSSEC walks from the root KSK, parent to child. If the chain breaks, you get SERVFAIL
  • In a KSK rollover, overlap the old and new keys and DS. The root KSK switches to KSK-2024 on October 11, 2026
  • A caching DNS allows recursion only from inside. An authoritative DNS uses RRL
  • Forgotten CNAMEs and domains nobody renewed are each enough to open the door to a takeover
  • Encryption protects the path; DNSSEC protects the content. Control browser DoH by policy

Next time, we look at how DNS is used in the cloud and on corporate networks, including Route 53, AD-integrated DNS, and Kubernetes.


Watch the video

This part is also explained in a YouTube video (about 22 min).

All parts of the series are in the DNS Fundamentals playlist on YouTube.

The DNS Fundamentals series (12 parts)

All 12 parts with a reading guide: DNS Fundamentals

  1. What Is DNS? How Name Resolution Works and Its Three Key Players
  2. The domain name hierarchy and delegation
  3. How name resolution works
  4. DNS messages and transport
  5. Resource records, part 1
  6. Resource records, part 2
  7. Running authoritative DNS servers
  8. Investigating with commands
  9. DNS security (this article)
  10. DNS in the cloud and on corporate networks
  11. DNS troubleshooting
  12. DNS design exercises

This series is the English edition of 【DNS入門】, originally written in Japanese.

コメント

Copied title and URL