Skip to content

Commit 3a3aba6

Browse files
authored
Merge pull request #3133 from httpwg/bemasc-mbishop-review
[optimistic-upgrade] Editorial adjustments from AD review
2 parents 0a772ee + f15ecf5 commit 3a3aba6

File tree

1 file changed

+40
-29
lines changed

1 file changed

+40
-29
lines changed

draft-ietf-httpbis-optimistic-upgrade.md

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ author:
2323
2424

2525
normative:
26-
26+
RFC9112:
27+
display: HTTP/1.1
2728
informative:
29+
RFC9113:
30+
display: HTTP/2
2831

2932

3033
--- abstract
3134

32-
In HTTP/1.1, the client can request a change to a new protocol on the existing connection. This document discusses the security considerations that apply to data sent by the client before this request is confirmed, and updates RFC 9298 to avoid related security issues.
35+
In HTTP/1.1, the client can request a change to a new protocol on the existing connection. This document discusses the security considerations that apply to data sent by the client before this request is confirmed, and updates RFC 9112 and RFC 9298 to avoid related security issues.
3336

3437

3538
--- middle
@@ -42,24 +45,24 @@ In HTTP/1.1, the client can request a change to a new protocol on the existing c
4245

4346
In HTTP/1.1 and later, a single connection can be used for many requests. In HTTP/2 and HTTP/3, these requests can be multiplexed, as each request is distinguished explicitly by its stream ID. However, in HTTP/1.1, requests are strictly sequential, and each new request is distinguished implicitly by the closure of the preceding request.
4447

45-
HTTP/1.1 is also the only version of HTTP that allows the client to change the protocol used for the remainder of the connection. There are two mechanisms to request such a protocol transition. One mechanism is the "Upgrade" request header field ({{!RFC9110, Section 7.8}}), which indicates that the client would like to use this connection for a protocol other than HTTP/1.1. The server replies with a "101 (Switching Protocols)" status code if it accepts the protocol change.
48+
HTTP/1.1 is also the only version of HTTP that allows the client to change the protocol used for the remainder of the connection. There are two mechanisms to request such a protocol transition. One mechanism is the Upgrade request header field ({{!HTTP=RFC9110, Section 7.8}}), which indicates that the client would like to use this connection for a protocol other than HTTP/1.1. The server replies with a 101 (Switching Protocols) status code if it accepts the protocol change.
4649

47-
The other mechanism is the HTTP "CONNECT" method. This method indicates that the client wishes to establish a TCP connection to the specified host and port. The server replies with a 2xx (Successful) response to indicate that the request was accepted and a TCP connection was established. After this point, the TCP connection is acting as a TCP tunnel, not an HTTP/1.1 connection.
50+
The other mechanism is the HTTP CONNECT method. This method indicates that the client wishes to establish a TCP connection to the specified host and port. The server replies with a 2xx (Successful) response to indicate that the request was accepted and a TCP connection was established. After this point, the TCP connection is acting as a TCP tunnel, not an HTTP/1.1 connection.
4851

49-
Both of these mechanisms also permit the server to reject the request. For example, {{RFC9110}} says:
52+
Both of these mechanisms also permit the server to reject the request. For example, {{HTTP}} says:
5053

5154
> A server MAY ignore a received Upgrade header field if it wishes to continue using the current protocol on that connection.
5255

5356
and
5457

5558
> A server MUST reject a CONNECT request that targets an empty or invalid port number, typically by responding with a 400 (Bad Request) status code.
5659

57-
Rejections are common, and can happen for a variety of reasons. An "upgrade" request might be rejected if:
60+
Rejections are common, and can happen for a variety of reasons. A request using Upgrade might be rejected if:
5861

