$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
Local and interdomain routingTCP/IP for routing and messaging; BGP for routing announcements.
Domain Name SystemFind the IP address from a symbolic name (www.cs.columbia.edu).
[+] The TCP protocol stack[+] Data formats: encapsulation[+] The Internet Protocol
IP is connectionlessUnreliable. 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
A typical route uses several hops.
IP gives no ordering or delivery guarantees- that is TCP's job.
[+] IP protocol functions (summary)
RoutingAn IP host knows the location of its router (gateway); the gateway must know the route to other networks.
Fragmentation and reassemblyIf the maximum packet size is less than the user data size.
Error reportingAn ICMP packet is sent to the source if a packet is dropped.
TTL fieldDecremented 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 IPEasy 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 1Anonymous DoS attacks - and reflection/amplification, since the victim
receives replies to requests it never sent.
Implication 2Anonymous 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.
SenderBreak the data into packets. Attach packet numbers.
ReceiverAcknowledge receipt; lost packets are resent. Reassemble the packets in the
correct order.
[+] 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[x] Basic security problems
Network packets pass by untrusted hostsEavesdropping 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 eavesdroppingWhich 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.
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.
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][x] BGP security issues and defenses
BGP path attestations are unauthenticatedAnyone 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
RPKIAn 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-BGPSign 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)
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 discoveryRouters dynamically discover direct neighbors on attached links, setting up an
"adjacency". Once set up, they exchange their LSA databases.
[+] 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 ASSo if there is a single malicious router, valid LSAs may still reach the destination by another path.
The "fight back" mechanismIf 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 modelA single malicious router wants to disrupt all AS traffic.
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[+] 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.
Root server designation, responsibility and locations.
[+] DNS lookup, step by step[+] Record types, and caching
Type
Meaning
NS
Name server - points to another server
A
Address record - contains the IP address
MX
The address in charge of handling email
TXT
Generic text - e.g. used to distribute site public keys (DKIM)
DNS responses are cachedQuick 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 outThe 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 authenticationA 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
Bailiwick checkingA 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 DNSIt 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 responsesFor example: a malicious access point in a cafe.
Solution: authenticated requests and responsesProvided 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.
[x] If at first you don't succeed...
Why this was the breakthroughPoisoning 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 bitsThe 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 twiceThe attacker then has to guess the Query ID correctly twice - 32 bits. But apparently the DNS system cannot handle the load.
The real fixDNSSEC: 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]
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 pinningRefuse to switch to a new IP. Interacts poorly with proxies, VPNs and dynamic DNS - and is not consistently implemented in any browser.
Server-side defensesCheck the Host header for unrecognized domains. Authenticate users with something other than their IP address.
Firewall defensesExternal 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 securityEavesdropping, packet injection, route stealing, DNS poisoning - all follow from fields nobody authenticates.
They were patched over time to prevent the basic attackse.g. random TCP sequence numbers, randomized DNS source ports. These raise cost; they do not add authentication.
More secure variants exist
[+] 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.