Skip to content

Latest commit

 

History

History
602 lines (456 loc) · 22.4 KB

draft-ietf-doh-dns-over-https-latest.mkd

File metadata and controls

602 lines (456 loc) · 22.4 KB

title: DNS Queries over HTTPS abbrev: DNS Queries over HTTPS docname: draft-ietf-doh-dns-over-https

stand_alone: true

ipr: trust200902 area: Art kw: Internet-Draft cat: std

pi: toc: yes tocdepth: 4 sortrefs: yes symrefs: yes

author:

ins: P. Hoffman name: Paul Hoffman org: ICANN email: paul.hoffman@icann.org

ins: P. McManus name: Patrick McManus org: Mozilla email: pmcmanus@mozilla.com

normative: RFC1035: RFC2119: RFC4648: RFC5246: RFC6960: RFC6961: RFC7230: RFC7234: RFC7540: RFC7541:

informative: I-D.ietf-dnsop-dns-wireformat-http: RFC2181: RFC5861: RFC6147: RFC6891: RFC6950: RFC7719: CORS: title: "Cross-Origin Resource Sharing" target: "https://fetch.spec.whatwg.org/#http-cors-protocol"

--- abstract

DNS queries sometimes experience problems with end to end connectivity at times and places where HTTPS flows freely.

HTTPS provides the most practical mechanism for reliable end to end communication. Its use of TLS provides integrity and confidentiality guarantees and its use of HTTP allows it to interoperate with proxies, firewalls, and authentication systems where required for transit.

This document describes how to run DNS service over HTTP using https:// URIs.

