trio.so
Explained

DNS Cache Snooping: What It Is, How to Test It and How to Fix It

What DNS cache snooping is, how to confirm the scanner finding with dig or nmap, and how to fix it on Windows DNS Server and BIND.

Mountain landscape representing leadership perspective and vision
Written by
Atena Ladchartabi

Content writer, trio.so

Published on
Modified on

DNS cache snooping is when someone asks a DNS resolver whether a domain is already in its cache, usually with a query that has the recursion flag turned off. If the server answers, the domain was looked up recently, which tells the asker which sites, cloud services or partners the people behind that resolver use. Vulnerability scanners report it as "DNS Server Cache Snooping Remote Information Disclosure" (Nessus plugin 12217, rated Medium). The fix is to let only your own clients query the resolver's cache and use recursion, and to keep internal and internet-facing DNS separate.

If a scan report brought you here, go straight to the fix section below; the rest of the post explains how the attack works and how to watch for it.

How to fix the DNS cache snooping finding

1. Confirm the finding

From a machine outside the network the scanner tested from, pick a popular domain and ask the server without recursion:

dig @203.0.113.10 www.example.com A +norecurse

If the reply contains an answer for a domain the server is not authoritative for, it is serving its cache to you. Nmap's dns-cache-snoop script checks a list of popular domains in one go:

nmap -sU -p 53 --script dns-cache-snoop 203.0.113.10

Its output reads like "10 of 100 tested domains are cached." The script is classed as intrusive, so run it only against servers you are allowed to test.

2. Decide what the server is for

  • An authoritative server on the internet (it answers for your own domains) should not do recursion for anyone. Turn recursion off.
  • An internal resolver (it looks up internet names for your staff) should answer only internal clients, and should not be reachable from the internet at all.
  • One server doing both is the usual cause of the finding. Split the roles onto separate servers or separate views.

3. Fix it on Windows DNS Server

  • For a server that only hosts your zones, disable recursion: in DNS Manager open the server's Properties, Advanced tab, and select Disable recursion (also disables forwarders), or run Set-DnsServerRecursion -Enable $false in PowerShell.
  • For a domain controller that resolves internet names for your users, block UDP and TCP port 53 from outside your network at the firewall. On Windows Server 2016 and later you can also use recursion scopes and a query resolution policy so that only your internal subnets get recursive answers.

4. Fix it on BIND

In named.conf, limit recursion and cache answers to your own networks with an access list:

acl internal { 10.0.0.0/8; 192.168.0.0/16; localhost; };
options {
    allow-recursion { internal; };
    allow-query-cache { internal; };
};

On an authoritative-only BIND server, set recursion no; instead. Reload with rndc reconfig and repeat the dig test from outside: the reply should now be refused.

5. When the finding is low risk

Tenable notes that if the server is internal and cannot be reached from outside, an attacker would have to be on your network already, which includes employees, contractors and guest Wi-Fi users. That is lower risk but not none: keep guest networks off your internal resolvers, then rescan and document the decision.

What is DNS Cache Snooping?

DNS cache snooping, also called DNS cache probing, is a way to learn what a DNS resolver has looked up recently by asking it whether a name is in its cache. The attacker does not need access to the computers behind the resolver, only the ability to send queries to it. That is why resolvers that answer anyone on the internet, or anyone on a guest network, are the main target.

How DNS Cache Snooping Works

