The Domain Name System (DNS) is one of the most critical services on the Internet, responsible for translating human-readable domain names into IP addresses. Because of its central role, DNS becomes a frequent target for adversaries.
Two interesting attack surfaces are NXDOMAIN responses and phantom domain attacks. Both exploit the way DNS resolvers behave when handling invalid or unreachable domains.
What is NXDOMAIN?
An NXDOMAIN ("Non-Existent Domain") response indicates that the requested domain name does not exist.
For example:
dig doesnotexist.example.com
Output (simplified):
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 12345
;; QUESTION SECTION:
;doesnotexist.example.com. IN A
This response is legitimate and useful — but when abused, it can become a vector for denial-of-service (DoS) or traffic manipulation.
NXDOMAIN Attacks
Attackers can exploit NXDOMAIN responses in multiple ways:
1. NXDOMAIN Flooding
Adversaries flood a resolver or victim’s recursive DNS with queries for non-existent domains.
Each query forces the resolver to waste CPU, memory, and upstream traffic until it confirms the domain truly does not exist.
Red Team Use Case: Stress-test an organization's DNS resilience.
Blue Team Defense: Implement rate limiting and NXDOMAIN caching (e.g., nxdomain-ttl in BIND).
Phantom Domain Attacks
A phantom domain attack occurs when attackers register domains with authoritative servers that respond extremely slowly or not at all.
Resolvers waiting for responses get stuck, consuming resources and delaying legitimate queries.
Imagine an attacker setting up an authoritative server that just "hangs" instead of replying.
Example: Slow DNS Server
# phantom_dns.py - malicious authoritative serverimport socket, timesock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)sock.bind(("0.0.0.0", 53))while True: data, addr = sock.recvfrom(512) print(f"Query from {addr}, stalling response...") time.sleep(10) # never respond or respond too late
Resolvers contacting this server will stall until the timeout. If many such phantom domains are inserted into queries, the resolver is overloaded.
Red Team Perspective
Testing DNS Resilience:
NXDOMAIN floods reveal how recursive resolvers handle garbage traffic.
Phantom domains simulate denial-of-service without brute force.
Evasion Techniques:
Malware may query phantom domains to delay detection or cause forensic difficulty.
Attackers can poison logs with junk queries that appear as NXDOMAIN noise.