Blog

Computer with bandit mask.

How Attackers Use DNS Tunneling, Why It’s Dangerous, and How to Defend Your Company

November 04, 20257 min read

DNS (Domain Name System) is one of the most trusted, and therefore most abused protocols on the internet. DNS tunneling is a technique attackers use to hide command-and-control (C2) traffic or to exfiltrate data by encoding it inside seemingly innocuous DNS queries and responses. Because DNS is almost always allowed through corporate firewalls and often receives less inspection than HTTP or HTTPS, it’s an attractive covert channel for adversaries (MITRE ATT&CK, 2024).


How Attackers Implement DNS Tunneling

At a high level, DNS tunneling has three moving parts: a compromised endpoint inside your network, malware (or a tunneling tool) that encodes data into DNS requests, and an attacker-controlled authoritative DNS server that decodes those requests and returns responses that can contain commands or confirmation. The infected device issues DNS queries containing encoded payloads in subdomains (for example: bG9naW46ZW1haWw=.attacker.com), which are forwarded by resolvers to the attacker’s nameserver. The attacker’s server extracts the encoded data, responds appropriately, and can send back payloads or instructions via DNS resource records. This enables two-way communication over DNS (Palo Alto Networks, 2024).

There are multiple tools and methods attackers use from older utilities like Iodine and DNScat to customized malware that implements DNS encoding and fragmentation, and even modern variations that hide data inside DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) to evade visibility. Research has shown that attackers adapt these techniques continuously, and defenders need to account for newer evasion tactics such as DoH-based exfiltration (Salat et al., 2023; Wang & Zhao, 2024).


The Attacker’s Goals and What They Can Steal

DNS tunneling is versatile. Common attacker goals include:

  • Command-and-control (C2): Maintain a stealthy connection to infected hosts to issue commands, deploy additional payloads, or pivot inside the network (MITRE ATT&CK, 2024).

  • Data exfiltration: Steal credentials, documents, or database snippets by encoding them into repeated DNS queries. Because exfiltration can be performed in small chunks, it’s ideal for slowly siphoning sensitive files while staying beneath detection thresholds (Salat et al., 2023).

  • Persistence and tunneling for other protocols: Tunnel arbitrary protocols or create a full-duplex channel to the attacker’s infrastructure (BrightSec, 2024).


Consequences of Not Defending Against DNS Tunneling

Underestimating DNS as an attack surface has real costs:

  • Silent data loss: DNS exfiltration can bypass normal egress filtering and go unnoticed for long periods, making breach discovery much later and increasing remediation cost. Large scale exfiltration incidents have historically resulted in prolonged investigations and regulatory exposure (Salat et al., 2023).

  • Stealthy footholds and lateral movement: DNS-based C2 allows attackers to control infected hosts and deploy additional tools, enabling privilege escalation and lateral movement that quickly multiplies the impact (MITRE ATT&CK, 2024).

  • Operational disruption and reputational harm: Once attackers have data or persistent access, companies face downtime, lost customer trust, and financial penalties, especially if regulated data is involved (CSO Online, 2023).


Why DNS Is Attractive to Attackers (and Why Standard Protections Can Fail)

Many organizations allow recursive DNS to the internet or permit DoH/DoT traffic for user convenience. DNS also happens early in the network stack (even before authentication completes), so it can be used by early-stage malware. In addition, legacy monitoring often focuses on web traffic and endpoints, while DNS logs are either not collected or not analyzed deeply. That combination makes DNS an excellent covert channel (Palo Alto Networks, 2024; Cisco Umbrella, 2024).


Practical Defenses — How to Stop DNS Tunneling

