SECURITY ENGINEERING · PART 2 · NETWORKING FOR SECURITY · ATTACKS · 24 OF 229

DNS Spoofing, Cache Poisoning and DNSSEC

DNS decides where every connection goes, so attackers aim at it: spoofed answers on the local network, cache poisoning at the resolver, hijacking the domain at the registrar, subdomain takeover through dangling records, and data smuggled out in DNS queries. Then the defenses: DNSSEC, encrypted DNS, registrar locks and DNS monitoring.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 12

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Spoofing
  • cache poisoning
  • registrar hijack
  • subdomain takeover
  • tunneling
  • DNSSEC, encrypted DNS, locked accounts

Notes

DNS in one picture

A quick picture of DNS. Your browser asks a resolver, usually run by your network or a public provider. The resolver walks down from the root servers to the top-level domain to the domain's own authoritative server, gets the answer, and caches it for a time set by the record. In classic DNS all of this travels as plain text, mostly over UDP, with no signature. An answer is accepted if it looks like it matches the question.

How a lookup works
  • browser asks a resolver
  • the resolver asks the root, the TLD, then the domain's authoritative server
  • the answer is cached for its TTL
  • classic DNS: plain text, UDP, no signature on the answer

Attack 1 · Spoofing

The first attack is local spoofing. An attacker who is already in the middle, through ARP spoofing or a fake access point, sees your DNS question and simply answers it first, with their own server's address. Your browser connects there. The name in the address bar is still the right one, which is what makes this dangerous. Only the certificate check stands between the user and a perfect copy of the real site.

Local DNS spoofing
  • the attacker is already in the middle (last episode)
  • they see the question and reply before the real server
  • the browser gets the attacker's address
  • the name in the address bar is still correct

Attack 2 · Poisoning

The second attack scales that up. In cache poisoning the attacker targets the resolver itself, racing to answer the resolver's question before the real authoritative server does. If a forged answer is accepted, the resolver caches it, and every user of that resolver is sent to the wrong address until the record expires. A famous flaw found in two thousand eight made this practical; randomised source ports and query identifiers made the race far harder, but not impossible.

Cache poisoning
  • the attacker races to answer the resolver's own question
  • if a forged answer is accepted it is cached
  • every user of that resolver gets the bad address until the TTL expires
  • randomised ports and IDs made the race much harder

Attack 3 · Hijack

The third attack skips protocol tricks entirely. The attacker takes over the company's account at its registrar or DNS provider, with a phished or reused password, and changes the real records. Now the genuine, authoritative answer points to the attacker, for everyone in the world. With control of the domain they can even obtain a valid certificate, so there is no browser warning at all. This has happened to banks and to cryptocurrency sites.

Registrar or DNS account hijack
  • the attacker phishes or guesses the registrar or DNS account
  • changes the name servers or the records themselves
  • now the *real* answer points to them, worldwide
  • they can even get a valid certificate for the domain

Attack 4 · Takeover

The fourth attack is the one teams cause themselves. A subdomain is pointed at a cloud service, such as a storage bucket or a hosted app. Later the team deletes the cloud resource and forgets the DNS record. That record is now dangling. An attacker claims the same resource name at the cloud provider, and is suddenly serving their content on your subdomain, with your cookies in reach. The fix is process: delete the record with the resource, and audit your DNS regularly.

Subdomain takeover
  • promo.shop.example CNAME points to a cloud service
  • the team deletes the cloud resource, forgets the record
  • an attacker registers the same resource name
  • they now serve content on your subdomain
  • fix: delete DNS with the resource; audit records

DNS as a tunnel

DNS is also abused as a carrier. Almost every network lets DNS out, so malware encodes stolen data inside the names of DNS queries and sends them to a server the attacker controls. That is DNS tunneling, used for command and control and for theft. The signs are long, random-looking subdomains and unusual query volume. Attackers also register look-alike domains, one letter off, for phishing. Both are found by watching DNS logs, which most companies never read.

Abusing DNS itself
  • DNS tunneling: data encoded in query names, sent to the attacker's DNS server
  • used for command and control and data theft
  • typosquatting: shopexample.co look-alike domains
  • signs: long random subdomains, huge query volume

Defense · DNSSEC

