DNS tunneling — the ability to encode the data of other programs or protocols in DNS queries and responses — has been a concern since the late 1990s. If you don't follow DNS closely, however, DNS tunneling likely isn't an issue you would be familiar with.
Originally, DNS tunneling was designed simply to bypass the captive portals of Wi-Fi providers, but as with many things on the Web it can be used for nefarious purposes. For many organizations, tunneling isn't even a known suspect and therefore a significant security risk. When most organizations think of DNS security, there is a tendency to overlook the security of critical data or systems being compromised by covert outbound DNS inside their networks.
To add some perspective, over the past several years there have been at least two large-scale security breaches using tunneling, affecting millions of accounts. In part one of this blog, we will provide some background on DNS tunneling in addition to discussing how DNS tunneling can be used to infiltrate your internal infrastructure. In part two, we will discuss how to detect whether your organization is affected by DNS tunneling and some proactive tips you can use to better protect your network.
What is DNS tunneling?
Through DNS tunneling, an organization's DNS can be used as a method of command and control and/or data exfiltration.
The basic method of tunneling requires that a client be compromised in some way. This follows the norm: malware via email attachment, compromised site, social engineering, etc.
While all of those methods of delivery typically require the compromised client to have external connectivity, interestingly, the compromised machine doesn't need actual external connectivity. The machine simply requires access to an internal DNS server with external access, which will enable the machine to send and receive DNS responses.
In addition to compromising the target organization, the attacker must also control a domain and a server that can act as an authoritative server for that domain in order to run the server-side tunneling and decoding programs.
Hackers use a variety of DNS tunneling utilities as well as several known malwares that use DNS as their communication channel. While each utility varies on the specifics of how they work, they all transmit the data encoded in the payload using Base32/Base64 Binary, NetBios, or Hex encoding. Hackers also use a wide variety of DNS record types, from A records to CNAME, to MX and TXT records, all of which can be combined with EDNS to increase the payload. (TXT records are the most common because they offer the largest and most diverse payload structure.)
How can DNS tunneling be used in a network breach?
Because DNS is rarely monitored and analyzed, hackers are able to use DNS tunneling to slip under the radar — until something else draws attention to the breach.
Here is the usual sequence of activities:
A client sends a request for a particular host name in a domain, with the data/response to the server encoded in the hostname being requested.
The server responds with its data in the RDATA field of the response. Because DNS allows hostnames of up to 255 characters, with each label (subdomain) limited to 63 characters, DNS allows the client to use lengthy individual labels as well as multiple levels of subdomains to encode their data. For example: The client sends a query for an A record where the data is encoded in the host name: MRZGS3TLEBWW64TFEBXXMYLMORUW4ZI.t.example.com. Then the server could respond with an answer as a CNAME response: WW2IDPOZQWY5DJNZSQ.t.example.com
The client now has two-way transactional communications to a compromised network. The attacker can transfer files out of the network or have complete remote access to the compromised system.
Join us next week for part two in this series. Learn steps you can take to identify whether your network has been compromised and some tips for preventing a breach.
Written by Chris Beauregard, Senior Professional Services Engineer at Neustar
Follow CircleID on Twitter
More under: DNS, DNS Security, Security