Defending against DNS tunneling requires layered controls, behavioral detection, and operational changes. Below are practical steps that organizations should implement now:

  1. Force trusted resolvers and block direct external DNS: Ensure endpoints use corporate or managed resolvers (do not allow arbitrary external DNS resolvers). Block outbound DNS to unknown DNS servers at the network perimeter and on endpoints. This prevents compromised hosts from directly contacting attacker nameservers (Cisco Umbrella, 2024; BrightSec, 2024).

  2. Deploy protective DNS / DNS filtering: Use a protective DNS service (e.g., Cloudflare Gateway, Cisco Umbrella, or similar) that blocks known-malicious domains, categorizes DNS requests, and enforces policy for remote users. These services also log DNS activity centrally for detection (Cisco Umbrella, 2024).

  3. Monitor DNS behavior and apply analytics: Look for anomalies such as unusually long subdomain labels, very high volumes of TXT/NULL requests, high-frequency queries from non-browser processes, patterns of small, repetitive queries to a single external domain, or base64-like payloads in subdomains. Use statistical and ML-based detectors for real-time flagging. Research shows that behavioral heuristics and ML significantly improve detection rates (Zhou et al., 2024; Salat et al., 2023).

  4. Inspect and control encrypted DNS: DoH/DoT can hide DNS traffic from local perimeter tools. Enforce corporate policy; either block unmanaged DoH providers or centralize DoH through enterprise services that the organization controls, and log those queries. Recent research highlights DoH-based exfiltration as a rising risk (Wang & Zhao, 2024).

  5. Harden endpoints and stop the initial infection: Many DNS tunnels rely on malware. Strengthen endpoint protection, apply least-privilege policies, restrict execution of scripting environments, and maintain patch/asset hygiene. User training reduces the chance of initial compromise (Palo Alto Networks, 2024; CSO Online, 2023).

  6. Rate limiting and protocol hardening: Implement DNS rate-limiting, limit large TXT/NULL responses, and disable unnecessary DNS services. These reduce the throughput available for exfiltration and raise the attack cost for adversaries (BrightSec, 2024).

  7. Retain and analyze DNS logs: Collect DNS logs centrally (SIEM, EDR integrations) and correlate with endpoint telemetry. Investigation capability is crucial: without usable logs, post-compromise forensics is difficult (Salat et al., 2023).


How We Help Companies Defend Themselves

At CSS we approach DNS tunneling defense as a blend of technology, process, and people:

  • Assessment & detection readiness: We start with a DNS risk assessment: mapping resolver usage, identifying DoH/DoT exposure, and analyzing baseline DNS patterns. That tells us where to focus detection rules and what logging to enable. This step often uncovers unmanaged DNS flows that quietly bypass corporate controls.

  • Protective DNS deployment & policy: We design and deploy enterprise-grade protective DNS (policy, allow/block lists, and split-horizon configurations) and integrate it with corporate SSO and device posture checks to maintain policy enforcement for both office and remote users (Cisco Umbrella, 2024).

  • Behavioral detection and hunting: We tune behavioral detections for DNS anomalies, deploy ML-assisted detection where appropriate, and run proactive threat hunting to find early signs of tunneling or exfiltration. Our playbooks include triage steps and containment guidance (Zhou et al., 2024).

  • Endpoint hardening and incident response: We help harden endpoints (application allowlisting, EDR tuning) to prevent the initial foothold and prepare an incident response plan specifically covering DNS-based incidents including DNS log retention, containment, and eradication steps (BrightSec, 2024).

  • Training and tabletop exercises: People are a key control. We run targeted awareness sessions and tabletop exercises that simulate DNS tunneling scenarios so SOCs and IT teams can practice detection and response.


Final Thought

DNS is not just a convenience service, it’s a potential covert channel. Attackers have long exploited DNS tunneling for C2 and stealthy exfiltration, and modern attackers continue to evolve their methods. A layered approach combining protective DNS, behavioral detection, endpoint hardening, and clear operational playbooks dramatically reduces risk and improves detection speed.

If you’d like, we can run a DNS risk assessment for your environment and produce an action plan tailored to your current resolver topology, DoH exposure, and logging posture.


References

BrightSec. (2024). DNS Tunneling Explained: Detection and Prevention. Retrieved from https://brightsec.com
Cisco Umbrella. (2024). Improvements to DNS Tunneling & Exfiltration Detection. Cisco Systems.
CSO Online. (2023). 4 Strategies to Help Reduce the Risk of DNS Tunneling. Foundry.
MITRE ATT&CK. (2024). T1071.004: Application Layer Protocol — DNS. MITRE Corporation.
Palo Alto Networks. (2024). What Is DNS Tunneling? Cyberpedia.
Salat, L., Gupta, R., & Kim, Y. (2023). DNS Tunneling, Exfiltration and Detection over Cloud. National Library of Medicine.
Wang, H., & Zhao, J. (2024). Detection of DoH-Based Data Exfiltration Using Machine Learning. ResearchGate.
Zhou, T., Li, X., & Singh, R. (2024). Information-Based Heavy Hitters for Real-Time DNS Data. NDSS Symposium.

Back to Blog

Call us at (954) 368-0648 or fill out the form below.

Enroll in Our Email Course

Learn How a No-Nonsense IT Strategy Benefits Your Company:
  • Strategies to allocate your IT budget efficiently

  • Enhance cybersecurity defenses on a budget

  • Ensure your technology investments continue to serve your business as it grows