Some advanced topics. Karst Koymans. Friday, September 11, 2015



Similar documents
Table of Contents DNS. How to package DNS messages. Wire? DNS on the wire. Some advanced topics. Encoding of domain names.

DNS. Some advanced topics. Karst Koymans. (with Niels Sijm) Informatics Institute University of Amsterdam. (version 2.6, 2013/09/19 10:55:30)

DNS/DNSSEC loose ends

DNS Conformance Test Specification For Client

1 DNS Packet Structure

Forouzan: Chapter 17. Domain Name System (DNS)

Motivation. Domain Name System (DNS) Flat Namespace. Hierarchical Namespace

Teldat Router. DNS Client

DNS at NLnet Labs. Matthijs Mekking

Coordinación. The background image of the cover is desgned by GUIDE TO DNS SECURITY 2

Internetworking with TCP/IP Unit 10. Domain Name System

Domain Name System (DNS) Fundamentals

19 Domain Name System (DNS)

netkit lab dns Università degli Studi Roma Tre Dipartimento di Informatica e Automazione Computer Networks Research Group Version Author(s)

Domain Name System. DNS is an example of a large scale client-server application. Copyright 2014 Jim Martin

THE DOMAIN NAME SYSTEM DNS

Domain Name System (DNS)

Domain Name System (DNS) Session-1: Fundamentals. Ayitey Bulley

Subverting BIND s SRTT algorithm Derandomizing NS selection

Introduction BIND. The DNS Protocol. History (1) DNS. History (2) Agenda

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Applications and Services. DNS (Domain Name System)

Response Differences between NSD and other DNS Servers

Ólafur Guðmundsson. Peter Koch. Shinkuro, Inc. DENIC eg. DNS IETF-80 ogud@ogud.com & pk@denic.de

