logo svg
logo

January 1, 2026

What Is DNS Data Exfiltration? How Attackers Steal Data

A deep dive into DNS-based data exfiltration, how it works, real-world attacks, and how defenders can detect and prevent it.

Mohammed Khalil

Mohammed Khalil

Featured Image

DNS data exfiltration is the practice of sneaking data out of a secured system by piggybacking on the Domain Name System DNS protocol. In plain terms, an attacker encodes stolen information into DNS queries or responses so that it leaves the network disguised as ordinary name lookups. This matters today because DNS is a foundational internet service that almost every network trusts firewalls and proxies routinely allow DNS traffic UDP/TCP port 53 through with minimal inspection. As a result, hackers exploit that trust to bypass security measures, knowing many organizations do not closely analyze DNS traffic for hidden data. DNS exfiltration is commonly observed in advanced persistent threat APT campaigns and malware incidents as part of the attack lifecycle. For example, malware may use DNS for command and control and data theft once inside a network, since it’s an ideal network level attack pattern to avoid detection. With the rise of cloud services and distributed networks, DNS based attacks have become a concern across on premises and cloud environments alike, forcing security teams to pay closer attention to a protocol that was once considered harmless.

How DNS Data Exfiltration Works

At its core, DNS exfiltration is a form of DNS tunneling, meaning the attacker creates a communication channel within DNS queries/responses to carry arbitrary data. To illustrate the mechanism, let’s break down a typical DNS data exfiltration step by step:

  1. Setup of Malicious Domain: The attacker registers a domain name e.g. malicious domain.com and configures its authoritative name server to a server under their control. This server will secretly receive stolen data via DNS queries.
  2. Infection and Data Collection: The attacker first compromises a system in the target network through malware, phishing, etc. and gathers sensitive data to steal e.g. passwords, financial records, or system information. The malware on the infected client is equipped to perform DNS queries programmatically.
  3. Data Encoding: The stolen data is broken into small chunks that can fit into DNS query labels. Each chunk is often encoded e.g. base32/base64 and sometimes encrypted for stealth. For example, a piece of data like Pa$$w0rd might be encoded into a string of seemingly random characters.
  4. DNS Query Transmission: The malware formulates DNS queries where the encoded data chunk is placed as a subdomain of the attacker’s domain. For instance, it might query a hostname like <encoded data > .malicious domain.com. To the network, this just looks like a DNS lookup for an external host. The queries are sent out from the compromised system to the organization’s DNS resolver or directly to the attacker’s nameserver if configured to bypass internal DNS.
  5. Resolution to Attacker Server: The DNS query travels through the normal resolution process. The corporate DNS resolver, not knowing the domain is malicious, forwards the request to the authoritative DNS server for malicious domain.com on the internet. This authoritative server is controlled by the attacker.
  6. Data Reconstruction on Attacker Side: When the attacker’s DNS server receives the query, it extracts the encoded data from the subdomain part and decodes it to obtain the stolen information. Over many such queries, the attacker can reassemble all chunks of the original data outside the target network.
  7. Optional Two Way Communication: In some cases, DNS tunneling is bidirectional. The attacker’s server can also send data back in DNS responses for example, in TXT record answers or in certain fields to issue commands or send malware updates to the infected client. This effectively creates a covert DNS based channel for command and control C2. However, for pure data exfiltration, the attacker often doesn’t need to send responses with hidden data; exfiltration can be accomplished with outbound queries alone.

Simplified illustration of a DNS exfiltration process. An infected client encodes stolen data into a DNS query e.g. as a subdomain of a domain controlled by the attacker and sends it out. The query passes through the normal DNS infrastructure and reaches the attacker’s name server, which decodes the hidden data from the query. Because DNS is typically allowed through firewalls, the stolen data sneaks out under the guise of a legitimate lookup. Image source: Infoblox

In essence, DNS data exfiltration is like smuggling notes out through the mailroom: the attacker hides snippets of secret information inside routine DNS lookup requests. Each DNS query can carry a small payload, so the malware continuously makes many queries until all pieces of data are sent. This process can be fast or slow depending on how much data and the attackers’ evasion strategy. Notably, because the attacker controls the DNS server on the receiving end, they can design the encoding scheme arbitrarily even evolving it over time which makes pattern based detection very challenging.

Real World Examples

DNS exfiltration is not just a theoretical concept; it has been observed in numerous real world attacks and malware campaigns:

Each of these examples underscores the appeal of DNS exfiltration: whether nation state spies or credit card thieves, attackers turn to DNS when they need a stealthy, reliable way to extract data from highly secure environments. It has been observed in finance, healthcare, retail, and even cloud service provider environments essentially anywhere valuable data resides and strict egress controls exist on common channels.

Why DNS Data Exfiltration Is Important

DNS data exfiltration is important to understand because its successful use can undermine an organization’s entire security posture. If an attacker can quietly sneak data out via DNS, they can potentially bypass all the expensive firewalls, DLP systems, and intrusion detection sensors that are focused on web or email traffic. The security implications are severe: confidential data, customer PII, intellectual property, credentials, etc. can be stolen without triggering traditional alerts, leading to breaches that remain undetected until the damage is done. This is especially dangerous for industries like financial services and healthcare, where sensitive data leakage has regulatory consequences and high financial impact. For example, a covert DNS exfiltration in a bank could extract account records or transaction data while blending in with normal DNS lookups, potentially violating compliance mandates PCI DSS, GDPR, HIPAA and causing reputational damage.

Operationally, DNS exfiltration indicates a compromise of internal systems by the time data is leaving via DNS, an attacker has already established a significant foothold. It often means malware is running on an internal host and actively communicating out. Thus, detecting DNS exfiltration is not only about stopping the data leak; it’s a critical incident response indicator to find the breached host and the scope of intrusion. Additionally, if attackers use DNS for command and control, they can maintain persistence in the network. This two way DNS traffic can allow them to issue commands, move laterally, or download additional payloads under the radar of many defenses.

From a business risk perspective, DNS exfiltration is a stealthy threat that increases the potential for mega breaches. Many organizations invest heavily in perimeter security but overlook DNS. Studies have shown an alarming rise in DNS based attacks across sectors. For instance, an industry threat report found that a large majority of organizations had been victims of DNS attacks in the past year, with DNS tunneling/exfiltration appearing in a significant portion of those incidents. The costs per DNS attack were measured in the hundreds of thousands of dollars when you account for downtime, mitigation, and data loss. Such statistics drive home the point that DNS is not just an IT utility, but a security vulnerability if left unmonitored. In cloud and SaaS providers, the stakes are also high: a breach in a multi-tenant cloud environment via DNS could expose data from numerous customers, so these providers have to double down on DNS security to protect their platforms’ integrity.

In summary, DNS data exfiltration is important because it targets a blind spot in many security programs. It exploits the assumptions of trust and necessity around DNS. Recognizing this threat prompts organizations to broaden their defensive strategy to include DNS layer monitoring and to treat DNS traffic with the same scrutiny as HTTP, SMTP, and other common channels used in breaches.

Common Abuse or Misuse

Attackers abuse DNS for data exfiltration precisely because it’s effective and hard to catch. Understanding how and why it’s misused can help defenders anticipate and disrupt this tactic:

In summary, attackers misuse DNS because it works: it’s a ubiquitous protocol with minimal oversight. The combination of easy to use tools, the difficulty of distinguishing malicious vs. legitimate queries, and the general lack of rigorous DNS defenses makes DNS exfiltration a go to technique for stealthy data theft. Understanding these abuse patterns e.g. high entropy subdomains, frequent unique DNS queries, use of TXT records can clue in defenders to the signs of DNS being used for nefarious purposes.

Detection & Monitoring

Detecting DNS data exfiltration is a notoriously tough challenge, but it’s not impossible. It requires smart monitoring of DNS traffic and system behavior to catch the subtle signals. Here are key approaches and telemetry sources for detection:

In summary, detecting DNS exfiltration requires a mix of pattern recognition, anomaly detection, and intelligent correlation. There will be false positives not every long domain is an attack CDNs and ad networks also use long subdomains!, but by tuning to your environment e.g. knowing which domains your hosts normally query you can filter noise. Empower your SOC analysts with tooling that highlights the strangest DNS traffic first. And consider leveraging automated systems as Infoblox notes, machines are well suited to parse huge DNS datasets for exfil patterns far faster than humans. A layered approach, from endpoint to network to cloud, will close the visibility gap and improve detection of these covert channels.

Mitigation & Prevention

Preventing DNS based exfiltration involves tightening control and visibility over DNS without disrupting its legitimate use. Here are several actionable measures to mitigate this threat:

Implementing these controls creates a layered defense: even if an attacker phishes a user and runs malware, their attempts to steal data via DNS will face hurdles and hopefully raise alarms. The goal is to turn DNS from a soft target into a monitored channel that an attacker cannot abuse easily. While you can’t realistically block DNS entirely, you can heavily monitor and constrain it so that covert exfiltration becomes a high risk for the adversary.

Related Concepts

DNS data exfiltration is part of a broader landscape of network covert channels and defense evasion techniques. It’s helpful to understand a few related concepts and how they connect:

In essence, DNS data exfiltration sits at the intersection of network security, malware C2, and data loss prevention. It is one instance of how attackers turn infrastructure against us. By comparing it with related techniques and concepts, defenders can better anticipate attacker behavior. For example, if you lock down DNS, the attacker might switch to another method so you must have a defense strategy that adapts and covers multiple angles, not just DNS in isolation.

FAQs

Attackers encode the data often in base32/base64 or hex and insert it into parts of the DNS query that allow arbitrary text. The most common way is to put the data into a subdomain of a domain they control. For example, if the data chunk encoded is abc123, the malware might send a DNS lookup for abc123.attacker domain.com. The string abc123 is not a legitimate hostname from the user’s perspective, it's the stolen data in encoded form. The organization’s DNS resolver will treat it as just another lookup and forward it on. When the attacker’s name server gets the query for abc123.attacker domain.com, it notes the abc123 part and decodes it back to the original sensitive data. Attackers can also carry data in DNS response messages like in TXT records or even bits stashed in fields like the transaction ID, but putting it in the query name is simplest and very common.

Several reasons: 1 DNS is ubiquitous and typically trusted, so there is a huge volume of legitimate DNS traffic that can act as camouflage. 2 Attackers can make the malicious queries look innocuous the data is encoded to look like random hostnames, and there’s nothing obviously malicious like a virus signature to catch. 3 Many organizations don’t inspect DNS at a content level; they might not notice if one DNS query out of millions contains weird data. 4 Attackers can use low and slow techniques exfiltrating very slowly or at random intervals to avoid noticeable spikes in DNS usage. 5 If they use techniques like DGAs or frequently changing subdomains, it’s hard to filter or block without causing false positives. In short, the signal malicious data is buried in a lot of noise normal DNS lookups, and it often requires advanced analysis or tooling to tease it out. It’s not impossible, but it’s harder than catching, say, an obvious malware beacon over HTTP.

Standard firewalls generally allow DNS by default, and basic IDS/IPS might not have signatures for every custom DNS tunneling pattern. Some next gen firewalls and IDS appliances do include detections for known DNS tunneling tools or anomalies for example, they might alert if a DNS query name exceeds 250 characters or if there’s a burst of DNS requests to random domains. However, crafty attackers can often bypass simple signatures by encoding data differently or using encryption within the DNS channel. To reliably detect DNS exfiltration, you often need specialized solutions or configurations: enable DNS logging and use IDS rules specifically for DNS, or deploy a DNS security solution that does deep packet inspection and behavioral analysis on DNS. Also, network based analytics NetFlow analysis can sometimes catch it by noticing unusual patterns. In summary, your infrastructure won’t catch it out of the box unless you’ve tuned it for this purpose. It’s worth checking if your IDS/IPS vendor provides DNS tunneling detection rules many do, for well known tool patterns.

The terms are closely related and often used interchangeably, but there is a nuance. DNS tunneling refers to using DNS to encapsulate any kind of traffic or messages effectively creating a tunnel or channel through DNS. This could be for command and control, for providing an attacker remote access, for proxying internet traffic like using DNS to browse the web in restricted environments, etc. DNS data exfiltration specifically refers to using DNS tunneling to sneak data out of a network. So you can think of DNS exfiltration as one goal or application of DNS tunneling, the goal being theft of data. In practice, when someone says DNS tunneling, they might mean a full bidirectional tunnel like a VPN over DNS, whereas DNS exfiltration emphasizes the theft of sensitive information. Many tools and attacks do both e.g., a backdoor might use DNS tunneling for C2 and also exfiltrate data via the same tunnel. But if we’re being precise: tunneling is the technique, exfiltration is the action data theft achieved by that technique.

