Domain Name System (DNS) #
An aside: “Hourglass Model of the Internet”
- Email/general Application layer
- DNS/TLS
- TCP/UDP - up till here, the internet we interact with
- IP/BGP (narrowest part, i.e., everything needs to go through here)
- Link layer, Ethernet, Cellular
If a layer’s security is compromised, everything above it could be compromised.
Motivation for DNS #
- Communication on the internet is via IP, but it’s hard to remember IP addresses!
- But: easier to remember names, so map names to IP addresses (e.g.
cs249i.stanford.edu
->185.199.108.153
) - Originally, a centralized solution - a
hosts.txt
file that has a mapping for all hosts:- Organization: host -> IP address
- Store in
/etc/hosts
on system - Historically, Stanford Research Institute (SRI) kept main copy, a single place to update records by downloading them periodically
- However: fragile, hard to scale and keep in sync
- Now, a decentralized solution:
- Root nameserver has a mapping: organization -> name of organization nameserver
- Organization nameserver has a mapping: host -> IP address
DNS hierarchical namespace #
- DNS root
.
, owned by ICANN (prev. US Dept of Commerce, now independent nonprofit) - TLDs; e.g.
com.
,edu.
,us.
, held by TLD authoritative nameservers (e.g. Educause, Verisign), authority delegated from ICANN - Domain: e.g.
stanford.edu.
, Stanford authoritative nameservers (authority delegated from Educause to Stanford) - Subdomain: e.g.
cs.stanford.edu.
, authority delegated from domain owner
DNS resolution #
- Client host: has Client Stub Resolver, asks recursive resolver to resolve a domain (e.g.
cs.stanford.edu
) - Recursive resolver only has location for Root Authoritative NS, queries for
cs.stanford.edu
- Root NS: responds to ask
.edu
authoritative NS, with its location
- Root NS: responds to ask
- Recursive resolver asks
.edu
auth NS, queries forcs.stanford.edu
.edu
auth NS: responds to askns1.stanford.edu
andns2.stanford.edu
, with their locations
- Recursive resolver asks
ns1.stanford.edu
forcs.stanford.edu
ns1.stanford.edu
: responds171.64.64.64
- Recursive resolver responds
171.64.64.64
to client stub resolver
Note: recursive resolvers will not tell you the IP addresses of nameservers, but authoritative nameservers will
DNS query structure #
Queries happen over UDP, with the following fields:
- UDP header
- DNS header
- ID
- QR
- Opcode
- AA
- TC
- RD
- RA
- Z
- Rcode
- 0:
NOERROR
(success) - 2:
SERVFAIL
(server failed to complete request) - 3:
NXDOMAIN
(domain name does not exist) - 4:
NOTIMP
(function not implemented) - 5:
REFUSED
(server refused to answer queries)
- 0:
- Query count
- Answer count
- NS count
- Additional record count
- Question section
- Query name (
QNAME
): domain to resolve - Query class (
QCLASS
)IN
: internetCHAOS
: used for debugging
- Query type (
QTYPE
)NS
: authoritative nameserver for domainA
: IPv4 addressAAAA
: IPv6 addressMX
: mail exchange records
- Query name (
- Answer section
- Name
- Type
- Class
- TTL (how long to cache answer)
- RDLength
- RDATA
- Authority section
- Additional info section
Caching #
- Why cache DNS responses?
- Reduces load
- Improves latency
- Reuse results of previous queries
- How long to cache? Governed by Time to Live (TTL)
DNS failures #
- Misconfigurations: typos, misconfigured auth NS
- Hardware/network failures: unreachable nameservers
- Large traffic volumes; DoS attacks
DNS reliability #
- UDP used, because faster than TCP (no need to do the whole handshake for a short single-use query)
- Reliability through replication
- Two auth NS per domain
- Multiple root NS’s, TLD authoritative NS’s
DNS confidentiality #
- Everyone on path can see your DNS queries!
- DNS-over-TLS/DNS-over-HTTPS solves this, by directly routing queries to DNS providers like Google and Cloudflare
- This made ISPs livid, because they were selling data about DNS queries they could collect in the clear
- However, ISPs can now try to pretend to be 8.8.8.8 - used for censorship
DNS administration #
- Before 1999: US Department of Commerce, SRI-NIC, Network Solutions
- After 1999: Commerce delegated to ICANN:
- gTLD (generic TLD) have to obey rules set forth by ICANN
- ccTLD (country code TLD) rules are determined by each country
- Principles:
- Competition
- Representation
- Stability
- Private, bottom-up coordination
- Stakeholders:
- ICANN
- Registrar (e.g. GoDaddy): handles registration of domains (i.e., selling domains)
- Registry (e.g. Verisign): handles operations
- Registrant (e.g. Google): domain owner
Updating nameservers #
- Registrant uses Registrar’s web API to change nameservers
- Registrar updates EPP (Extensible Provisioning Protocol) server held by Registry, which updates its database
- Registry updates TLD authoritative NS
Attacks on DNS infrastructure #
- Domain hijacking: compromise of domain registrars to redirect a victim company’s domain name to a malicious IP
- Used for conducting phishing attacks
- TLS doesn’t help here!
- TLS protects against MITM attacks
- Automated TLS certificate issuance using domain validation (e.g. Let’s Encrypt) uses DNS to authenticate domain “ownership”
- However, if attacker controls DNS on registrar end, can obtain TLS certificate for the fraudulent domain
- 2017 attack against aerospace companies was pre-Cert Transparency, so no record of the new fraudulent certificate being issued
- But: if you’re someone big like Google, then you ship your cert to browsers and have the browsers SSL pin you, so this attack is hard to pull off against such targets