[[ There is a repository for this draft at https://github.com/dohwg/draft-ietf-doh-dns-over-https ]].

--- middle

Introduction

The Internet does not always provide end to end reachability for native DNS. On-path network devices may spoof DNS responses, block DNS requests, or just redirect DNS queries to different DNS servers that give less-than-honest answers.

Over time, there have been many proposals for using HTTP and HTTPS as a substrate for DNS queries and responses. To date, none of those proposals have made it beyond early discussion, partially due to disagreement about what the appropriate formatting should be and partially because they did not follow HTTP best practices.

This document defines a specific protocol for sending DNS {{RFC1035}} queries and getting DNS responses over HTTP {{RFC7540}} using https:// (and therefore TLS {{RFC5246}} security for integrity and confidentiality). Each DNS query-response pair is mapped into a HTTP request-response pair.

The described approach is more than a tunnel over HTTP. It establishes default media formatting types for requests and responses but uses normal HTTP content negotiation mechanisms for selecting alternatives that endpoints may prefer in anticipation of serving new use cases. In addition to this media type negotiation, it aligns itself with HTTP features such as caching, proxying, and compression.

The integration with HTTP provides a transport suitable for both traditional DNS clients and native web applications seeking access to the DNS.

Terminology

A server that supports this protocol is called a "DNS API server" to differentiate it from a "DNS server" (one that uses the regular DNS protocol). Similarly, a client that supports this protocol is called a "DNS API client".

In this document, the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in BCP 14, RFC 2119 {{RFC2119}}.

Use Cases

There are two initial use cases for this protocol.

The primary use case is to prevent on-path network devices from interfering with DNS operations. This interference includes, but is not limited to, spoofing DNS responses, blocking DNS requests, and tracking.

In this use, clients -- whether operating systems or individual applications -- will be explicitly configured to use a DOH server as a recursive resolver by its user (or administrator). They might use the DOH server for all queries, or only for a subset of them. The specific configuration mechanism is out of scope for this document.

A secondary use case is allowing web applications to access DNS information, by using existing APIs in browsers to access it over HTTP in a safe way consistent with Cross Origin Resource Sharing (CORS) {{CORS}}.

This is technically already possible (since the server controls both the HTTP resources it exposes and the use of browser APIs by its content), but standardization might make this easier to accomplish.

Note that in this second use, the browser does not consult the DOH server or use its responses for any DNS lookups outside the scope of the application using them; i.e., there is (currently) no API that allows a Web site to poison DNS for others.

[[ This paragraph is to be removed when this document is published as an RFC ]] Note that these use cases are different than those in a similar protocol described at {{I-D.ietf-dnsop-dns-wireformat-http}}. The use case for that protocol is proxying DNS queries over HTTP instead of over DNS itself. The use cases in this document all involve query origination instead of proxying.

Protocol Requirements

The protocol described here bases its design on the following protocol requirements:

  • The protocol must use normal HTTP semantics.

  • The queries and responses must be able to be flexible enough to express every normal DNS query.

  • The protocol must allow implementations to use HTTP's content negotiation mechanism.

  • The protocol must ensure interoperable media formats through a mandatory to implement format wherein a query must be able to contain future modifications to the DNS protocol including the inclusion of one or more EDNS extensions (including those not yet defined).

  • The protocol must use a secure transport that meets the requirements for HTTPS.

Non-requirements

  • Supporting network-specific DNS64 {{RFC6147}}

  • Supporting other network-specific inferences from plaintext DNS queries

  • Supporting insecure HTTP

  • Supporting legacy HTTP versions

The HTTP Request

To make a DNS API query a DNS API client encodes a single DNS query into an HTTP request using either the HTTP GET or POST method and the other requirements of this section. The DNS API server defines the URI used by the request. Configuration and discovery of the URI is done out of band from this protocol.

When using the POST method the DNS query is included as the message body of the HTTP request and the Content-Type request header indicates the media type of the message. POST-ed requests are smaller than their GET equivalents.

When using the GET method the URI path MUST contain a query parameter with the name of "ct" and a value indicating the media-format used for the dns parameter. The value may either be an explicit media type (e.g. ct=application/dns-udpwireformat&dns=...) or it may be empty. An empty value indicates the default application/dns-udpwireformat type (e.g. ct&dns=...).

When using the GET method the URI path MUST contain a query parameter with the name of "dns". The value of the parameter is the content of the request potentially encoded with base64url {{RFC4648}}. Specifications that define media types for use with DOH, such as DNS Wire Format {{dnswire}} of this document, MUST indicate if the body parameter uses base64url encoding.

Using the GET method is friendlier to many HTTP cache implementations.

The DNS API Client SHOULD include an HTTP "Accept:" request header to say what type of content can be understood in response. The client MUST be prepared to process "application/dns-udpwireformat" {{dnswire}} responses but MAY process any other type it receives.

In order to maximize cache friendliness, DNS API clients using media formats that include DNS ID, such as application/dns-udpwireformat, SHOULD use a DNS ID of 0 in every DNS request. HTTP correlates request and response, thus eliminating the need for the ID in a media type such as application/dns-udpwireformat and the use of a varying DNS ID can cause semantically equivalent DNS queries to be cached separately.

DNS API clients can use HTTP/2 padding and compression in the same way that other HTTP/2 clients use (or don't use) them.

DNS Wire Format {#dnswire}

The media type is "application/dns-udpwireformat".

The body is the DNS on-the-wire format defined in {{RFC1035}}.

When using the GET method, the body MUST be encoded with base64url {{RFC4648}} and then placed as a name value pair in the query portion of the URI with name "dns". Padding characters for base64url MUST NOT be included.

When using the POST method, the body MUST NOT be encoded.

DNS API clients using the DNS wire format MAY have one or more EDNS extensions {{RFC6891}} in the request.

Examples

These examples use HTTP/2 style formatting from {{RFC7540}}.

These examples use a DNS API service located at https://dnsserver.example.net/dns-query to resolve the IN A records.

The requests are represented as application/dns-udpwirefomat typed bodies, but the client indicates it can parse responses in either that format or as a hypothetical JSON-based content type. The application/simpledns+json type used by this example is currently fictitious.

The first example request uses GET to request www.example.com

:method = GET
:scheme = https
:authority = dnsserver.example.net
:path = /dns-query?ct& (no space or CR)
        dns=AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB
accept = application/dns-udpwireformat, application/simpledns+json

The same DNS query for www.example.com, using the POST method would be:

:method = POST
:scheme = https
:authority = dnsserver.example.net
:path = /dns-query
accept = application/dns-udpwireformat, application/simpledns+json
content-type = application/dns-udpwireformat
content-length = 33

<33 bytes represented by the following hex encoding>
00 00 01 00 00 01 00 00  00 00 00 00 03 77 77 77
07 65 78 61 6d 70 6c 65  03 63 6f 6d 00 00 01 00
01

Finally, a GET based query for a.62characterlabel-makes-base64url-distinct-from-standard-base64.example.com is shown as an example to emphasize that the encoding alphabet of base64url is different than regular base64 and that padding is omitted.

The DNS query is 94 bytes represented by the following hex encoding


00 00 01 00 00 01 00 00  00 00 00 00 01 61 3e 36
32 63 68 61 72 61 63 74  65 72 6c 61 62 65 6c 2d
6d 61 6b 65 73 2d 62 61  73 65 36 34 75 72 6c 2d
64 69 73 74 69 6e 63 74  2d 66 72 6f 6d 2d 73 74
61 6e 64 61 72 64 2d 62  61 73 65 36 34 07 65 78
61 6d 70 6c 65 03 63 6f  6d 00 00 01 00 01      

:method = GET
:scheme = https
:authority = dnsserver.example.net
:path = /dns-query?ct& (no space or CR)
        dns=AAABAAABAAAAAAAAAWE-NjJjaGFyYWN0ZXJsYWJl (no space or CR)
        bC1tYWtlcy1iYXNlNjR1cmwtZGlzdGluY3QtZnJvbS1z (no space or CR)
        dGFuZGFyZC1iYXNlNjQHZXhhbXBsZQNjb20AAAEAAQ
accept = application/dns-udpwireformat, application/simpledns+json

The HTTP Response

Different response media types will provide more or less information from a DNS response. For example, one response type might include the information from the DNS header bytes while another might omit it. The amount and type of information that a media type gives is solely up to the format, and not defined in this protocol.

At the time this is published, the response types are works in progress. The only response type defined in this document is "application/dns-udpwireformat", but it is possible that at least one JSON-based response format will be defined in the future.

The DNS response for "application/dns-udpwireformat" in {{dnswire}} MAY have one or more EDNS extensions, depending on the extension definition of the extensions given in the DNS request.

Each DNS request-response pair is matched to one HTTP request-response pair. The responses may be processed and transported in any order using HTTP's multi-streaming functionality ({{RFC7540}} Section 5}).

The Answer section of a DNS response contains one or more RRsets. (RRsets are defined in {{RFC7719}}.) According to {{RFC2181}}, each resource record in an RRset is supposed to have the Time To Live (TTL) freshness information. Different RRsets in the Answer section can have different TTLs, though it is only possible for the HTTP response to have a single freshness lifetime. The HTTP response freshness lifetime ({{RFC7234}} Section 4.2) should be coordinated with the Resource Record bearing the smallest TTL in the Answer section of the response. Specifically, the HTTP freshness lifetime SHOULD be set to expire at the same time any of the DNS Records reach a 0 TTL. The response freshness lifetime MUST NOT be greater than that indicated by the DNS Record with the smallest TTL in the response.

A DNS API Client that receives a response without an explicit freshness lifetime MUST NOT assign that response a heuristic freshness ({{RFC7234}} Section 4.2.2.) greater than that indicated by the DNS Record with the smallest TTL in the response.

A DNS API Server MUST be able to process application/dns-udpwireformat request messages.

A DNS API Server SHOULD respond with HTTP status code 415 (Unsupported Media Type) upon receiving a media type it is unable to process.

This document does not change the definition of any HTTP response codes or otherwise proscribe their use.

Example

This is an example response for a query for the IN A records for "www.example.com" with recursion turned on. The response bears one record with an address of 192.0.2.1 and a TTL of 128 seconds.

:status = 200
content-type = application/dns-udpwireformat
content-length = 64
cache-control = max-age=128

<64 bytes represented by the following hex encoding>
00 00 81 80 00 01 00 01  00 00 00 00 03 77 77 77
07 65 78 61 6d 70 6c 65  03 63 6f 6d 00 00 01 00
01 03 77 77 77 07 65 78  61 6d 70 6c 65 03 63 6f
6d 00 00 01 00 01 00 00  00 80 00 04 C0 00 02 01

HTTP Integration

This protocol MUST be used with the https scheme URI {{RFC7230}}.

Cache Interaction

A DOH API Client may utilize a hierarchy of caches that include both HTTP and DNS specific caches. HTTP cache entries may be bypassed with HTTP mechanisms such as the Cache-Control no-cache directive however DNS caches do not have a similar mechanism.

A DOH response that was previously stored in an HTTP cache will contain the {{RFC7234}} Age response header indicating the elapsed time between when the entry was placed in the HTTP cache and the current DOH response. DNS API clients should subtract this time from the DNS TTL if they are re-sharing the information in a non HTTP context (e.g. their own DNS cache) to determine the remaining time to live of the DNS record.

HTTP revalidation (e.g. via If-None-Match request headers) of cached DNS information may be of limited value to DOH as revalidation provides only a bandwidth benefit and DNS transactions are normally latency bound. Furthermore, the HTTP response headers that enable revalidation (such as "Last-Modified" and "Etag") are often fairly large when compared to the overall DNS response size, and have a variable nature that creates constant pressure on the HTTP/2 compression dictionary {{RFC7541}}. Other types of DNS data, such as zone transfers, may be larger and benefit more from revalidation. DNS API servers may wish to consider whether providing these validation enabling response headers is worthwhile.

The stale-while-revalidate and stale-if-error cache control directives may be well suited to a DOH implementation when allowed by server policy. Those mechanisms allow a client, at the server's discretion, to reuse a cache entry that is no longer fresh under some extenuating circumstances defined in {{RFC5861}}.

All HTTP servers, including DNS API servers, need to consider cache interaction when they generate responses that are not globally valid. For instance, if a DNS API server customized a response based on the client's identity then it would not want to globally allow reuse of that response. This could be accomplished through a variety of HTTP techniques such as a Cache-Control max-age of 0, or perhaps by the Vary response header.

HTTP/2

The minimum version of HTTP used by DOH SHOULD be HTTP/2 {{RFC7540}}.

The messages in classic UDP based DNS {{RFC1035}} are inherently unordered and have low overhead. A competitive HTTP transport needs to support reordering, parallelism, priority, and header compression to achieve similar performance. Those features were introduced to HTTP in HTTP/2 {{RFC7540}}. Earlier versions of HTTP are capable of conveying the semantic requirements of DOH but may result in very poor performance for many uses cases.

Server Push

Before using DOH response data for DNS resolution, the client MUST establish that the HTTP request URI is a trusted service for the DOH query. For HTTP requests initiated by the DNS API client this trust is implicit in the selection of URI. For HTTP server push ({{RFC7540}} Section 8.2) extra care must be taken to ensure that the pushed URI is one that the client would have directed the same query to if the client had initiated the request. This specification does not extend DNS resolution privileges to URIs that are not recognized by the client as trusted DNS API servers.

IANA Considerations {#iana}

Registration of application/dns-udpwireformat Media Type

To: ietf-types@iana.org
Subject: Registration of MIME media type
         application/dns-udpwireformat

MIME media type name: application

MIME subtype name: dns-udpwireformat

Required parameters: n/a

Optional parameters: n/a

Encoding considerations: This is a binary format. The contents are a
DNS message as defined in RFC 1035. The format used here is for DNS
over UDP, which is the format defined in the diagrams in RFC 1035.

Security considerations:  The security considerations for carrying
this data are the same for carrying DNS without encryption.

Interoperability considerations:  None.

Published specification:  This document.

Applications that use this media type:
  Systems that want to exchange full DNS messages.

Additional information:

Magic number(s):  n/a

File extension(s):  n/a

Macintosh file type code(s):  n/a

Person & email address to contact for further information:
   Paul Hoffman, paul.hoffman@icann.org

Intended usage:  COMMON

Restrictions on usage:  n/a

Author:  Paul Hoffman, paul.hoffman@icann.org

Change controller:  IESG

Security Considerations {#Security}

Running DNS over HTTPS relies on the security of the underlying HTTP transport. Implementations utilizing HTTP/2 benefit from the TLS profile defined in {{RFC7540}} Section 9.2.

Session level encryption has well known weaknesses with respect to traffic analysis which might be particularly acute when dealing with DNS queries. Sections 10.6 (Compression) and 10.7 (Padding) of {{RFC7540}} provide some further advice on mitigations within an HTTP/2 context.

The HTTPS connection provides transport security for the interaction between the DNS API server and client, but does not inherently ensure the authenticity of DNS data. A DNS API client may also perform full DNSSEC validation of answers received from a DNS API server or it may choose to trust answers from a particular DNS API server, much as a DNS client might choose to trust answers from its recursive DNS resolver.

[[ From the WG charter:

The working group will analyze the security and privacy issues that could arise from accessing DNS over HTTPS. In particular, the working group will consider the interaction of DNS and HTTP caching.

]]

A server that is acting both as a normal web server and a DNS API server is in a position to choose which DNS names it forces a client to resolve (through its web service) and also be the one to answer those queries (through its DNS API service). An untrusted DNS API server can thus easily cause damage by poisoning a client's cache with names that the DNS API server chooses to poison. A client MUST NOT trust a DNS API server simply because it was discovered, or because the client was told to trust the DNS API server by an untrusted party. Instead, a client MUST only trust DNS API server that is configured as trustworthy.

[[ From the WG charter:

The working group may define mechanisms for discovery of DOH servers similar to existing mechanisms for discovering other DNS servers if the chairs determine that there is both sufficient interest and working group consensus.

]]

Operational Considerations

Local policy considerations and similar factors mean different DNS servers may provide different results to the same query: for instance in split DNS configurations {{RFC6950}}. It logically follows that the server which is queried can influence the end result. Therefore a client’s choice of DNS server may affect the responses it gets to its queries.

The HTTPS channel used by this specification establishes secure two party communication between the DNS API Client and the DNS API Server. Filtering or inspection systems that rely on unsecured transport of DNS will not function in a DNS over HTTPS environment.

Many HTTPS implementations perform real time third party checks of the revocation status of the certificates being used by TLS. If this check is done as part of the DNS API server connection procedure and the check itself requires DNS resolution to connect to the third party a deadlock can occur. The use of an OCSP {{RFC6960}} server is one example of how this can happen. DNS API servers SHOULD utilize OCSP Stapling {{RFC6961}} to provide the client with certificate revocation information that does not require contacting a third party.

A DNS API client may face a similar bootstrapping problem when the HTTP request needs to resolve the hostname portion of the DNS URI. Just as the address of a traditional DNS nameserver cannot be originally determined from that same server, a DOH client cannot use its DOH server to initially resolve the server's host name into an address. Alternative strategies a client might employ include making the initial resolution part of the configuration, IP based URIs and corresponding IP based certificates for HTTPS, or resolving the DNS API Server's hostname via traditional DNS or another DOH server while still authenticating the resulting connection via HTTPS.

Acknowledgments

Joe Hildebrand contributed lots of material for a different iteration of this document. Helpful early comments were given by Ben Schwartz and Mark Nottingham.

--- back

Previous Work on DNS over HTTP or in Other Formats

The following is an incomplete list of earlier work that related to DNS over HTTP/1 or representing DNS data in other formats.

The list includes links to the tools.ietf.org site (because these documents are all expired) and web sites of software.