Motivation. Users can t remember IP addresses. Implemented by library functions & servers. - Need to map symbolic names (

DNS : Domain Name System

DNS (Domain Name System) IETF-70 (DNS for protocol designers)

The Domain Name System from a security point of view

Domain Name System :49:44 UTC Citrix Systems, Inc. All rights reserved. Terms of Use Trademarks Privacy Statement

Lecture 2 CS An example of a middleware service: DNS Domain Name System

Tanenbaum, Computer Networks (extraits) Adaptation par J.Bétréma. DNS The Domain Name System

The Domain Name System

DNS zone transfers from FreeIPA to non-freeipa slave servers

dnsperf DNS Performance Tool Manual

How-to: DNS Enumeration

The Domain Name System

Agenda. Network Services. Domain Names. Domain Name. Domain Names Domain Name System Internationalized Domain Names. Domain Names & DNS

Application Protocols in the TCP/IP Reference Model

Application Protocols in the TCP/IP Reference Model. Application Protocols in the TCP/IP Reference Model. DNS - Concept. DNS - Domain Name System

Networking Domain Name System

Measurement of the Usage of Several Secure Internet Protocols from Internet Traces

Domain Name System Security

Internet-Praktikum I Lab 3: DNS

Response Policy Zones for the Domain Name System (DNS RPZ) By Paul Vixie, ISC (et.al.) 2010 World Tour

Outline. Definition. Name spaces Name resolution Example: The Domain Name System Example: X.500, LDAP. Names, Identifiers and Addresses

The Domain Name System

The Domain Name System (DNS)

DNS ActiveX Control for Microsoft Windows. Copyright Magneto Software All rights reserved

Networking Domain Name System

Understanding DNS (the Domain Name System)

Chapter 23 The Domain Name System (DNS)

Computer Networks Prof. S. Ghosh Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 34 DNS & Directory

Local DNS Attack Lab. 1 Lab Overview. 2 Lab Environment. SEED Labs Local DNS Attack Lab 1

Hostnames. HOSTS.TXT was a bottleneck. Once there was HOSTS.TXT. CSCE515 Computer Network Programming. Hierarchical Organization of DNS

API of DNS hosting. For DNS-master and Secondary services Table of contents

CSE 127: Computer Security. Network Security. Kirill Levchenko

Use Domain Name System and IP Version 6

Rough Outline. Introduction Why DNSSEC DNSSEC Theory Famous last words. Universiteit van Amsterdam, Sep 2006.

Copyright International Business Machines Corporation All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure

USING TRANSACTION SIGNATURES (TSIG) FOR SECURE DNS SERVER COMMUNICATION

1 Introduction: Network Applications

DNS Service on Linux. Supawit Wannapila CCNA, RHCE

Networking Domain Name System

The Use of DNS Resource Records

DNSSEC Applying cryptography to the Domain Name System

Part 5 DNS Security. SAST01 An Introduction to Information Security Martin Hell Department of Electrical and Information Technology

DNS Session 4: Delegation and reverse DNS. Joe Abley AfNOG 2006 workshop

Computer Networks - CS132/EECS148 - Spring

State of the "DNS privacy" project. Stéphane Bortzmeyer AFNIC

Domain Name System (DNS) RFC 1034 RFC

Introduction to Network Operating Systems

How to Configure DNS Zones

KB Windows 2000 DNS Event Messages 1 Through 1614

Lecture 15. IP address space managed by Internet Assigned Numbers Authority (IANA)

Chapter 25 Domain Name System Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Computer Networks: Domain Name System

DNS Domain Name System

Basic DNS Course. Module 1. DNS Theory. Ron Aitchison ZYTRAX, Inc. Page 1 of 24

DNS. The Root Name Servers. DNS Hierarchy. Computer System Security and Management SMD139. Root name server. .se name server. .

3. The Domain Name Service

Protection of DNS using HAVAL

what s in a name? taking a deeper look at the domain name system mike boylan penn state mac admins conference

KAREL UCAP DNS AND DHCP CONCEPTS MANUAL MADE BY: KAREL ELEKTRONIK SANAYI ve TICARET A.S. Organize Sanayi Gazneliler Caddesi 10

Recommendations for dealing with fragmentation in DNS(SEC)

CS3250 Distributed Systems

Transcription:

DNS Some advanced topics Karst Koymans Informatics Institute University of Amsterdam (version 154, 2015/09/14 10:44:10) Friday, September 11, 2015 Karst Koymans (UvA) DNS Friday, September 11, 2015 1 / 41

1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 2 / 41

DNS on the wire Outline 1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 3 / 41

DNS on the wire Wire? Wire == Network Not the 1980s rock band ;-) nor the TV series ;-) Queries and Responses are packaged in packets Packets are transferred over the wire/air OSI Layer 2: can be anything OSI Layer 3: IPv4 or IPv6 OSI Layer 4: UDP or TCP Karst Koymans (UvA) DNS Friday, September 11, 2015 4 / 41

DNS on the wire How to package DNS messages 1 Define what information you want to exchange 2 Specify a format in which to encode that information Serialization, flattening data structures 3 Implement that format in software 4 Start doing DNS :) Karst Koymans (UvA) DNS Friday, September 11, 2015 5 / 41

DNS on the wire DNS Message packet format Header section Question section Answer section Authority section Additional section Karst Koymans (UvA) DNS Friday, September 11, 2015 6 / 41

DNS on the wire DNS packet header 0 15 16 31 ID Flags QDCOUNT ANCOUNT NSCOUNT ARCOUNT Karst Koymans (UvA) DNS Friday, September 11, 2015 7 / 41

DNS on the wire DNS header DNS header fields ID Flags QDCOUNT ANCOUNT NSCOUNT ARCOUNT Transaction Identifier See next slide Number of questions Number of answers Number of authority records Number of additional records Karst Koymans (UvA) DNS Friday, September 11, 2015 8 / 41

DNS header flags Bit(s) Mnemonic Meaning 0 QR Query(0) or Response(1) 1-4 OPCODE Kind of Query (see next slide) 5 AA Authoritative Answer 6 TC TrunCation or Truncated Response 7 RD Recursion Desired 8 RA Recursion Available 9 - Reserved 10 AD Authentic Data (DNSSEC) 11 CD Checking Disabled (DNSSEC) 12-15 RCODE Result Code

