Skip to content

Commit 3dff013

Browse files
committed
Make paragraphs flow better
1 parent a8d3418 commit 3dff013

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

draft-denis-dprive-dnscrypt.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ The DNSCrypt protocol is designed to encrypt and authenticate DNS traffic betwee
2929

3030
# Introduction
3131

32-
The Domain Name System (DNS) {{!RFC1035}} is a critical component of Internet infrastructure, but its original design did not include security features to protect the confidentiality and integrity of queries and responses. This document defines the DNSCrypt protocol, which encrypts and authenticates DNS queries and responses, improving confidentiality, integrity, and resistance to attacks affecting the original DNS protocol.
32+
The Domain Name System (DNS) {{!RFC1035}} is a critical component of Internet infrastructure, but its original design did not include security features to protect the confidentiality and integrity of queries and responses. This fundamental security gap exposes DNS traffic to eavesdropping, tampering, and various attacks that can compromise user privacy and network security.
3333

34-
The protocol is designed to be lightweight, extensible, and simple to implement securely on top of an existing DNS client, server or proxy. It provides a standardized approach to securing DNS communications while maintaining compatibility with existing DNS infrastructure.
34+
To address these vulnerabilities, this document defines the DNSCrypt protocol, which encrypts and authenticates DNS queries and responses, providing strong confidentiality, integrity, and resistance to attacks affecting the original DNS protocol. The protocol is designed to be lightweight, extensible, and simple to implement securely on top of existing DNS infrastructure, offering a practical solution for securing DNS communications without requiring significant changes to current systems.
35+
36+
The following sections detail the protocol's design, starting with an overview of its operation and then progressing through the technical specifications needed for implementation.
3537

3638
# Conventions And Definitions
3739

@@ -93,7 +95,7 @@ The initial setup phase (steps 1-2) occurs only when:
9395

9496
After the initial setup, the client and server engage in the ongoing communication phase (steps 3-8), where encrypted queries and responses are exchanged as needed. This phase can be repeated indefinitely until the certificate expires or a new certificate is available.
9597

96-
Key characteristics of the ongoing communication phase:
98+
The ongoing communication phase operates with several important characteristics that distinguish it from traditional DNS:
9799

98100
1. **Stateless Operation**: Each query and response is independent. The server does not maintain state between queries.
99101

@@ -103,8 +105,12 @@ Key characteristics of the ongoing communication phase:
103105

104106
4. **Asynchronous Communication**: The protocol does not require strict request-response pairing. A client can send multiple queries before receiving responses, and responses can be processed as they arrive.
105107

108+
With this understanding of the protocol flow, we can now examine the specific components that make up DNSCrypt packets and their structure.
109+
106110
# Protocol Components
107111

112+
The DNSCrypt protocol defines specific packet structures for both client queries and server responses. These components work together to provide the security properties described in the previous section.
113+
108114

109115
Definitions for client queries:
110116

@@ -176,11 +182,13 @@ The following diagram shows the structure of a DNSCrypt response packet:
176182
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177183
~~~
178184

185+
These packet structures form the foundation for the protocol operations described in the next section, which details how clients and servers use these components to establish secure communications.
186+
179187
# Protocol Description
180188

181189
## Overview
182190

183-
The DNSCrypt protocol operates through the following steps:
191+
Building on the protocol flow and components described earlier, this section provides a detailed examination of how the DNSCrypt protocol operates. The protocol follows a well-defined sequence of steps:
184192

185193
1. The DNSCrypt client sends a DNS query to a DNSCrypt server to retrieve the server's public keys.
186194
2. The client generates its own key pair.
@@ -197,13 +205,17 @@ Key features of the DNSCrypt protocol include:
197205
- Shared infrastructure: Recursive DNS servers can accept DNSCrypt queries on the same IP address and port used for regular DNS traffic.
198206
- Attack mitigation: DNSCrypt mitigates two common security vulnerabilities in regular DNS over UDP: amplification {{!RFC5358}} and fragmentation attacks.
199207

