draft-ietf-masque-connect-udp-09.txt   draft-ietf-masque-connect-udp-10.txt 
MASQUE D. Schinazi MASQUE D. Schinazi
Internet-Draft Google LLC Internet-Draft Google LLC
Intended status: Standards Track 11 April 2022 Intended status: Standards Track 18 April 2022
Expires: 13 October 2022 Expires: 20 October 2022
UDP Proxying Support for HTTP Proxying UDP in HTTP
draft-ietf-masque-connect-udp-09 draft-ietf-masque-connect-udp-10
Abstract Abstract
This document describes how to proxy UDP over HTTP. Similar to how This document describes how to proxy UDP in HTTP, similar to how the
the CONNECT method allows proxying TCP over HTTP, this document HTTP CONNECT method allows proxying TCP in HTTP. More specifically,
defines a new mechanism to proxy UDP. When using HTTP/2 or HTTP/3, this document defines a protocol that allows HTTP clients to create a
it uses Extended CONNECT; when using HTTP/1.1, it uses Upgrade. tunnel for UDP communications through an HTTP server that acts as a
proxy.
About This Document About This Document
This note is to be removed before publishing as an RFC. This note is to be removed before publishing as an RFC.
The latest revision of this draft can be found at https://ietf-wg- The latest revision of this draft can be found at https://ietf-wg-
masque.github.io/draft-ietf-masque-connect-udp/draft-ietf-masque- masque.github.io/draft-ietf-masque-connect-udp/draft-ietf-masque-
connect-udp.html. Status information for this document may be found connect-udp.html. Status information for this document may be found
at https://datatracker.ietf.org/doc/draft-ietf-masque-connect-udp/. at https://datatracker.ietf.org/doc/draft-ietf-masque-connect-udp/.
skipping to change at page 1, line 48 skipping to change at page 2, line 4
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on 20 October 2022.
This Internet-Draft will expire on 13 October 2022.
Copyright Notice Copyright Notice
Copyright (c) 2022 IETF Trust and the persons identified as the Copyright (c) 2022 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/ Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components and restrictions with respect to this document. Code Components
extracted from this document must include Revised BSD License text as extracted from this document must include Revised BSD License text as
described in Section 4.e of the Trust Legal Provisions and are described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Revised BSD License. provided without warranty as described in the Revised BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Conventions and Definitions . . . . . . . . . . . . . . . 3 1.1. Conventions and Definitions . . . . . . . . . . . . . . . 3
2. Configuration of Clients . . . . . . . . . . . . . . . . . . 3 2. Client Configuration . . . . . . . . . . . . . . . . . . . . 3
3. HTTP Exchanges . . . . . . . . . . . . . . . . . . . . . . . 4 3. Tunnelling UDP over HTTP . . . . . . . . . . . . . . . . . . 4
3.1. Proxy Handling . . . . . . . . . . . . . . . . . . . . . 5 3.1. UDP Proxy Handling . . . . . . . . . . . . . . . . . . . 5
3.2. HTTP Request over HTTP/1.1 . . . . . . . . . . . . . . . 6 3.2. HTTP/1.1 Request . . . . . . . . . . . . . . . . . . . . 6
3.3. HTTP Response over HTTP/1.1 . . . . . . . . . . . . . . . 7 3.3. HTTP/1.1 Response . . . . . . . . . . . . . . . . . . . . 7
3.4. HTTP Request over HTTP/2 and HTTP/3 . . . . . . . . . . . 7 3.4. HTTP/2 and HTTP/3 Requests . . . . . . . . . . . . . . . 7
3.5. HTTP Response over HTTP/2 and HTTP/3 . . . . . . . . . . 8 3.5. HTTP/2 and HTTP/3 Responses . . . . . . . . . . . . . . . 8
3.6. Note About Draft Versions . . . . . . . . . . . . . . . . 8 3.6. Note About Draft Versions . . . . . . . . . . . . . . . . 8
4. Context Identifiers . . . . . . . . . . . . . . . . . . . . . 9 4. Context Identifiers . . . . . . . . . . . . . . . . . . . . . 9
5. HTTP Datagram Payload Format . . . . . . . . . . . . . . . . 9 5. HTTP Datagram Payload Format . . . . . . . . . . . . . . . . 10
6. Performance Considerations . . . . . . . . . . . . . . . . . 10 6. Performance Considerations . . . . . . . . . . . . . . . . . 11
6.1. MTU Considerations . . . . . . . . . . . . . . . . . . . 11 6.1. MTU Considerations . . . . . . . . . . . . . . . . . . . 11
6.2. Tunneling of ECN Marks . . . . . . . . . . . . . . . . . 11 6.2. Tunneling of ECN Marks . . . . . . . . . . . . . . . . . 11
7. Security Considerations . . . . . . . . . . . . . . . . . . . 12 7. Security Considerations . . . . . . . . . . . . . . . . . . . 12
8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 12 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 12
8.1. HTTP Upgrade Token . . . . . . . . . . . . . . . . . . . 12 8.1. HTTP Upgrade Token . . . . . . . . . . . . . . . . . . . 12
8.2. Well-Known URI . . . . . . . . . . . . . . . . . . . . . 13 8.2. Well-Known URI . . . . . . . . . . . . . . . . . . . . . 13
9. References . . . . . . . . . . . . . . . . . . . . . . . . . 13 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 13
9.1. Normative References . . . . . . . . . . . . . . . . . . 13 9.1. Normative References . . . . . . . . . . . . . . . . . . 13
9.2. Informative References . . . . . . . . . . . . . . . . . 15 9.2. Informative References . . . . . . . . . . . . . . . . . 15
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 15 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 16
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 15 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 16
1. Introduction 1. Introduction
This document describes how to proxy UDP over HTTP. Similar to how While HTTP provides the CONNECT method (see Section 9.3.6 of [HTTP])
the CONNECT method (see Section 9.3.6 of [HTTP]) allows proxying TCP for creating a TCP [TCP] tunnel to a proxy, it lacks a method for
[TCP] over HTTP, this document defines a new mechanism to proxy UDP doing so for UDP [UDP] traffic.
[UDP].
UDP Proxying supports all versions of HTTP and uses HTTP Datagrams This document describes a protocol for tunnelling UDP to a server
[HTTP-DGRAM]. When using HTTP/2 [HTTP/2] or HTTP/3 [HTTP/3], UDP acting as a UDP-specific proxy over HTTP. UDP tunnels are commonly
proxying uses HTTP Extended CONNECT as described in [EXT-CONNECT2] used to create an end-to-end virtual connection, which can then be
and [EXT-CONNECT3]. When using HTTP/1.x [HTTP/1.1], UDP proxying secured using QUIC [QUIC] or another protocol running over UDP.
uses HTTP Upgrade as defined in Section 7.8 of [HTTP]. Unlike CONNECT, the UDP proxy itself is identified with an absolute
URL containing the traffic's destination. Clients generate those
URLs using a URI Template [TEMPLATE], as described in Section 2.
This protocol supports all versions of HTTP by using HTTP Datagrams
[HTTP-DGRAM]. When using HTTP/2 [HTTP/2] or HTTP/3 [HTTP/3], it uses
HTTP Extended CONNECT as described in [EXT-CONNECT2] and
[EXT-CONNECT3]. When using HTTP/1.x [HTTP/1.1], it uses HTTP Upgrade
as defined in Section 7.8 of [HTTP].
1.1. Conventions and Definitions 1.1. Conventions and Definitions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in "OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
In this document, we use the term "proxy" to refer to the HTTP server In this document, we use the term "UDP proxy" to refer to the HTTP
that acts upon the client's UDP proxying request to open a UDP socket server that acts upon the client's UDP tunnelling request to open a
to a target server, and generates the response to this request. If UDP socket to a target server, and generates the response to this
there are HTTP intermediaries (as defined in Section 3.7 of [HTTP]) request. If there are HTTP intermediaries (as defined in Section 3.7
between the client and the proxy, those are referred to as of [HTTP]) between the client and the UDP proxy, those are referred
"intermediaries" in this document. to as "intermediaries" in this document.
Note that, when the HTTP version in use does not support multiplexing Note that, when the HTTP version in use does not support multiplexing
streams (such as HTTP/1.1), any reference to "stream" in this streams (such as HTTP/1.1), any reference to "stream" in this
document represents the entire connection. document represents the entire connection.
2. Configuration of Clients 2. Client Configuration
Clients are configured to use UDP Proxying over HTTP via a URI HTTP clients are configured to use a UDP proxy with a URI Template
Template [TEMPLATE] with the variables "target_host" and [TEMPLATE] that has the variables "target_host" and "target_port".
"target_port". Examples are shown below: Examples are shown below:
https://masque.example.org/.well-known/masque/udp/{target_host}/{target_port}/ https://masque.example.org/.well-known/masque/udp/{target_host}/{target_port}/
https://proxy.example.org:4443/masque?h={target_host}&p={target_port} https://proxy.example.org:4443/masque?h={target_host}&p={target_port}
https://proxy.example.org:4443/masque{?target_host,target_port} https://proxy.example.org:4443/masque{?target_host,target_port}
Figure 1: URI Template Examples Figure 1: URI Template Examples
The following requirements apply to the URI Template: The following requirements apply to the URI Template:
* The URI Template MUST be a level 3 template or lower. * The URI Template MUST be a level 3 template or lower.
* The URI Template MUST be in absolute form, and MUST include non- * The URI Template MUST be in absolute form, and MUST include non-
empty scheme, authority and path components. empty scheme, authority and path components.
* The path component of the URI Template MUST start with a slash * The path component of the URI Template MUST start with a slash
"/". "/".
* All template variables MUST be within the path component of the * All template variables MUST be within the path or query components
URI. of the URI.
* The URI template MUST contain the two variables "target_host" and * The URI template MUST contain the two variables "target_host" and
"target_port" and MAY contain other variables. "target_port" and MAY contain other variables.
* The URI Template MUST NOT contain any non-ASCII unicode characters * The URI Template MUST NOT contain any non-ASCII unicode characters
and MUST only contain ASCII characters in the range 0x21-0x7E and MUST only contain ASCII characters in the range 0x21-0x7E
inclusive (note that percent-encoding is allowed). inclusive (note that percent-encoding is allowed).
* The URI Template MUST NOT use Reserved Expansion ("+" operator), * The URI Template MUST NOT use Reserved Expansion ("+" operator),
Fragment Expansion ("#" operator), Label Expansion with Dot- Fragment Expansion ("#" operator), Label Expansion with Dot-
Prefix, Path Segment Expansion with Slash-Prefix, nor Path-Style Prefix, Path Segment Expansion with Slash-Prefix, nor Path-Style
Parameter Expansion with Semicolon-Prefix. Parameter Expansion with Semicolon-Prefix.
If any of the requirements above are not met by a URI Template, the If the client detects that any of the requirements above are not met
client MUST reject its configuration and fail the request without by a URI Template, the client MUST reject its configuration and fail
sending it to the proxy. the request without sending it to the UDP proxy. While clients
SHOULD validate the requirements above, some clients MAY use a
general-purpose URI Template implementation that lacks this specific
validation.
Since the original HTTP CONNECT method allowed conveying the target Since the original HTTP CONNECT method allowed conveying the target
host and port but not the scheme, proxy authority, path, nor query, host and port but not the scheme, proxy authority, path, nor query,
there exist proxy configuration interfaces that only allow the user there exist proxy configuration interfaces that only allow the user
to configure the proxy host and the proxy port. Client to configure the proxy host and the proxy port. Client
implementations of this specification that are constrained by such implementations of this specification that are constrained by such
limitations MAY attempt to access UDP Proxying capabilities using the limitations MAY attempt to access UDP proxying capabilities using the
default template, which is defined as: default template, which is defined as:
"https://$PROXY_HOST:$PROXY_PORT/.well-known/masque/ "https://$PROXY_HOST:$PROXY_PORT/.well-known/masque/
udp/{target_host}/{target_port}/" where $PROXY_HOST and $PROXY_PORT udp/{target_host}/{target_port}/" where $PROXY_HOST and $PROXY_PORT
are the configured host and port of the proxy respectively. Proxy are the configured host and port of the UDP proxy respectively. UDP
deployments SHOULD offer service at this location if they need to proxy deployments SHOULD offer service at this location if they need
interoperate with such clients. to interoperate with such clients.
Clients MAY interpret HTTP 400, 404, or 405 response codes as
indications that the URI template is not correct. Servers MUST NOT
return these response codes if the request is well-formed and the URI
matches a supported template.
3. HTTP Exchanges 3. Tunnelling UDP over HTTP
This document defines the "connect-udp" HTTP Upgrade Token. "connect- To allow negotiation of a tunnel for UDP over HTTP, this document
udp" uses the Capsule Protocol as defined in Section 3.2 of defines the "connect-udp" HTTP Upgrade Token. The resulting UDP
[HTTP-DGRAM]. The format of HTTP Datagrams is defined in Section 5. tunnels use the Capsule Protocol (see Section 3.2 of [HTTP-DGRAM])
with HTTP Datagram in the format defined in Section 5.
Clients issue requests containing a "connect-udp" upgrade token to To initiate a UDP tunnel associated with a single HTTP stream,
initiate a UDP tunnel associated with a single HTTP stream. Tunnels clients issue a request containing the "connect-udp" upgrade token.
are commonly used to create an end-to-end virtual connection, which The target of the tunnel is indicated by the client to the UDP proxy
can then be secured using QUIC [QUIC] or another protocol running via the "target_host" and "target_port" variables of the URI
over UDP. The target of the tunnel is indicated by the client to the Template, see Section 2. If the request is successful, the UDP proxy
proxy via the "target_host" and "target_port" variables of the URI
Template (see Section 2). If the request is successful, the proxy
commits to converting received HTTP Datagrams into UDP packets and commits to converting received HTTP Datagrams into UDP packets and
vice versa until the tunnel is closed. vice versa until the tunnel is closed.
When sending its UDP proxying request, the client SHALL perform URI When sending its UDP proxying request, the client SHALL perform URI
Template expansion to determine the path and query of its request. Template expansion to determine the path and query of its request.
target_host supports using DNS names, IPv6 literals and IPv4 target_host supports using DNS names, IPv6 literals and IPv4
literals. Note that this URI Template expansion requires using pct- literals. Note that this URI Template expansion requires using pct-
encoding, so for example if the target_host is "2001:db8::42", it encoding, so for example if the target_host is "2001:db8::42", it
will be encoded in the URI as "2001%3Adb8%3A%3A42". will be encoded in the URI as "2001%3Adb8%3A%3A42".
By virtue of the definition of the Capsule Protocol (see By virtue of the definition of the Capsule Protocol (see
[HTTP-DGRAM]), UDP proxying requests do not carry any message [HTTP-DGRAM]), UDP proxying requests do not carry any message
content. Similarly, successful UDP proxying responses also do not content. Similarly, successful UDP proxying responses also do not
carry any message content. carry any message content.
Responses to UDP proxying requests are not cacheable. 3.1. UDP Proxy Handling
3.1. Proxy Handling
Upon receiving a UDP proxying request, the recipient proxy extracts Upon receiving a UDP proxying request, the recipient UDP proxy
the "target_host" and "target_port" variables from the URI it has extracts the "target_host" and "target_port" variables from the URI
reconstructed from the request headers, and establishes a tunnel by it has reconstructed from the request headers, and establishes a
directly opening a UDP socket to the requested target. tunnel by directly opening a UDP socket to the requested target.
Unlike TCP, UDP is connection-less. The proxy that opens the UDP Unlike TCP, UDP is connection-less. The UDP proxy that opens the UDP
socket has no way of knowing whether the destination is reachable. socket has no way of knowing whether the destination is reachable.
Therefore it needs to respond to the request without waiting for a Therefore it needs to respond to the request without waiting for a
packet from the target. However, if the target_host is a DNS name, packet from the target. However, if the target_host is a DNS name,
the proxy MUST perform DNS resolution before replying to the HTTP the UDP proxy MUST perform DNS resolution before replying to the HTTP
request. If errors occur during this process (for example, a DNS request. If errors occur during this process (for example, a DNS
resolution failure), the proxy MUST fail the request and SHOULD send resolution failure), the UDP proxy MUST fail the request and SHOULD
details using the Proxy-Status header field [PROXY-STATUS]. send details using an appropriate "Proxy-Status" header field
[PROXY-STATUS].
Proxies can use connected UDP sockets if their operating system UDP proxies can use connected UDP sockets if their operating system
supports them, as that allows the proxy to rely on the kernel to only supports them, as that allows the UDP proxy to rely on the kernel to
send it UDP packets that match the correct 5-tuple. If the proxy only send it UDP packets that match the correct 5-tuple. If the UDP
uses a non-connected socket, it MUST validate the IP source address proxy uses a non-connected socket, it MUST validate the IP source
and UDP source port on received packets to ensure they match the address and UDP source port on received packets to ensure they match
client's request. Packets that do not match MUST be discarded by the the client's request. Packets that do not match MUST be discarded by
proxy. the UDP proxy.
The lifetime of the socket is tied to the request stream. The proxy The lifetime of the socket is tied to the request stream. The UDP
MUST keep the socket open while the request stream is open. If a proxy MUST keep the socket open while the request stream is open. If
proxy is notified by its operating system that its socket is no a UDP proxy is notified by its operating system that its socket is no
longer usable (for example, this can happen when an ICMP "Destination longer usable (for example, this can happen when an ICMP "Destination
Unreachable" message is received, see Section 3.1 of [ICMP6]), it Unreachable" message is received, see Section 3.1 of [ICMP6]), it
MUST close the request stream. Proxies MAY choose to close sockets MUST close the request stream. UDP proxies MAY choose to close
due to a period of inactivity, but they MUST close the request stream sockets due to a period of inactivity, but they MUST close the
when closing the socket. Proxies that close sockets after a period request stream when closing the socket. UDP proxies that close
of inactivity SHOULD NOT use a period lower than two minutes, see sockets after a period of inactivity SHOULD NOT use a period lower
Section 4.3 of [BEHAVE]. than two minutes, see Section 4.3 of [BEHAVE].
A successful response (as defined in Section 3.3 and Section 3.5) A successful response (as defined in Section 3.3 and Section 3.5)
indicates that the proxy has opened a socket to the requested target indicates that the UDP proxy has opened a socket to the requested
and is willing to proxy UDP payloads. Any response other than a target and is willing to proxy UDP payloads. Any response other than
successful response indicates that the request has failed, and the a successful response indicates that the request has failed, and the
client MUST therefore abort the request. client MUST therefore abort the request.
Proxies MUST NOT introduce fragmentation at the IP layer when UDP proxies MUST NOT introduce fragmentation at the IP layer when
forwarding HTTP Datagrams onto a UDP socket. In IPv4, the Don't forwarding HTTP Datagrams onto a UDP socket. In IPv4, the Don't
Fragment (DF) bit MUST be set if possible, to prevent fragmentation Fragment (DF) bit MUST be set if possible, to prevent fragmentation
on the path. Future extensions MAY remove these requirements. on the path. Future extensions MAY remove these requirements.
3.2. HTTP Request over HTTP/1.1 3.2. HTTP/1.1 Request
When using HTTP/1.1 [HTTP/1.1], a UDP proxying request will meet the When using HTTP/1.1 [HTTP/1.1], a UDP proxying request will meet the
following requirements: following requirements:
* the method SHALL be "GET". * the method SHALL be "GET".
* the request-target SHALL use absolute-form (see Section 3.2.2 of * the request SHALL include a single "Host" header field containing
[HTTP/1.1]). the origin of the UDP proxy.
* the request SHALL include a single Host header field containing
the origin of the proxy.
* the request SHALL include a single "Connection" header field with * the request SHALL include a "Connection" header field with value
value "Upgrade" (note that this requirement is case-insensitive as "Upgrade" (note that this requirement is case-insensitive as per
per Section 7.6.1 of [HTTP]). Section 7.6.1 of [HTTP]).
* the request SHALL include a single "Upgrade" header field with * the request SHALL include an "Upgrade" header field with value
value "connect-udp". "connect-udp".
For example, if the client is configured with URI Template For example, if the client is configured with URI Template
"https://proxy.example.org/.well-known/masque/ "https://proxy.example.org/.well-known/masque/
udp/{target_host}/{target_port}/" and wishes to open a UDP proxying udp/{target_host}/{target_port}/" and wishes to open a UDP proxying
tunnel to target 192.0.2.42:443, it could send the following request: tunnel to target 192.0.2.42:443, it could send the following request:
GET https://proxy.example.org/.well-known/masque/udp/192.0.2.42/443/ HTTP/1.1 GET https://proxy.example.org/.well-known/masque/udp/192.0.2.42/443/ HTTP/1.1
Host: proxy.example.org Host: proxy.example.org
Connection: Upgrade Connection: Upgrade
Upgrade: connect-udp Upgrade: connect-udp
Figure 2: Example HTTP Request over HTTP/1.1 Figure 2: Example HTTP/1.1 Request
3.3. HTTP Response over HTTP/1.1 In HTTP/1.1, this protocol uses the GET method to mimic the design of
the WebSocket Protocol [WEBSOCKET].
The proxy SHALL indicate a successful response by replying with the 3.3. HTTP/1.1 Response
following requirements:
The UDP proxy SHALL indicate a successful response by replying with
the following requirements:
* the HTTP status code on the response SHALL be 101 (Switching * the HTTP status code on the response SHALL be 101 (Switching
Protocols). Protocols).
* the reponse SHALL include a single "Connection" header field with * the reponse SHALL include a single "Connection" header field with
value "Upgrade" (note that this requirement is case-insensitive as value "Upgrade" (note that this requirement is case-insensitive as
per Section 7.6.1 of [HTTP]). per Section 7.6.1 of [HTTP]).
* the response SHALL include a single "Upgrade" header field with * the response SHALL include a single "Upgrade" header field with
value "connect-udp". value "connect-udp".
* the response SHALL NOT include any Transfer-Encoding or Content- * the response SHALL NOT include any "Transfer-Encoding" or
Length header fields. "Content-Length" header fields.
If any of these requirements are not met, the client MUST treat this If any of these requirements are not met, the client MUST treat this
proxying attempt as failed and abort the connection. proxying attempt as failed and abort the connection.
For example, the proxy could respond with: For example, the UDP proxy could respond with:
HTTP/1.1 101 Switching Protocols HTTP/1.1 101 Switching Protocols
Connection: Upgrade Connection: Upgrade
Upgrade: connect-udp Upgrade: connect-udp
Figure 3: Example HTTP Response over HTTP/1.1 Figure 3: Example HTTP/1.1 Response
3.4. HTTP Request over HTTP/2 and HTTP/3 3.4. HTTP/2 and HTTP/3 Requests
When using HTTP/2 [HTTP/2] or HTTP/3 [HTTP/3], UDP proxying requests When using HTTP/2 [HTTP/2] or HTTP/3 [HTTP/3], UDP proxying requests
use Extended CONNECT. This requires that servers send an HTTP use Extended CONNECT. This requires that servers send an HTTP
Setting as specified in [EXT-CONNECT2] and [EXT-CONNECT3], and that Setting as specified in [EXT-CONNECT2] and [EXT-CONNECT3], and that
requests use HTTP pseudo-header fields with the following requests use HTTP pseudo-header fields with the following
requirements: requirements:
* The ":method" pseudo-header field SHALL be "CONNECT". * The ":method" pseudo-header field SHALL be "CONNECT".
* The ":protocol" pseudo-header field SHALL be "connect-udp". * The ":protocol" pseudo-header field SHALL be "connect-udp".
* The ":authority" pseudo-header field SHALL contain the authority * The ":authority" pseudo-header field SHALL contain the authority
of the proxy. of the UDP proxy.
* The ":path" and ":scheme" pseudo-header fields SHALL NOT be empty. * The ":path" and ":scheme" pseudo-header fields SHALL NOT be empty.
Their values SHALL contain the scheme and path from the URI Their values SHALL contain the scheme and path from the URI
Template after the URI template expansion process has been Template after the URI template expansion process has been
completed. completed.
A UDP proxying request that does not conform to these restrictions is A UDP proxying request that does not conform to these restrictions is
malformed (see Section 8.1.1 of [HTTP/2]). malformed (see Section 8.1.1 of [HTTP/2]).
For example, if the client is configured with URI Template For example, if the client is configured with URI Template
skipping to change at page 8, line 20 skipping to change at page 8, line 25
to open a UDP proxying tunnel to target 192.0.2.42:443, it could send to open a UDP proxying tunnel to target 192.0.2.42:443, it could send
the following request: the following request:
HEADERS HEADERS
:method = CONNECT :method = CONNECT
:protocol = connect-udp :protocol = connect-udp
:scheme = https :scheme = https
:path = /.well-known/masque/udp/192.0.2.42/443/ :path = /.well-known/masque/udp/192.0.2.42/443/
:authority = proxy.example.org :authority = proxy.example.org
Figure 4: Example HTTP Request over HTTP/2 Figure 4: Example HTTP/2 Request
3.5. HTTP Response over HTTP/2 and HTTP/3 3.5. HTTP/2 and HTTP/3 Responses
The proxy SHALL indicate a successful response by replying with any The UDP proxy SHALL indicate a successful response by replying with
2xx (Successful) HTTP status code, without any Transfer-Encoding or any 2xx (Successful) HTTP status code, without any "Transfer-
Content-Length header fields. Encoding" or "Content-Length" header fields.
If any of these requirements are not met, the client MUST treat this If any of these requirements are not met, the client MUST treat this
proxying attempt as failed and abort the request. proxying attempt as failed and abort the request.
For example, the proxy could respond with: For example, the UDP proxy could respond with:
HEADERS HEADERS
:status = 200 :status = 200
Figure 5: Example HTTP Response over HTTP/2 Figure 5: Example HTTP/2 Response
3.6. Note About Draft Versions 3.6. Note About Draft Versions
[[RFC editor: please remove this section before publication.]] [[RFC editor: please remove this section before publication.]]
In order to allow implementations to support multiple draft versions In order to allow implementations to support multiple draft versions
of this specification during its development, we introduce the of this specification during its development, we introduce the
"connect-udp-version" header field. When sent by the client, it "connect-udp-version" header field. When sent by the client, it
contains a list of draft numbers supported by the client (e.g., contains a list of draft numbers supported by the client (e.g.,
"connect-udp-version: 0, 2"). When sent by the proxy, it contains a "connect-udp-version: 0, 2"). When sent by the UDP proxy, it
single draft number selected by the proxy from the list provided by contains a single draft number selected by the UDP proxy from the
the client (e.g., "connect-udp-version: 2"). Sending this header list provided by the client (e.g., "connect-udp-version: 2").
field is RECOMMENDED but not required. The "connect-udp-version" Sending this header field is RECOMMENDED but not required. The
header field is a List Structured Field, see Section 3.1 of "connect-udp-version" header field is a List Structured Field, see
[STRUCT-FIELD]. Each list member MUST be an Integer. Section 3.1 of [STRUCT-FIELD]. Each list member MUST be an Integer.
4. Context Identifiers 4. Context Identifiers
This protocol allows future extensions to exchange HTTP Datagrams This protocol allows future extensions to exchange HTTP Datagrams
which carry different semantics from UDP payloads. Some of these which carry different semantics from UDP payloads. Some of these
extensions can augment UDP payloads with additional data, while extensions can augment UDP payloads with additional data, while
others can exchange data that is completely separate from UDP others can exchange data that is completely separate from UDP
payloads. In order to accomplish this, all HTTP Datagrams associated payloads. In order to accomplish this, all HTTP Datagrams associated
with UDP Proxying request streams start with a context ID, see with UDP Proxying request streams start with a context ID, see
Section 5. Section 5.
skipping to change at page 9, line 29 skipping to change at page 9, line 33
are client-allocated, and odd-numbered context IDs are proxy- are client-allocated, and odd-numbered context IDs are proxy-
allocated. The context ID namespace is tied to a given HTTP request: allocated. The context ID namespace is tied to a given HTTP request:
it is possible for a context ID with the same numeric value to be it is possible for a context ID with the same numeric value to be
simultaneously allocated in distinct requests, potentially with simultaneously allocated in distinct requests, potentially with
different semantics. Context IDs MUST NOT be re-allocated within a different semantics. Context IDs MUST NOT be re-allocated within a
given HTTP namespace but MAY be allocated in any order. The context given HTTP namespace but MAY be allocated in any order. The context
ID allocation restrictions to the use of even-numbered and odd- ID allocation restrictions to the use of even-numbered and odd-
numbered context IDs exist in order to avoid the need for numbered context IDs exist in order to avoid the need for
synchronisation between endpoints. However, once a context ID has synchronisation between endpoints. However, once a context ID has
been allocated, those restrictions do not apply to the use of the been allocated, those restrictions do not apply to the use of the
context ID: it can be used by any client or proxy, independent of context ID: it can be used by any client or UDP proxy, independent of
which endpoint initially allocated it. which endpoint initially allocated it.
Registration is the action by which an endpoint informs its peer of Registration is the action by which an endpoint informs its peer of
the semantics and format of a given context ID. This document does the semantics and format of a given context ID. This document does
not define how registration occurs. Future extensions MAY use HTTP not define how registration occurs. Future extensions MAY use HTTP
header fields or capsules to register contexts. Depending on the header fields or capsules to register contexts. Depending on the
method being used, it is possible for datagrams to be received with method being used, it is possible for datagrams to be received with
Context IDs which have not yet been registered, for instance due to Context IDs which have not yet been registered, for instance due to
reordering of the packet containing the datagram and the packet reordering of the packet containing the datagram and the packet
containing the registration message during transmission. containing the registration message during transmission.
skipping to change at page 10, line 29 skipping to change at page 10, line 38
value of the previous field. Note that this field can be empty. value of the previous field. Note that this field can be empty.
UDP packets are encoded using HTTP Datagrams with the Context ID set UDP packets are encoded using HTTP Datagrams with the Context ID set
to zero. When the Context ID is set to zero, the Payload field to zero. When the Context ID is set to zero, the Payload field
contains the unmodified payload of a UDP packet (referred to as "data contains the unmodified payload of a UDP packet (referred to as "data
octets" in [UDP]). octets" in [UDP]).
Clients MAY optimistically start sending UDP packets in HTTP Clients MAY optimistically start sending UDP packets in HTTP
Datagrams before receiving the response to its UDP proxying request. Datagrams before receiving the response to its UDP proxying request.
However, implementors should note that such proxied packets may not However, implementors should note that such proxied packets may not
be processed by the proxy if it responds to the request with a be processed by the UDP proxy if it responds to the request with a
failure, or if the proxied packets are received by the proxy before failure, or if the proxied packets are received by the UDP proxy
the request. before the request.
By virtue of the definition of the UDP header [UDP], it is not By virtue of the definition of the UDP header [UDP], it is not
possible to encode UDP payloads longer than 65527 bytes. Therefore, possible to encode UDP payloads longer than 65527 bytes. Therefore,
endpoints MUST NOT send HTTP Datagrams with a Payload field longer endpoints MUST NOT send HTTP Datagrams with a Payload field longer
than 65527 using Context ID zero. An endpoint that receives a than 65527 using Context ID zero. An endpoint that receives a
DATAGRAM capsule using Context ID zero whose Payload field is longer DATAGRAM capsule using Context ID zero whose Payload field is longer
than 65527 MUST abort the stream. If a proxy knows it can only send than 65527 MUST abort the stream. If a UDP proxy knows it can only
out UDP packets of a certain length due to its underlying link MTU, send out UDP packets of a certain length due to its underlying link
it SHOULD discard incoming DATAGRAM capsules using Context ID zero MTU, it SHOULD discard incoming DATAGRAM capsules using Context ID
whose Payload field is longer than that limit without buffering the zero whose Payload field is longer than that limit without buffering
capsule contents. the capsule contents.
6. Performance Considerations 6. Performance Considerations
Proxies SHOULD strive to avoid increasing burstiness of UDP traffic: UDP proxies SHOULD strive to avoid increasing burstiness of UDP
they SHOULD NOT queue packets in order to increase batching. traffic: they SHOULD NOT queue packets in order to increase batching.
When the protocol running over UDP that is being proxied uses When the protocol running over UDP that is being proxied uses
congestion control (e.g., [QUIC]), the proxied traffic will incur at congestion control (e.g., [QUIC]), the proxied traffic will incur at
least two nested congestion controllers. This can reduce performance least two nested congestion controllers. This can reduce performance
but the underlying HTTP connection MUST NOT disable congestion but the underlying HTTP connection MUST NOT disable congestion
control unless it has an out-of-band way of knowing with absolute control unless it has an out-of-band way of knowing with absolute
certainty that the inner traffic is congestion-controlled. certainty that the inner traffic is congestion-controlled.
If a client or proxy with a connection containing a UDP proxying If a client or UDP proxy with a connection containing a UDP proxying
request stream disables congestion control, it MUST NOT signal ECN request stream disables congestion control, it MUST NOT signal ECN
support on that connection. That is, it MUST mark all IP headers support on that connection. That is, it MUST mark all IP headers
with the Not-ECT codepoint. It MAY continue to report ECN feedback with the Not-ECT codepoint. It MAY continue to report ECN feedback
via ACK_ECN frames, as the peer may not have disabled congestion via ACK_ECN frames, as the peer may not have disabled congestion
control. control.
When the protocol running over UDP that is being proxied uses loss When the protocol running over UDP that is being proxied uses loss
recovery (e.g., [QUIC]), and the underlying HTTP connection runs over recovery (e.g., [QUIC]), and the underlying HTTP connection runs over
TCP, the proxied traffic will incur at least two nested loss recovery TCP, the proxied traffic will incur at least two nested loss recovery
mechanisms. This can reduce performance as both can sometimes mechanisms. This can reduce performance as both can sometimes
independently retransmit the same data. To avoid this, UDP proxying independently retransmit the same data. To avoid this, UDP proxying
SHOULD be performed over HTTP/3 to allow leveraging the QUIC DATAGRAM SHOULD be performed over HTTP/3 to allow leveraging the QUIC DATAGRAM
frame. frame.
6.1. MTU Considerations 6.1. MTU Considerations
When using HTTP/3 with the QUIC Datagram extension [DGRAM], UDP When using HTTP/3 with the QUIC Datagram extension [DGRAM], UDP
payloads are transmitted in QUIC DATAGRAM frames. Since those cannot payloads are transmitted in QUIC DATAGRAM frames. Since those cannot
be fragmented, they can only carry payloads up to a given length be fragmented, they can only carry payloads up to a given length
determined by the QUIC connection configuration and the path MTU. If determined by the QUIC connection configuration and the path MTU. If
a proxy is using QUIC DATAGRAM frames and it receives a UDP payload a UDP proxy is using QUIC DATAGRAM frames and it receives a UDP
from the target that will not fit inside a QUIC DATAGRAM frame, the payload from the target that will not fit inside a QUIC DATAGRAM
proxy SHOULD NOT send the UDP payload in a DATAGRAM capsule, as that frame, the UDP proxy SHOULD NOT send the UDP payload in a DATAGRAM
defeats the end-to-end unreliability characteristic that methods such capsule, as that defeats the end-to-end unreliability characteristic
as Datagram Packetization Layer Path MTU Discovery (DPLPMTUD) depend that methods such as Datagram Packetization Layer Path MTU Discovery
on [DPLPMTUD]. In this scenario, the proxy SHOULD drop the UDP (DPLPMTUD) depend on [DPLPMTUD]. In this scenario, the UDP proxy
payload and send an ICMP "Packet Too Big" message to the target, see SHOULD drop the UDP payload and send an ICMP "Packet Too Big" message
Section 3.2 of [ICMP6]. to the target, see Section 3.2 of [ICMP6].
6.2. Tunneling of ECN Marks 6.2. Tunneling of ECN Marks
UDP proxying does not create an IP-in-IP tunnel, so the guidance in UDP proxying does not create an IP-in-IP tunnel, so the guidance in
[ECN-TUNNEL] about transferring ECN marks between inner and outer IP [ECN-TUNNEL] about transferring ECN marks between inner and outer IP
headers does not apply. There is no inner IP header in UDP proxying headers does not apply. There is no inner IP header in UDP proxying
tunnels. tunnels.
Note that UDP proxying clients do not have the ability in this Note that UDP proxying clients do not have the ability in this
specification to control the ECN codepoints on UDP packets the proxy specification to control the ECN codepoints on UDP packets the UDP
sends to the target, nor can proxies communicate the markings of each proxy sends to the target, nor can UDP proxies communicate the
UDP packet from target to proxy. markings of each UDP packet from target to UDP proxy.
A UDP proxy MUST ignore ECN bits in the IP header of UDP packets A UDP proxy MUST ignore ECN bits in the IP header of UDP packets
received from the target, and MUST set the ECN bits to Not-ECT on UDP received from the target, and MUST set the ECN bits to Not-ECT on UDP
packets it sends to the target. These do not relate to the ECN packets it sends to the target. These do not relate to the ECN
markings of packets sent between client and proxy in any way. markings of packets sent between client and UDP proxy in any way.
7. Security Considerations 7. Security Considerations
There are significant risks in allowing arbitrary clients to There are significant risks in allowing arbitrary clients to
establish a tunnel to arbitrary targets, as that could allow bad establish a tunnel to arbitrary targets, as that could allow bad
actors to send traffic and have it attributed to the proxy. Proxies actors to send traffic and have it attributed to the UDP proxy. HTTP
that support UDP proxying ought to restrict its use to authenticated servers that support UDP proxying ought to restrict its use to
users. authenticated users.
Because the CONNECT method creates a TCP connection to the target, Because the CONNECT method creates a TCP connection to the target,
the target has to indicate its willingness to accept TCP connections the target has to indicate its willingness to accept TCP connections
by responding with a TCP SYN-ACK before the proxy can send it by responding with a TCP SYN-ACK before the CONNECT proxy can send it
application data. UDP doesn't have this property, so a UDP proxy application data. UDP doesn't have this property, so a UDP proxy
could send more data to an unwilling target than a CONNECT proxy. could send more data to an unwilling target than a CONNECT proxy.
However, in practice denial of service attacks target open TCP ports However, in practice denial of service attacks target open TCP ports
so the TCP SYN-ACK does not offer much protection in real scenarios. so the TCP SYN-ACK does not offer much protection in real scenarios.
While a proxy could potentially limit the number of UDP packets it is While a UDP proxy could potentially limit the number of UDP packets
willing to forward until it has observed a response from the target, it is willing to forward until it has observed a response from the
that is unlikely to provide any protection against denial of service target, that is unlikely to provide any protection against denial of
attacks because such attacks target open UDP ports where the protocol service attacks because such attacks target open UDP ports where the
running over UDP would respond, and that would be interpreted as protocol running over UDP would respond, and that would be
willingness to accept UDP by the proxy. interpreted as willingness to accept UDP by the UDP proxy.
UDP sockets for UDP proxying have a different lifetime than TCP UDP sockets for UDP proxying have a different lifetime than TCP
sockets for CONNECT, therefore implementors would be well served to sockets for CONNECT, therefore implementors would be well served to
follow the advice in Section 3.1 if they base their UDP proxying follow the advice in Section 3.1 if they base their UDP proxying
implementation on a preexisting implementation of CONNECT. implementation on a preexisting implementation of CONNECT.
The security considerations described in [HTTP-DGRAM] also apply The security considerations described in [HTTP-DGRAM] also apply
here. here.
8. IANA Considerations 8. IANA Considerations
skipping to change at page 15, line 37 skipping to change at page 15, line 41
Briscoe, B., "Tunnelling of Explicit Congestion Briscoe, B., "Tunnelling of Explicit Congestion
Notification", RFC 6040, DOI 10.17487/RFC6040, November Notification", RFC 6040, DOI 10.17487/RFC6040, November
2010, <https://www.rfc-editor.org/rfc/rfc6040>. 2010, <https://www.rfc-editor.org/rfc/rfc6040>.
[ICMP6] Conta, A., Deering, S., and M. Gupta, Ed., "Internet [ICMP6] Conta, A., Deering, S., and M. Gupta, Ed., "Internet
Control Message Protocol (ICMPv6) for the Internet Control Message Protocol (ICMPv6) for the Internet
Protocol Version 6 (IPv6) Specification", STD 89, Protocol Version 6 (IPv6) Specification", STD 89,
RFC 4443, DOI 10.17487/RFC4443, March 2006, RFC 4443, DOI 10.17487/RFC4443, March 2006,
<https://www.rfc-editor.org/rfc/rfc4443>. <https://www.rfc-editor.org/rfc/rfc4443>.
[WEBSOCKET]
Fette, I. and A. Melnikov, "The WebSocket Protocol",
RFC 6455, DOI 10.17487/RFC6455, December 2011,
<https://www.rfc-editor.org/rfc/rfc6455>.
Acknowledgments Acknowledgments
This document is a product of the MASQUE Working Group, and the This document is a product of the MASQUE Working Group, and the
author thanks all MASQUE enthusiasts for their contibutions. This author thanks all MASQUE enthusiasts for their contibutions. This
proposal was inspired directly or indirectly by prior work from many proposal was inspired directly or indirectly by prior work from many
people. In particular, the author would like to thank Eric Rescorla people. In particular, the author would like to thank Eric Rescorla
for suggesting to use an HTTP method to proxy UDP. Thanks to Lucas for suggesting to use an HTTP method to proxy UDP. The author is
Pardue for their inputs on this document. The extensibility design indebted to Mark Nottingham and Lucas Pardue for the many
in this document came out of the HTTP Datagrams Design Team, whose improvements they contributed to this document. The extensibility
members were Alan Frindell, Alex Chernyakhovsky, Ben Schwartz, Eric design in this document came out of the HTTP Datagrams Design Team,
Rescorla, Lucas Pardue, Marcus Ihlar, Martin Thomson, Mike Bishop, whose members were Alan Frindell, Alex Chernyakhovsky, Ben Schwartz,
Tommy Pauly, Victor Vasiliev, and the author of this document. Eric Rescorla, Lucas Pardue, Marcus Ihlar, Martin Thomson, Mike
Bishop, Tommy Pauly, Victor Vasiliev, and the author of this
document.
Author's Address Author's Address
David Schinazi David Schinazi
Google LLC Google LLC
1600 Amphitheatre Parkway 1600 Amphitheatre Parkway
Mountain View, CA 94043 Mountain View, CA 94043
United States of America United States of America
Email: dschinazi.ietf@gmail.com Email: dschinazi.ietf@gmail.com
 End of changes. 61 change blocks. 
169 lines changed or deleted 180 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/