A resolver keeps answers in its cache for a while (the record's time to live) so that the next lookup is fast. An attacker uses that in two ways:

  • Non-recursive queries: the attacker sends a query with the "recursion desired" flag off. A resolver that answers from its cache returns the record only if someone looked it up recently, and returns nothing otherwise.
  • Timing: on resolvers that refuse non-recursive queries, the attacker sends normal queries and measures the response time. A cached answer comes back noticeably faster. This method adds the name to the cache, so it only works once per name.

For example, an attacker asks the resolver about a company's VPN provider, its payroll service and a supplier's portal. Every cached answer confirms that someone behind the resolver uses that service, and the remaining TTL hints at when.

Risks Associated with DNS Cache Snooping

Snooping does not change anything on the server. Its risk is what it reveals:

  • Reconnaissance: which cloud services, security tools, banks and partners an organization uses. That makes phishing more convincing, for example a fake login page for the exact service your staff use.
  • Privacy: on resolvers that serve the public, such as an ISP's or a hotel's, it can reveal what the users visit.
  • A step towards other attacks: knowing what is cached and when it expires helps an attacker time a DNS cache poisoning attempt. Poisoning is a different attack: it plants false answers in the cache instead of reading it.

Treat it as part of vulnerability management: low impact on its own, worth fixing because the fix is a configuration change.

Real-World Scenarios of DNS Cache Snooping Attacks

Most of what is written about real snooping is research and penetration testing rather than reported breaches. Typical scenarios look like this:

  • Mapping a target's services: a tester queries a company's open resolver for common SaaS, VPN and security product domains to learn the company's software stack before a phishing campaign. Black Hills Information Security describes this kind of test in Are You Snoopable?.
  • Finding business partners: Tenable's description of the issue gives the example of learning which financial institution or partner a company uses from what its resolver has cached.
  • Checking whether malware is active: researchers have used the same trick on public resolvers to estimate whether domains used by malware are being looked up in a network.

How to Detect DNS Cache Snooping

  • Look for non-recursive queries from clients. Normal clients ask for recursion. Many queries with the recursion flag off, especially from outside your network, are a signal.
  • Watch query sources. Queries to an internal resolver from addresses outside your network should not happen at all.
  • Look for bursts of lookups for popular domains from one source, which is what scripts like nmap's produce.
  • Log and keep DNS queries. Turn on query logging (DNS analytical logs on Windows, query logging in BIND) long enough to spot patterns, and alert on the signals above in your SIEM or IDS.

Best Practices for Mitigating DNS Cache Snooping Vulnerabilities

  • Close open recursion: no resolver should answer recursive or cache queries from the whole internet.
  • Separate roles: authoritative servers for your public zones, resolvers for your users, each configured for one job.
  • Restrict by network: firewall port 53 so internal resolvers are reachable only from internal subnets, and give guest Wi-Fi its own resolver.
  • Rate-limit queries per source to slow down bulk probing.
  • Keep DNS software patched and rescan after every configuration change. See server security best practices.
  • Segment the network so a compromised device cannot reach every server; see network segmentation.

Role of DNS Security Solutions in Prevention

DNS firewalls and protective DNS services filter queries and block known malicious domains, and many log every query, which helps with detection. Managed resolvers also take the job of running and securing a resolver off your team. DNSSEC is often mentioned here, but it solves a different problem: it signs DNS answers so they cannot be forged, which defends against cache poisoning, not snooping. A DNSSEC-validating resolver still reveals what is in its cache if it answers outsiders.

Conclusion

DNS cache snooping reads what a resolver has cached, and the scanner finding usually means a resolver answers people it should not. Confirm it with dig or nmap, decide what the server is for, restrict recursion and cache answers to your own clients, and rescan.

Related reading: preventing DNS cache poisoning, DNSSEC benefits, DHCP server best practices and network segmentation.

Ready-to-use Templates

Must-have Template Toolkit for IT Admins

Explore All
Template Toolkit

Start your free trial

No credit card required
Full access to all features

Manage Every Device From One Console

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

14-day free trial. No credit card required.

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

Smiling womanAbstract geometric patternAbstract geometric patternSmiling womanSmiling woman

Frequently Asked Questions (FAQ)

Have questions? We've got answers. This section covers some of the most commonly asked questions related to this topic.

Asking a DNS resolver whether a domain is in its cache, usually with a non-recursive query, to learn which domains its users visited recently.

Limit recursion and cache queries to your internal clients (allow-recursion and allow-query-cache in BIND; disable recursion or use recursion scopes and the firewall on Windows DNS), keep internal resolvers off the internet, and rescan.

Run dig @server domain A +norecurse from outside your network, or nmap with the dns-cache-snoop script. An answer for a domain the server does not host means it serves its cache to you.

Tenable rates it Medium (CVSS v3 5.3). It leaks information rather than giving access, and the risk is lower when the server is reachable only from inside your network.

Related

From the blog

The related industry news, interviews, technologies, and resources.