DNS on the wire DNS opcodes DNS opcodes 0 Query Standard query 1 IQuery Inverse Query (obsolete) 2 Status Status query (not standardized) 4 Notify Change of master data 5 Update Dynamic update Karst Koymans (UvA) DNS Friday, September 11, 2015 10 / 41

DNS result codes Value Mnemonic Meaning 0 NoError No Error 1 FormErr Format Error 2 ServFail Server Failure 3 NXDomain Non-eXistent Domain 4 NotImp Not Implemented 5 Refused Query Refused 6-10 Related to dynamic updates 11-15 Not assigned 16- Extended result codes (EDNS0)

DNS on the wire Queries In most cases QDCOUNT is 1 Query consists of QNAME (sequence of labels, encoded with length/value pairs) Ending when length == 0, respresenting the empty root label QTYPE (2 bytes) QCLASS (2 bytes, almost always IN (==1)) Karst Koymans (UvA) DNS Friday, September 11, 2015 12 / 41

DNS on the wire Answers, Authorities and Additionals (1/2) Answers Answers to question(s) Special treatment of CNAMEs, DNAMEs and wildcards Authorities Adds NS records as referral information Additionals Courtesy information Dangerous if accepted too easily, especially if the information is not related to the question Karst Koymans (UvA) DNS Friday, September 11, 2015 13 / 41

DNS on the wire Answers, Authorities and Additionals (2/2) Each of these is a list of resource records Answers Authorities Additionals Data per resource record NAME, TYPE, CLASS (as in queries) TTL (4 bytes) RDLENGTH (2 bytes) RDATA (RDLENGTH bytes) Karst Koymans (UvA) DNS Friday, September 11, 2015 14 / 41

Encoding of domain names Outline 1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 15 / 41

Encoding of domain names Encoding of domain names Specify length of labels in label encoding So a domain name is encoded as <length> <label> <length> <label> 3 "www" 3 "os3" 2 "nl" 0, which amounts to 3 'w' 'w' 'w' 3 'o' 's' '3' 2 'n' 'l' 0, or 3 119 119 119 3 111 115 51 2 114 108 0, where Lengths are at most 63 and encoded as big endian 'X' is the ASCII value of character X Note the difference between 3 and '3' Karst Koymans (UvA) DNS Friday, September 11, 2015 16 / 41

Encoding of domain names Normal label length encoding First byte used for length First 2 bits are flags 00 means normal label length Remaining 6 specify label length Hence the maximum label length of 2 6 1 = 63 octets Remaining bytes contain the label itself Number of remaining bytes is encoded in first byte of label Karst Koymans (UvA) DNS Friday, September 11, 2015 17 / 41

Encoding of domain names Normal label length encoding Source: Niels Sijm, CIA lecture 2012-2013 Karst Koymans (UvA) DNS Friday, September 11, 2015 18 / 41

Encoding of domain names Normal label length encoding Source: Niels Sijm, CIA lecture 2012-2013 Karst Koymans (UvA) DNS Friday, September 11, 2015 19 / 41

Encoding of domain names Label types First two bits of the length byte denote the label type A label length may not exceed 63 octets (6 bits needed) 00: Normal label length 11: Compressed label 1 : 6+8 bits used as pointer 01: Extended label type (EDNS0) 01000001: Binary labels (for use with IPv6 PTR types) Binary labels were deprecated in April 2013 (RFC 6891) 10: Unallocated label type 1 This is a misnomer, because the domain name (not the label) is compressed Karst Koymans (UvA) DNS Friday, September 11, 2015 20 / 41

Encoding of domain names Compressed encoding Domain name with compressed encoding has fixed length of 2 bytes First 2 bits are flags 11 means compressed label Remaining 6 bits + 8 subsequent bits are used as a pointer Points to domain name at another position in the packet from where the domain name construction is continued Value is offset from beginning of DNS packet which starts right after the UDP or TCP header Saves space when a domain name is used more than once Karst Koymans (UvA) DNS Friday, September 11, 2015 21 / 41