Unfortunately, these technologies do not solve different problems. DNSSEC ensures that DNS responses are authenticated and haven’t been tampered with, but it doesn’t hide or restrict DNS queries. An attacker can still perform DNS queries with embedded data; DNSSEC would just sign the responses which the attacker’s domain could still do if they set it up, or they might not bother since they control the domain. DNSSEC doesn’t stop an attacker from querying a malicious domain. Encrypted DNS DoH/DoT actually makes detection harder for defenders. DoH DNS over HTTPS means DNS queries look like normal HTTPS traffic, so your DNS monitoring might not even see the queries. If an attacker uses DoH to a public resolver, they could exfiltrate data without any DNS logs in your system. From a defender’s view, blocking or limiting DoH is important so that you can see DNS queries. Encrypted DNS protects privacy and prevents ISP tampering, but if abused by malware, it just becomes an encrypted tunnel for the malware’s data essentially giving them an extra layer of cover. In summary, these protocols don’t prevent DNS from being used as a tunnel; they either ensure trust DNSSEC or provide privacy DoH, neither of which stop data exfiltration.

Any industry with valuable data can be a target, but we commonly see DNS tunneling attacks in: Financial services, where attackers target banks or fintech knowing that egress channels are locked down DNS might be the one way to get data out e.g., stock trading algorithms, credit card data. Healthcare, where patient records and research data are highly sensitive; APT29’s campaign using DNS against vaccine research is a prime example. Retail/Point of Sale, where attackers have used DNS to export credit card numbers from breached POS systems e.g., the FrameworkPOS malware case. Government and defense, as state sponsored hackers often use whatever means necessary to exfiltrate intel, including DNS for stealth. Cloud/SaaS providers themselves can be targets if attackers attempt to abuse the provider’s DNS or target management networks plus, any large enterprise with a mature security program is likely to see attackers try DNS if other channels are monitored. Essentially, DNS exfiltration is a go to for advanced adversaries, so high value targets and highly fortified networks where simpler paths are blocked will see this technique. However, even smaller organizations can be victims, since automated malware can use DNS exfiltration as well. It’s broadly a concern wherever traditional data loss channels USB drives, email, HTTP uploads are guarded and DNS might be the forgotten hole.

A number of tools exist. On the legitimate side often used by pentesters or researchers: Iodine is a popular open source tool that creates an IPv4 tunnel through DNS often used to get network access where only DNS is allowed. Dnscat2 is another well known tool focusing on creating an encrypted C2 channel over DNS. DNSExfiltrator as the name suggests is a tool specifically to exfiltrate files over DNS queries. Attack frameworks like Cobalt Strike have built in DNS beacon capabilities, which many threat actors use for C2. In terms of malware: FrameworkPOS targeting POS systems used DNS for card data theft, Feederbot and Morto early 2010s worms used DNS for C2, Backdoor.DNS DNSMessenger used DNS queries for remote control, and more recently, some ransomware groups’ toolkits include DNS tunneling for network recon or exfil. Even nation state APT malware often has a DNS backdoor module. For defenders, knowing these tools and their network behaviors like the format of Dnscat2 queries or typical Iodine traffic patterns can aid in detection. But attackers may customize traffic, so use tools as examples but rely on broader detection methods as discussed.

DNS data exfiltration is a stealthy and potent technique in the modern cyber threat landscape. It turns one of the internet’s most fundamental services, DNS , into a vehicle for data theft and covert communication. By disguising stolen data as routine name lookups, attackers can bypass many security controls and quietly siphon information out of even well secured networks. As defenders, it’s crucial to recognize that allowing DNS is not the same as safe traffic continuous monitoring, intelligent analysis, and strict egress control over DNS are must-haves to close this gap. In summary, DNS exfiltration teaches us that every protocol can be a potential attack path. The key takeaway for security teams is to treat DNS as an integral part of your security monitoring strategy. By implementing the right controls and staying vigilant for anomalies, you can detect and prevent these covert channels, denying attackers one of their favorite escapes for your data.

About the Author

Mohammed Khalil is a Cybersecurity Architect at DeepStrike, specializing in advanced penetration testing and offensive security operations. With certifications including CISSP, OSCP, and OSWE, he has led numerous red team engagements for Fortune 500 companies, focusing on cloud security, application vulnerabilities, and adversary emulation. His work involves dissecting complex attack chains and developing resilient defense strategies for clients in the finance, healthcare, and technology sectors.

background
Let's hack you before real hackers do

Stay secure with DeepStrike penetration testing services. Reach out for a quote or customized technical proposal today

Contact Us