208+
These key features enable DNSCrypt to provide robust security while maintaining practical deployability. The protocol's transport characteristics further support these goals.
209+
200210
## Transport
201211

202212
The DNSCrypt protocol can use the UDP and TCP transport protocols.
203213
DNSCrypt clients and resolvers SHOULD support the protocol via UDP, and MUST support it over TCP.
204214

205215
Both TCP and UDP connections using DNSCrypt SHOULD employ port 443 by default.
206216

217+
The choice of port 443 helps DNSCrypt traffic blend with HTTPS traffic, providing some protection against traffic analysis. Once transport is established, the next step is session establishment through certificate exchange.
218+
207219
## Session Establishment
208220

209221
From the client's perspective, a DNSCrypt session is initiated when the client sends an unauthenticated DNS query to a DNSCrypt-capable resolver. This DNS query contains encoded information about the certificate versions supported by the client and a public identifier of the desired provider.
@@ -218,6 +230,8 @@ The encryption algorithm, resolver public key, and client magic number from the
218230

219231
With the knowledge of the chosen certificate and corresponding secret key, along with the client's public key, the resolver is able to verify, decrypt the query, and then encrypt the response utilizing identical parameters.
220232

233+
Once the session is established through certificate exchange, the ongoing query processing follows specific rules for different transport protocols and padding requirements.
234+
221235
## Query Processing
222236

223237
### Padding For Client Queries Over UDP
@@ -254,6 +268,8 @@ If the response has the TC flag set, the client MUST:
254268

255269
The client MAY decrease `<min-query-len>`, but the length MUST remain a multiple of 64 bytes.
256270

271+
While UDP queries require careful length management due to truncation concerns, TCP queries follow different padding rules due to the reliable nature of the transport.
272+
257273
### Padding For Client Queries Over TCP
258274

259275
Queries MUST undergo padding using the ISO/IEC 7816-4 format before being encrypted. The padding starts with a byte valued `0x80` followed by a variable number of NUL bytes.
@@ -286,6 +302,8 @@ Unlike UDP queries, a query sent over TCP can be shorter than the response.
286302

287303
After having received a response from the resolver, the client and the resolver MUST close the TCP connection to ensure security and comply with this revision of the protocol, which prohibits multiple transactions over the same TCP connection.
288304

305+
The query processing rules described above depend on the certificate information obtained during session establishment. The certificate format and management procedures are critical to the protocol's security.
306+
289307
## Certificates
290308

291309
The following diagram shows the structure of a DNSCrypt certificate:
@@ -381,12 +399,16 @@ or
381399

382400
- A certificate with a higher serial number than the current one is available.
383401

402+
The certificate management system ensures that cryptographic keys remain fresh and that clients can smoothly transition to updated certificates. With the core protocol mechanics now established, we can examine implementation considerations.
403+
384404
# Implementation Status
385405

386406
*Note: This section is to be removed before publishing as an RFC.*
387407

