COMS W4181 · Security I · Fall 2026 · Lecture 5

Internet Security:
TCP and DNS

Columbia University

$ traceroute bank.com # every hop is someone you have never met
[+] Where we are going
  • 01The stack: IP, TCP, and what each layer does not check
  • 02Source-IP spoofing and TCP sequence-number prediction
  • 03Routing security: ARP, OSPF, BGP
  • 04DNS: how a name becomes an address
  • 05DNS cache poisoning, up to Kaminsky - and rebinding

Every attack in this lecture exploits a field that nobody authenticates.

[+] Internet infrastructure hosts your laptop ISP backbone ISP Your packets pass through machines owned by people you have no relationship with.
Local and interdomain routing TCP/IP for routing and messaging; BGP for routing announcements.
Domain Name System Find the IP address from a symbolic name (www.cs.columbia.edu).
[+] The TCP protocol stack Application Transport Network Link Application Transport Network Link application protocol TCP protocol router: IP data link Only the two ends speak TCP. Every hop in between reads and rewrites the IP layer.
[+] Data formats: encapsulation APPLICATION data message TRANSPORT (TCP, UDP) TCP data segment NETWORK (IP) IP TCP data packet LINK (ETHERNET) ETH IP TCP data ETF frame
[+] The Internet Protocol
IP is connectionless Unreliable. Best effort. No ordering or delivery guarantees.

Note: source and destination ports are not part of the IP header - they belong to TCP/UDP.

Version4b
Hdr Len4b
Type of Service8b
Total Length16b
Identification
Flags
Fragment Offset
Time to Live
Protocol
Header Checksum
Source Address of Originating Host32 bits · unauthenticated
Destination Address of Target Host32 bits
Options
Padding
IP Data
[+] IP routing Meg 121.42.33.12 Tom 132.14.11.51 office gateway 121.42.33.1 ISP ISP SOURCE 121.42.33.12 DESTINATION 132.14.11.51 packet
  • A typical route uses several hops.
  • IP gives no ordering or delivery guarantees - that is TCP's job.
[+] IP protocol functions (summary)
  • Routing An IP host knows the location of its router (gateway); the gateway must know the route to other networks.
  • Fragmentation and reassembly If the maximum packet size is less than the user data size.
  • Error reporting An ICMP packet is sent to the source if a packet is dropped.
  • TTL field Decremented after every hop; the packet is dropped when TTL reaches 0. Prevents infinite loops.

Fragmentation and reassembly will come back to bite us in the network-defense lecture - it is the classic way to make a firewall and a host disagree about what a packet says.

[x] Problem: no source-IP authentication
  • The client is trusted to embed the correct source IP Easy to override using raw sockets. Libnet is a library for formatting raw packets with arbitrary IP headers.
  • Anyone who owns their machine can send packets with an arbitrary source IP ... and the response will be sent back to the forged source IP, not to the attacker.
Implication 1 Anonymous DoS attacks - and reflection/amplification, since the victim receives replies to requests it never sent.
Implication 2 Anonymous infection attacks, e.g. the Slammer worm.

The reply goes to the forged address - a bug for the attacker, and a weapon.

[+] Transmission Control Protocol

Connection-oriented, and it preserves order.

Sender Break the data into packets. Attach packet numbers.
Receiver Acknowledge receipt; lost packets are resent. Reassemble the packets in the correct order.
a book mail each page numbered 1, 2, 3, ... 19 reassemble the book
[+] The TCP header (protocol = 6)
Source Port16 bits
Dest Port16 bits
SEQ Number (SN)32 bits - which byte of the stream this is
ACK Number (AN)32 bits - what I have received so far
Other stuff
URG
ACK
PSH
RST
SYN
FIN

The two sequence numbers are the only thing distinguishing a legitimate segment from an injected one. There is no key anywhere in this header.

[+] Review: the TCP handshake CLIENT SERVER listening SYN:  SN_C ← rand_C,  AN_C ← 0 SYN/ACK:  SN_S ← rand_S,  AN_S ← SN_C store SN_C, SN_S ACK:  SN ← SN_C + 1,  AN ← SN_S established Received packets with SN too far out of window are dropped.
[x] Basic security problems
  • Network packets pass by untrusted hosts Eavesdropping and packet sniffing - especially easy when the attacker controls a machine close to the victim, e.g. a Wi-Fi router.
  • TCP state is easily obtained by eavesdropping Which enables spoofing and session hijacking: once you know SN and AN, you can inject bytes into someone else's connection.
  • Denial-of-service vulnerabilities

An eavesdropper is automatically an injector, because the only secret in TCP is on the wire.

[x] Why random initial sequence numbers?

Suppose the initial sequence numbers (SN_C, SN_S) are predictable.

ATTACKER VICTIM SERVER TCP SYN   srcIP = victim SYN/ACK  dstIP = victim,  SN = server SN_S the attacker never sees this ACK   srcIP = victim,  AN = predicted SN_S command the server thinks the command came from the victim's IP
  • This breaks IP-based authentication - e.g. SPF, /etc/hosts.equiv.
  • Random sequence numbers do not prevent the attack - they make it much harder.