59-
* The server does not support any of the client's indicated Upgrade Tokens (i.e., the client's proposed new protocols), so it continues to use HTTP/1.1.
62+
* The server does not support any of the client's indicated upgrade tokens (i.e., the client's proposed new protocols), so it continues to use HTTP/1.1.
6063
* The server knows that an upgrade to the offered protocol will not provide any improvement over HTTP/1.1 for this request to this resource, so it chooses to respond in HTTP/1.1.
61-
* The server requires the client to authenticate before upgrading the protocol, so it replies with the status code "401 (Authentication Required)" and provides a challenge in an "Authorization" response header ({{!RFC9110, Section 11.6.2}}).
62-
* The resource has moved, so the server replies with a 3XX redirect status code ({{!RFC9110, Section 3.4}}).
64+
* The server requires the client to authenticate before upgrading the protocol, so it replies with the status code 401 (Authentication Required) and provides a challenge in an Authorization response header field ({{!HTTP, Section 11.6.2}}).
65+
* The resource has moved, so the server replies with a 3xx (Redirection) status code ({{!HTTP, Section 3.4}}).
6366

6467
Similarly, a CONNECT request might be rejected if:
6568

@@ -70,7 +73,7 @@ Similarly, a CONNECT request might be rejected if:
7073

7174
After rejecting a request, the server will continue to interpret subsequent bytes on that connection in accordance with HTTP/1.1.
7275

73-
{{!RFC9110}} also states:
76+
{{!HTTP}} also states:
7477