Encoding of domain names Compressed encoding Source: Niels Sijm, CIA lecture 2012-2013 Karst Koymans (UvA) DNS Friday, September 11, 2015 22 / 41

Encoding of domain names Compressed encoding Source: Niels Sijm, CIA lecture 2012-2013 Karst Koymans (UvA) DNS Friday, September 11, 2015 23 / 41

Encoding of domain names Reading domain names Read first 2 bits of domain name field If value is 00 normal label length 1 Read 6 subsequent bits and determine length of label 2 If label length is 0 (empty label, thus root): Return sequence of noted labels as domain name 3 If label length is positive Read label, first 2 bits of next byte and iterate If value is 11 compressed encoding 1 Read 14 subsequent bits and determine position of domain name 2 Jump to position and decode remainder of domain name recursively Karst Koymans (UvA) DNS Friday, September 11, 2015 24 / 41

Encoding of domain names Extended label type First two bits are 01 Defined by EDNS0 For instance first byte is 01000001 which was used for binary labels (deprecated) where the main use case was IPv6 PTR resource records Karst Koymans (UvA) DNS Friday, September 11, 2015 25 / 41

Zone transfers Outline 1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 26 / 41

Zone transfers Use of zone transfers Copy data from master server to slave server ns1os3nl (master) ns2os3nl (slave) ns1zurichsurfnet (slave) Zone transfers are often limited to slave servers DNS data: public or semipublic? You can prevent zone transfers using ACLs on the IP level Karst Koymans (UvA) DNS Friday, September 11, 2015 27 / 41

Zone transfers How zones are transferred Pull When starting without a cached copy of the zone data When data has changed Uses serial number to decide whether data has changed DNS query type AXFR or IXFR Push Tells slave servers to pull :) DNS opcode 4 ( notify ) Karst Koymans (UvA) DNS Friday, September 11, 2015 28 / 41

Wildcards Outline 1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 29 / 41

Wildcards Wildcards (1) From RFC 1034, section 433 The contents of the wildcard RRs follows the usual rules and formats for RRs The wildcards in the zone have an owner name that controls the query names they will match The owner name of the wildcard RRs is of the form *<anydomain>, where <anydomain> is any domain name <anydomain> should not contain other * labels, and should be in the authoritative data of the zone The wildcards potentially apply to descendants of <anydomain>, but not to <anydomain> itself Another way to look at this is that the * label always matches at least one whole label and sometimes more, but always whole labels Karst Koymans (UvA) DNS Friday, September 11, 2015 30 / 41

Wildcards Wildcards (2) From RFC 1034, section 433 Wildcard RRs do not apply: When the query is in another zone That is, delegation cancels the wildcard defaults When the query name or a name between the wildcard domain and the query name is know a to exist For example, if a wildcard RR has an owner name of *X, and the zone also contains RRs attached to BX, the wildcards would apply to queries for name ZX (presuming there is no explicit information for ZX), but not to BX, ABX, or X a original text, should be known Karst Koymans (UvA) DNS Friday, September 11, 2015 31 / 41

Wildcards Wildcard synthesis in query matching algorithm From RFC 1034, section 432, algorithm step 3c If at some label, a match is impossible (ie, the corresponding label does not exist), look to see if a the * label exists If the * label does not exist, check whether the name we are looking for is the original QNAME in the query or a name we have followed due to a CNAME If the name is original, set an authoritative name error in the response and exit Otherwise just exit If the * label does exist, match RRs at that node against QTYPE If any match, copy them into the answer section, but set the owner of the RR to be QNAME, and not the node with the * label Go to step 6 Karst Koymans (UvA) DNS Friday, September 11, 2015 32 / 41

