Learn › Part 2 ยท Network attacks and defence

DNS attacks, amplification and firewalls

Pharming and glue poisoning, on-path and off-path cache poisoning, DNS hardening, amplification, and stateless, stateful and proxy firewalls.

DNS attacks

A resolver accepts a reply only if it matches the query's IP addresses, UDP ports and 16-bit transaction ID. Attacks aim to supply a forged reply that passes those checks.

  • Pharming: corrupt the name-to-address mapping (compromised server or spoofed reply); often paired with a phishing replica.
  • Glue poisoning: a compromised authoritative server for univ-a.example adds glue claiming bank.example is at the attacker's address; a naive resolver caches it. Defence: bailiwick checking (discard glue outside the queried zone).
  • On-path poisoning: the attacker sees the query's ID and ports, so racing a forged reply is easy.
  • Off-path poisoning: the attacker must guess. With sequential IDs it triggers a query for its own domain, reads ID, then forges replies with ID + 1 for the victim's next lookup.

Random 16-bit ID alone: 216 = 65,536 guesses. Random ID and random 16-bit source port: 216 × 216 = 232 ≈ 4.29 billion.

DNSSEC adds signatures to DNS data so resolvers can verify origin and integrity; it does not encrypt queries.

Amplification

The attacker sends small queries with the victim's address as source to open servers, which send large replies to the victim. Victim load = attacker rate × amplification factor; a 60-byte query that yields 3,000 bytes is a factor of 50, so 10 Mbps of queries become 500 Mbps.

Firewalls

A firewall is a single choke point that enforces policy and is itself hardened. Three types:

TypeDecides onStrengthWeakness
Stateless packet filterEach packet's addresses, protocol, ports, TCP flags, ICMP typeFast, simpleAccepts crafted packets that look like replies (e.g. source port 80 with ACK)
Stateful packet filterHeaders plus a connection table (TCP handshakes; UDP 4-tuples with short timeouts)Only real replies get inNo view of application content or users
Application gateway (proxy)Application data and user identityPer-user, per-command policyOne gateway per protocol; slower

Policy to rule examples

PolicyRule
No outside web accessDrop outgoing TCP to destination port 80 (and 443)
No inbound connections except to the public web serverDrop inbound SYN (ACK = 0) except to that server's port 80
Stop traceroute mappingDrop outgoing ICMP Time Exceeded
Insiders may connect out, outsiders may not connect inDrop inbound TCP with ACK = 0

Worked ACL (organisation 222.22/16), first match wins

1 allow  222.22/16 -> outside   TCP  >1023 -> 80     any
2 allow  outside   -> 222.22/16 TCP  80    -> >1023  ACK   [check connection]
3 allow  222.22/16 -> outside   UDP  >1023 -> 53
4 allow  outside   -> 222.22/16 UDP  53    -> >1023        [check connection]
5 deny   all

A crafted packet from 150.23.23.155:80 to an inside host with ACK set passes rule 2 in a stateless filter. With the stateful “check connection” column it is dropped, because no inside host opened that connection.

Common pitfalls

  • Guessing spaces multiply; they do not add.
  • Longer TTLs keep poisoned records alive longer.
  • Rule order matters: a broad deny above a narrow allow wins.