Now the defenses. DNSSEC adds signatures. The domain signs its records with a private key, and resolvers verify each signature up a chain of trust that ends at the root. A forged answer has no valid signature and is rejected, which defeats spoofing and cache poisoning. Know its limits, because interviews ask. DNSSEC proves an answer is authentic. It does not encrypt the lookup, and it does not help if the attacker controls your registrar account.

DNSSEC
  • the zone signs its records with a private key
  • resolvers verify the signature up a chain of trust to the root
  • a forged answer has no valid signature: rejected
  • proves authenticity, does not encrypt, does not stop a registrar hijack

More defenses

The rest of the kit. DNS over HTTPS or DNS over TLS encrypts the lookup, so nobody on the path can read or change it. Protect the registrar and DNS provider accounts like crown jewels: multi-factor login, a registry lock, very few administrators, and alerts on every change. Publish CAA records to limit which certificate authorities may issue for your domain, and watch certificate transparency logs for certificates you did not request. And log DNS queries, then actually review them.

The rest of the kit
  • DNS over HTTPS or TLS: nobody on the path can read or change the lookup
  • registrar: MFA, registry lock, few admins, alerts on change
  • CAA records: which CAs may issue for your domain
  • monitor certificate logs
  • log and review DNS queries

Common mistakes

Mistakes. A registrar account with a shared password and no multi-factor login, when it controls the whole company's traffic. Dangling records left behind when cloud resources are deleted. A DNS zone that no team owns, full of entries nobody can explain. No DNS logs and no review. Believing DNSSEC encrypts anything. And never looking at certificate transparency logs, where a hijack often shows up first.

Avoid these
  • registrar login with a shared password and no MFA
  • dangling records after deleting cloud resources
  • nobody owns the DNS zone
  • no DNS logs, no review
  • thinking DNSSEC encrypts
  • ignoring certificate logs

Say it like this

In the interview: DNS can be attacked with spoofed answers on the local network, cache poisoning at the resolver, hijacking the registrar account, subdomain takeover through dangling records, and tunneling for data theft. I defend it with DNSSEC and encrypted DNS, a locked registrar account with multi-factor login and change alerts, removing DNS records together with the resources they point to, CAA records, and monitoring of DNS queries and certificate transparency logs.

In the interview
  • "Spoofed answers on the LAN, cache poisoning at resolvers, registrar hijack, subdomain
  • takeover, and tunneling. I use
  • DNSSEC and encrypted DNS, lock
  • the registrar with MFA, remove
  • dangling records, add CAA, and monitor DNS and cert logs."

Interview questions

Q1What is DNS spoofing?

Giving a victim a forged DNS answer so a name resolves to an attacker-controlled address. On a local network an attacker in the middle answers before the real server; the address bar still shows the correct name, so only certificate validation protects the user.

Q2What is DNS cache poisoning?

Tricking a recursive resolver into accepting and caching a forged answer, so every client using that resolver is misdirected until the record’s TTL expires. Randomised source ports and query IDs make it harder, and DNSSEC validation rejects unsigned forgeries.

Q3What does DNSSEC do and what does it not do?

DNSSEC signs DNS records so resolvers can verify authenticity and integrity through a chain of trust to the root, defeating spoofing and poisoning. It does not encrypt queries, and it does not protect against an attacker who controls the registrar or DNS provider account.

Q4What is a subdomain takeover?

A DNS record (often a CNAME) still points at a cloud resource that has been deleted. An attacker claims that resource name at the provider and serves their own content on the victim’s subdomain. Prevent it by removing records with resources and auditing DNS.

Q5Why is the domain registrar account so sensitive?

Whoever controls it can change name servers or records for the whole domain, redirecting all traffic and email and obtaining valid certificates. It needs MFA, a registry lock, minimal administrators and alerts on every change.

Q6What is DNS tunneling and how is it detected?

Encoding data inside DNS query names and responses to move commands or stolen data through a channel most firewalls allow. It is detected by unusually long or random subdomains, high query volume to one domain, and rare record types.

Q7What is the difference between DNSSEC and DNS over HTTPS?

DNSSEC provides authenticity: the answer is signed and cannot be forged, but it is still visible. DNS over HTTPS or TLS provides confidentiality and integrity in transit between the client and the resolver. They solve different problems and are used together.

Q8What are CAA records and certificate transparency logs used for?

CAA records state which certificate authorities may issue certificates for a domain. Certificate transparency logs publicly record issued certificates, so monitoring them reveals certificates you did not request, an early sign of a DNS or domain hijack.