[ 03 ]

Routing security

ARP, OSPF, BGP - who decides where your packets go.

[+] Interdomain routing
Autonomous System (AS) A connected group of one or more Internet Protocol prefixes under a single routing policy - also called a domain.
earthlink.net (AS #4355) OSPF inside columbia.edu (AS #32) OSPF inside BGP between

OSPF = open shortest path first, used inside an AS. BGP carries routes between autonomous systems.

[x] Routing protocols and their security issues
  • ARP - address resolution protocol (IP address → Ethernet address) Local network attacks: node A can confuse the gateway into sending it traffic for node B. By proxying that traffic, A can read and inject packets into B's session - e.g. on Wi-Fi networks.
  • OSPF - used for routing within an AS.
  • BGP - routing between autonomous systems. Security issue: unauthenticated route updates. Anyone can cause the entire Internet to send traffic for a victim IP to the attacker's address - e.g. the YouTube-Pakistan mishap. Anyone can hijack the route to a victim.
[+] How BGP paths propagate [D. Wetherall] 7 origin: announces "7" 2 2 7 3 3 2 7 6 6 2 7 1 3 2 7 6 2 7 picks one, prepends itself, passes it on Nothing in the announcement proves AS 7 actually owns that prefix - or that AS 2 can reach it.
[x] BGP security issues and defenses
  • BGP path attestations are unauthenticated Anyone can inject advertisements for arbitrary routes, and the advertisement will propagate everywhere. Used for DoS, spam and eavesdropping - and often it is just human error.

Solutions

  • RPKI An AS obtains a certificate (a Route Origin Authorization) from its regional authority and attaches the ROA to its path advertisement. Advertisements without a valid ROA are ignored. Defends against a malicious AS - but not against a network attacker.
  • S-BGP Sign every hop of a path advertisement.

RIR = Regional Internet Registry, the body that assigns IP blocks to ASes. A ROA (Route Origin Authorization) says an AS number is authorized to advertise specific prefixes; it carries the ASN, a validity date range, and the IP prefixes.

[x] Example path hijack (Renesys, 2013)
Traceroute path from Guadalajara to Washington DC routed via Belarus February 2013: Guadalajara → Washington DC via Belarus. Normally: Alestra (Mexico) → PCCW (Texas) → Qwest (DC). Source: Renesys path measurements.
  • The route was in effect for several hours.
  • The reverse route (DC → Guadalajara) is unaffected - so a person browsing in DC cannot tell by traceroute that the HTTP responses are being routed through Moscow.
[+] OSPF: routing inside an AS
Link State Advertisements (LSAs) Flooded throughout the AS so that all routers have a complete view of the AS topology. Transmitted as IP datagrams with protocol = 89.
Neighbor discovery Routers dynamically discover direct neighbors on attached links, setting up an "adjacency". Once set up, they exchange their LSA databases.
Ra Rb Net-1 Ra LSA, Rb LSA - flooded R3 updates its LSA database
[+] OSPF security features
  • OSPF has message integrity (unlike BGP) - every link can have its own shared secret. Unfortunately OSPF uses an insecure MAC: MAC(k, m) = MD5(data || key || pad || len)
  • Every LSA is flooded throughout the AS So if there is a single malicious router, valid LSAs may still reach the destination by another path.
  • The "fight back" mechanism If a router receives its own LSA with a newer timestamp than the latest it sent, it immediately floods a corrected LSA.
  • Links must be advertised by both ends

That MAC construction is the length-extension-vulnerable shape we warned about in the crypto lecture - it is not HMAC.

[x] Still some attacks possible [NKGB'12]
Threat model A single malicious router wants to disrupt all AS traffic.
victim router (DR) on the LAN, serving net 1 remote attacker false Hello and DBD messages phantom router does not exist adjacency Result: denial of service on net 1.

Example problem: adjacency setup needs no peer feedback. A router can set up an adjacency with a peer without ever hearing back from it - so a remote attacker can make a victim router adopt a phantom peer.

[ 04 ]

The Domain
Name System

Turning a name you typed into an address you trust.

[+] A hierarchical name space root edu net org com uk ca wisc stanford columbia cmu mit cs ee www.cs.columbia.edu
[+] DNS root name servers
  • A hierarchical service
  • Root name servers for top-level domains
  • Authoritative name servers for subdomains
  • Local name resolvers contact authoritative servers when they do not know a name

A small number of well-known addresses bootstrap the entire namespace - which makes them both critical infrastructure and an obvious target.

Map of DNS root server locations Root server designation, responsibility and locations.
[+] DNS lookup, step by step CLIENT LOCAL RESOLVER root & edu columbia.edu / cs.columbia.edu www.cs.columbia.edu www.cs.columbia.edu ? NS columbia.edu www.cs.columbia.edu ? NS cs.columbia.edu A www = IP address the answer
[+] Record types, and caching
TypeMeaning
NSName server - points to another server
AAddress record - contains the IP address
MXThe address in charge of handling email
TXTGeneric text - e.g. used to distribute site public keys (DKIM)
  • DNS responses are cached Quick response for repeated translations. Note: NS records for domains are cached too.
  • Negative queries are cached - saving time for nonexistent sites, e.g. misspellings.
  • Cached data periodically times out The lifetime (TTL) of data is controlled by the owner of the data, and is passed with every record.
[+] The DNS packet
Query ID16 bits, random - links the response to the query
FlagsQR, opcode, RD, RA...
Question
Answer
Authority
Additional
That 16-bit field is the whole authentication A response is accepted if it arrives at the right port with the right Query ID and the right question. Classic DNS is UDP, so the source address in the reply proves nothing. 65,536 possibilities is the entire security margin.

The response is ignored if the Query ID is not recognized. (packet layout after Steve Friedl)

[+] Glue records and bailiwick checking resolver wants www.unixwiz.net .net TLD server referral: NS records + their IP addresses ("glue") authoritative NS final answer
Bailiwick checking A response is cached only if it is within the same domain as the query - i.e. a.com cannot set the NS record for b.com.
[x] Basic DNS vulnerabilities
  • Users and hosts trust the host-address mapping provided by DNS It is used as the basis for many security policies: the browser same-origin policy, and the URL address bar.
  • Interception of requests, or compromise of DNS servers, produces incorrect or malicious responses For example: a malicious access point in a cafe.
  • Solution: authenticated requests and responses Provided by DNSSEC ... but few use DNSSEC.

The same-origin policy is only as strong as the name-to-address mapping underneath it.

[x] DNS cache poisoning (a la Kaminsky '08)

The victim visits the attacker's website and downloads JavaScript.

USER BROWSER LOCAL RESOLVER .com ATTACKER query: a.bank.com a.bank.com  QID = x1 256 forged responses, random QIDs y1, y2, ... NS bank.com = ns.bank.com A ns.bank.com = attackerIP the real response, arriving second the attacker wins if there exists j with x1 = yj - then bank.com is theirs
[x] If at first you don't succeed... query b.bank.com QID = x2 256 more forged responses random QIDs y1, y2, ... c, d, e, ... success after about 256 tries - a few minutes a fresh subdomain each round, so the cache never blocks a retry
Why this was the breakthrough Poisoning a single A record was always possible but nearly useless - one failed race and the real answer got cached for hours. Using a fresh subdomain every attempt means there is never a cached answer in the way, so the attacker can retry indefinitely - and the record they inject is the NS record for the whole domain.
[/] Defenses
  • Increase the Query ID size. How? The field is 16 bits and the packet format is deployed everywhere.
  • Randomize the source port - an additional 11 bits The response must now match both the QID and the port, so the attack takes several hours instead of minutes. This is what actually shipped in 2008.
  • Ask every DNS query twice The attacker then has to guess the Query ID correctly twice - 32 bits. But apparently the DNS system cannot handle the load.
The real fix DNSSEC: sign the records, so guessing a transaction identifier is no longer enough. Adoption remains partial - which is why source-port randomization is still doing most of the work.
[x] DNS rebinding attack [DWF'96, R'01] victim browser inside the firewall FIREWALL www.evil.com ? ns.evil.com A 171.64.7.115  TTL = 0 www.evil.com serves an iframe of evil.com second lookup: 192.168.0.100 the internal corporate web server Read permitted: it is the "same origin".

The browser's origin is the name, not the address. Re-answering the same name with an internal address turns the victim's browser into a proxy behind the firewall. DNSSEC cannot stop this attack - every answer is legitimately signed by evil.com.

[/] DNS rebinding defenses
  • Browser mitigation: DNS pinning Refuse to switch to a new IP. Interacts poorly with proxies, VPNs and dynamic DNS - and is not consistently implemented in any browser.
  • Server-side defenses Check the Host header for unrecognized domains. Authenticate users with something other than their IP address.
  • Firewall defenses External names cannot resolve to internal addresses. Protects browsers inside the organization.

Every defense here is a patch on a layer that was not the one that broke.

[+] Summary
  • The core protocols were not designed for security Eavesdropping, packet injection, route stealing, DNS poisoning - all follow from fields nobody authenticates.
  • They were patched over time to prevent the basic attacks e.g. random TCP sequence numbers, randomized DNS source ports. These raise cost; they do not add authentication.
  • More secure variants exist
IP IPsec DNS DNSSEC BGP S-BGP
[+] Acknowledgements

These lecture materials were provided by Suman Jana (Columbia University), and this deck is a re-typeset and extended version of his Security I slides.

Slides in the original material are borrowed from Dan Boneh.

Figures and results: BGP propagation example [D. Wetherall]; path hijack measurement [Renesys, 2013]; OSPF attacks [Nakibly, Kirshon, Gonikman, Boneh, 2012]; DNS packet walkthrough [Steve Friedl]; rebinding [Dean, Felten, Wallach '96; Roskind '01].

Errors introduced in the re-working are mine.

← all lectures