388408
Multiple implementations of the protocol described in this document have been developed and verified for interoperability. A comprehensive list of known implementations can be found at [](https://dnscrypt.info/implementations).
389409

410+
The successful deployment of multiple interoperable implementations demonstrates the protocol's maturity. However, proper implementation requires careful attention to security considerations.
411+
390412
# Security Considerations
391413

392414
This section discusses security considerations for the DNSCrypt protocol.
@@ -403,6 +425,8 @@ The DNSCrypt protocol provides several security benefits:
403425

404426
4. **Forward Secrecy**: Short-term key pairs are used for each session, providing forward secrecy. Even if a long-term key is compromised, past communications remain secure.
405427

428+
These fundamental security properties depend on correct implementation practices. Several implementation-specific security aspects require particular attention.
429+
406430
## Implementation Security
407431

408432
Implementations should consider the following security aspects:
@@ -430,6 +454,8 @@ Implementations should consider the following security aspects:
430454
- Clients MUST prefer certificates with higher serial numbers
431455
- Example: A client might cache valid certificates and check for updates hourly
432456

457+
Proper implementation of these security measures provides the foundation for the protocol's attack mitigation capabilities.
458+
433459
## Attack Mitigation
434460

435461
DNSCrypt provides protection against several types of attacks:
@@ -442,6 +468,8 @@ DNSCrypt provides protection against several types of attacks:
442468

443469
4. **Replay Attacks**: The use of nonces and timestamps helps prevent replay attacks. A replayed query would be detected due to nonce reuse.
444470

471+
While DNSCrypt effectively mitigates these attacks, implementers should also be aware of privacy considerations that extend beyond basic protocol security.
472+
445473
## Privacy Considerations
446474

447475
While DNSCrypt encrypts DNS traffic, there are some privacy considerations:
@@ -452,6 +480,8 @@ While DNSCrypt encrypts DNS traffic, there are some privacy considerations:
452480

453481
3. **Certificate Requests**: Initial certificate requests are unencrypted and may reveal client capabilities. This is a one-time exposure per session.
454482

483+
These privacy considerations complement the security measures and should inform operational practices for DNSCrypt deployments.
484+
455485
## Operational Security
456486

457487
Operators should consider:
@@ -476,6 +506,8 @@ Operators should consider:
476506
- Unusual query patterns
477507
- Certificate request anomalies
478508

509+
These operational security practices work together with the technical security measures to provide comprehensive protection. Additional operational considerations extend beyond security to include practical deployment aspects.
510+
479511
# Operational Considerations
480512

481513
Special attention should be paid to the uniqueness of the generated secret keys.
@@ -492,10 +524,14 @@ Provider public keys MAY be published as DNSSEC-signed `TXT` records {{!RFC1035}
492524

493525
As a client is likely to reuse the same key pair many times, servers are encouraged to cache shared keys instead of performing the X25519 operation for each query. This makes the computational overhead of DNSCrypt negligible compared to plain DNS.
494526

527+
While DNSCrypt provides strong encryption and authentication, some use cases require additional privacy protection. The Anonymized DNSCrypt extension addresses scenarios where hiding client IP addresses from resolvers is necessary.
528+
495529
# Anonymized DNSCrypt
496530

497531
While DNSCrypt encrypts DNS traffic, DNS server operators can still observe client IP addresses. Anonymized DNSCrypt is an extension to the DNSCrypt protocol that allows queries and responses to be relayed by an intermediate server, hiding the client's IP address from the resolver.
498532

533+
This extension maintains all the security properties of standard DNSCrypt while adding an additional layer of privacy protection.
534+
499535
## Protocol Overview
500536

501537
Anonymized DNSCrypt works by having the client send encrypted queries to a relay server, which then forwards them to the actual DNSCrypt resolver. The relay server cannot decrypt the queries or responses, and the resolver only sees the relay's IP address.
@@ -575,6 +611,8 @@ Relays MUST:
575611
- Validate the response format (either starts with resolver magic or is a certificate response)
576612
- Forward valid responses unmodified to the client
577613

614+
These relay requirements ensure that anonymization does not compromise the security properties of the underlying DNSCrypt protocol. Proper deployment requires additional operational considerations.
615+
578616
## Operational Considerations
579617

580618
When using Anonymized DNSCrypt:
@@ -586,6 +624,8 @@ When using Anonymized DNSCrypt:
586624
- Restrict allowed server ports (typically only allowing port 443)
587625
- Monitor for abuse
588626

627+
These operational guidelines help ensure that Anonymized DNSCrypt deployments provide the intended privacy benefits while maintaining security and preventing abuse.
628+
589629
# IANA Considerations
590630

591631
This document has no IANA actions.

0 commit comments

Comments
 (0)