7578
> A client cannot begin using an upgraded protocol on the connection until it has completely sent the request message (i.e., the client can't change the protocol it is sending in the middle of a message).
7679

@@ -80,15 +83,15 @@ In some cases, the client might expect that the protocol transition will succeed
8083

8184
# Possible Security Issues
8285

83-
When there are only two distinct parties involved in an HTTP/1.1 connection (i.e., the client and the server), protocol transitions introduce no new security issues: each party must already be prepared for the other to send arbitrary data on the connection at any time. However, HTTP connections often involve more than two parties, if the requests or responses include third-party data. For example, a browser (party 1) might send an HTTP request to an origin (party 2) with path, headers, or body controlled by a website from a different origin (party 3). Post-transition protocols such as WebSocket similarly are often used to convey data chosen by a third party.
86+
When there are only two distinct parties involved in an HTTP/1.1 connection (i.e., the client and the server), protocol transitions introduce no new security issues: each party must already be prepared for the other to send arbitrary data on the connection at any time. However, HTTP connections often involve more than two parties, if the requests or responses include third-party data. For example, a browser (party 1) might send an HTTP request to an origin (party 2) with path, headers, or content controlled by a website from a different origin (party 3). Post-transition protocols such as WebSocket similarly are often used to convey data chosen by a third party.
8487

8588
If the third-party data source is untrusted, we call the data it provides "attacker-controlled". The combination of attacker-controlled data and optimistic protocol transitions results in two significant security issues.
8689

8790
## Request Smuggling
8891

89-
In a Request Smuggling attack ({{?RFC9112, Section 11.2}}) the attacker-controlled data is chosen in such a way that it is interpreted by the server as an additional HTTP request. These attacks allow the attacker to speak on behalf of the client while bypassing the client's own rules about what requests it will issue. Request Smuggling can occur if the client and server have distinct interpretations of the data that flows between them.
92+
In a Request Smuggling attack ({{RFC9112, Section 11.2}}) the attacker-controlled data is chosen in such a way that it is interpreted by the server as an additional HTTP request. These attacks allow the attacker to speak on behalf of the client while bypassing the client's own rules about what requests it will issue. Request Smuggling can occur if the client and server have distinct interpretations of the data that flows between them.
9093

91-
If the server accepts a protocol transition request, it interprets the subsequent bytes in accordance with the new protocol. If it rejects the request, it interprets those bytes as HTTP/1.1. However, the client doesn't know which interpretation the server will take until it receives the server's response status code. If it uses the new protocol optimistically, this creates a risk that the server will interpret attacker-controlled data in the new protocol as an additional HTTP request issued by the client.
94+
If the server accepts a protocol transition request, it interprets the subsequent bytes in accordance with the new protocol. If it rejects the request, it interprets those bytes as HTTP/1.1. However, the client cannot know which interpretation the server will take until it receives the server's response status code. If it uses the new protocol optimistically, this creates a risk that the server will interpret attacker-controlled data in the new protocol as an additional HTTP request issued by the client.
9295

9396
As a trivial example, consider an HTTP CONNECT client providing connectivity to an untrusted application. If the client is authenticated to the proxy server using a connection-level authentication method such as TLS Client Certificates, the attacker could send an HTTP/1.1 POST request for the proxy server at the beginning of its TCP connection. If the client delivers this data optimistically, and the CONNECT request fails, the server would misinterpret the application's data as a subsequent authenticated request issued by the client.
9497

@@ -102,23 +105,23 @@ If the server rejects the transition request, the connection can continue to be
102105

103106
# Impact on HTTP Upgrade with Existing Upgrade Tokens {#existing}
104107

105-
This section describes the impact of this document's considerations on some registered Upgrade Tokens that are believed to be in use at the time of writing.
108+
This section describes the impact of this document's considerations on some registered upgrade tokens that are believed to be in use at the time of writing.
106109

107110
## "TLS"
108111

109-
The "TLS" family of Upgrade Tokens was defined in {{?RFC2817}}, which correctly highlights the possibility of the server rejecting the upgrade. If a client ignores this possibility and sends TLS data optimistically, the result cannot be valid HTTP/1.1: the first octet of a TLS connection must be 22 (ContentType.handshake), but this is not an allowed character in an HTTP/1.1 method. A compliant HTTP/1.1 server will treat this as a parsing error and close the connection without processing further requests.
112+
The "TLS" family of upgrade tokens was defined in {{?RFC2817}}, which correctly highlights the possibility of the server rejecting the upgrade. If a client ignores this possibility and sends TLS data optimistically, the result cannot be valid HTTP/1.1: the first octet of a TLS connection must be 22 (ContentType.handshake), but this is not an allowed character in an HTTP/1.1 method. A compliant HTTP/1.1 server will treat this as a parsing error and close the connection without processing further requests.
110113

111114
## "WebSocket"/"websocket"
112115

113-
{{Section 4.1 of ?RFC6455}} says:
116+
{{Section 4.1 of ?WEBSOCKET=RFC6455}} says:
114117

115118
> Once the client's opening handshake has been sent, the client MUST wait for a response from the server before sending any further data.
116119

117-
Thus, optimistic use of HTTP Upgrade is already forbidden in the WebSocket protocol. Additionally, the WebSocket protocol requires high-entropy masking of client-to-server frames ({{Section 5.1 of ?RFC6455}}).
120+
Thus, optimistic use of HTTP Upgrade is already forbidden in the WebSocket protocol. Additionally, the WebSocket protocol requires high-entropy masking of client-to-server frames ({{Section 5.1 of ?WEBSOCKET}}).
118121

119122
## "connect-udp"
120123

121-
{{Section 5 of !RFC9298}} says:
124+
{{Section 5 of !CONNECT-UDP=RFC9298}} says:
122125

123126
> A client MAY optimistically start sending UDP packets in HTTP Datagrams before receiving the response to its UDP proxying request.
124127

@@ -128,36 +131,44 @@ However, in HTTP/1.1, this "proxying request" is an HTTP Upgrade request. This
128131

129132
## "connect-ip"
130133

131-
The "connect-ip" Upgrade Token is defined in {{!RFC9484}}. {{Section 11 of !RFC9484}} forbids clients from sending packets optimistically in HTTP/1.1, avoiding this issue.
134+
The "connect-ip" upgrade token is defined in {{?CONNECT-IP=RFC9484}}. {{Section 11 of ?CONNECT-IP}} forbids clients from sending packets optimistically in HTTP/1.1, avoiding this issue.
132135

133136
# Guidance for Future Upgrade Tokens
134137

135138
There are now several good examples of designs that reduce or eliminate the security concerns discussed in this document and may be applicable in future specifications:
136139

137-
* Forbid optimistic use of HTTP Upgrade (WebSocket, {{Section 4.1 of ?RFC6455}}).
138-
* Embed a fixed preamble that terminates HTTP/1.1 processing (HTTP/2, {{Section 3.4 of ?RFC9113}}).
139-
* Apply high-entropy masking of client-to-server data (WebSocket, {{Section 5.1 of ?RFC6455}}).
140+
* Forbid optimistic use of HTTP Upgrade ({{Section 4.1 of ?WEBSOCKET}}, {{Section 11 of ?CONNECT-IP}}).
141+
* Embed a fixed preamble that deliberately terminates HTTP/1.1 processing ({{Section 3.4 of RFC9113}}).
142+
* Apply high-entropy masking of client-to-server data ({{Section 5.1 of ?WEBSOCKET}}).
140143

141-
Future specifications for Upgrade Tokens should account for the security issues discussed here and provide clear guidance on how implementations can avoid them.
144+
Future specifications for upgrade tokens should account for the security issues discussed here and provide clear guidance on how implementations can avoid them.
142145

143146
## Selection of Request Methods
144147

145-
Some Upgrade Tokens, such as "TLS", are defined for use with any ordinary HTTP Method. The upgraded protocol continues to provide HTTP semantics, and will convey the response to this HTTP request.
148+
Some upgrade tokens, such as "TLS", are defined for use with any ordinary HTTP method. The upgraded protocol continues to provide HTTP semantics, and will convey the response to this HTTP request.
146149

147-
The other Upgrade Tokens mentioned in {{existing}} do not preserve HTTP semantics, so the method is not relevant. All of these Upgrade Tokens are specified only for requests with the "GET" method and an empty body.
150+
The other upgrade tokens mentioned in {{existing}} do not preserve HTTP semantics, so the method is not relevant. All of these upgrade tokens are specified only for GET requests with no content.
148151

149-
Future specifications for Upgrade Tokens should restrict their use to "GET" requests with an empty body if the HTTP method is otherwise irrelevant and a request body is not required. This improves consistency with other Upgrade Tokens and simplifies server implementation.
152+
Future specifications for upgrade tokens should restrict their use to GET requests with no content if the HTTP method is otherwise irrelevant and the request does not need to carry any message content. This improves consistency with other upgrade tokens and simplifies server implementation.
150153

151154
# Guidance for HTTP CONNECT
152155

153-
In HTTP/1.1, proxy clients that send CONNECT requests on behalf of untrusted TCP clients MUST do one or both of the following:
156+
This document updates RFC 9112 to include the remaining text of this section. The requirements in this section apply only to HTTP/1.1.
157+
158+
Proxy clients that send CONNECT requests on behalf of untrusted TCP clients MUST do one or both of the following:
154159

155160
1. Wait for a 2xx (Successful) response before forwarding any TCP payload data.
156161
1. Send a "Connection: close" request header.
157162

158-
Proxy clients that don't implement at least one of these two behaviors are vulnerable to a trivial request smuggling attack ({{request-smuggling}}).
163+
Proxy clients that don't implement at least one of these two behaviors are vulnerable to a trivial request smuggling attack ({{RFC9112, Section 11.2}}).
164+
165+
At the time of writing, some proxy clients are believed to be vulnerable as described. As a mitigation, proxy servers MUST close the underlying connection when rejecting a CONNECT request, without processing any further requests on that connection, unless the client is known to wait for a 2xx (Successful) response before forwarding TCP payload data. This requirement applies whether or not the request includes a "close" connection option.
166+
167+
Note that this mitigation will frequently impair the performance of correctly implemented clients, especially when returning a 407 (Proxy Authentication Required) response. This performance loss can be avoided by using HTTP/2 or HTTP/3, which are not vulnerable to this attack.
168+
169+
# Security Considerations
159170

160-
At the time of writing, some proxy clients are believed to be vulnerable as described. When communicating with potentially vulnerable clients, proxy servers MUST close the underlying connection when rejecting an HTTP/1.1 CONNECT request, without processing any further data on that connection, whether or not the request headers include "Connection: close". Note that this mitigation will frequently impair the performance of correctly implemented clients, especially when returning a "407 (Proxy Authentication Required)" response. This performance loss can be avoided by using HTTP/2 or HTTP/3, which are not vulnerable to this attack.
171+
This document describes security considerations related to optimistic use of protocol transitions in HTTP/1.1.
161172

162173
# IANA Considerations
163174

0 commit comments

Comments
 (0)