Wildcards Problems with wildcards in RFC 1034 Notions are intuitive, not well-defined When does a domain name exist? How does matching work exactly? What about empty non-terminals? RFC 4592 tries to clarify all of this Defines existence of a domain name Defines asterisk label and wildcard domain name Defines source of synthesis and closest encloser Karst Koymans (UvA) DNS Friday, September 11, 2015 33 / 41

Wildcards Wildcard supporting definitions Definitions A domain name exists if the name itself or any of its descendants has at least one RR In particular empty non-terminals exist An asterisk label is a label of length 1 containing as only octet the ASCII equivalent of * A wildcard domain name is a domain name with an asterisk label as its leftmost label The closest encloser of a query name is the longest matching ancestor that exists The source of synthesis of a query name is the domain name *<closest encloser>, which may or may not exist Karst Koymans (UvA) DNS Friday, September 11, 2015 34 / 41

Wildcards RFC 4592 example $ORIGIN example example 3600 IN SOA <SOA RDATA> example 3600 NS nsexamplecom example 3600 NS nsexamplenet *example 3600 TXT "this is a wildcard" *example 3600 MX 10 host1example sub*example 3600 TXT " not a wildcard" host1example 3600 A 192021 host1example 3600 < RDATA> host2example 3600 < RDATA> subdelexample 3600 NS nsexamplecom subdelexample 3600 NS nsexamplenet Karst Koymans (UvA) DNS Friday, September 11, 2015 35 / 41

Wildcards RFC 4592 example tree example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host3example MX example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host3example MX yes RDATA example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result foobarexample TXT example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result foobarexample TXT yes RDATA example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host1example MX example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host1example MX no NoData example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host3example A example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result host3example A yes NoData example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result sub*example MX example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result sub*example MX no NoData example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result telnet host1example example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result telnet host1example no NXDOMAIN example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result hostsubdelexample A example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result hostsubdelexample A no referral example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result ghost*example MX example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example tree QNAME QTYPE Synthesized? Result ghost*example MX no NXDOMAIN example SOA, NS * TXT, MX host1 A host2 subdel NS sub TXT Karst Koymans (UvA) DNS Friday, September 11, 2015 36 / 41

Wildcards RFC 4592 example queries QNAME QTYPE Synthesized? Result host3example MX yes RDATA host3example A yes NoData foobarexample TXT yes RDATA host1example MX no NoData sub*example MX no NoData telnet host1example no NXDOMAIN hostsubdelexample A no referral ghost*example MX no NXDOMAIN Karst Koymans (UvA) DNS Friday, September 11, 2015 37 / 41

Limitations and extras Outline 1 DNS on the wire 2 Encoding of domain names 3 Zone transfers 4 Wildcards 5 Limitations and extras Karst Koymans (UvA) DNS Friday, September 11, 2015 38 / 41

Limitations and extras DNS limitations DNS is usually based on UDP RFC 1035 maximum size is 512 bytes of DNS content Option to use TCP was present from the start but was not recommended for ordinary use DNS has weak security DNS packets can easily be spoofed Initially no support for message authentication except for a clear text Transaction ID Karst Koymans (UvA) DNS Friday, September 11, 2015 39 / 41

Limitations and extras Message Authentication TSIG mechanism added in RFC 2845/4635 calculates HMAC-MD5/SHA over the complete DNS packet adds this as a pseudo -TSIG-RR uses secret keys may use a pseudo -TKEY-RR for key exchange (RFC 2930) SIG(0) mechanism added in RFC 2931 uses public keys uses DNSSEC mechanisms extends DNSSEC to cover complete DNS packets Karst Koymans (UvA) DNS Friday, September 11, 2015 40 / 41

Limitations and extras Extension Mechanisms for DNS (EDNS0) EDNS0 was first specified in RFC 2671, now replaced by RFC 6891 Extends maximum size of UDP-based requests and responses Extends result codes, possible flags and label types Used by DNSSEC for DO (DNSSEC OK) extended flag Uses a pseudo -OPT-RR TYPE 41 CLASS reused for UDP message size TTL reused for extended result codes and flags Karst Koymans (UvA) DNS Friday, September 11, 2015 41 / 41