You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
33
36
34
37
35
38
--- middle
@@ -42,24 +45,24 @@ In HTTP/1.1, the client can request a change to a new protocol on the existing c
42
45
43
46
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.
44
47
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.
46
49
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.
48
51
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:
50
53
51
54
> A server MAY ignore a received Upgrade header field if it wishes to continue using the current protocol on that connection.
52
55
53
56
and
54
57
55
58
> 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.
56
59
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:
58
61
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.
60
63
* 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}}).
63
66
64
67
Similarly, a CONNECT request might be rejected if:
65
68
@@ -70,7 +73,7 @@ Similarly, a CONNECT request might be rejected if:
70
73
71
74
After rejecting a request, the server will continue to interpret subsequent bytes on that connection in accordance with HTTP/1.1.
72
75
73
-
{{!RFC9110}} also states:
76
+
{{!HTTP}} also states:
74
77
75
78
> 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).
76
79
@@ -80,15 +83,15 @@ In some cases, the client might expect that the protocol transition will succeed
80
83
81
84
# Possible Security Issues
82
85
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.
84
87
85
88
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.
86
89
87
90
## Request Smuggling
88
91
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.
90
93
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.
92
95
93
96
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.
94
97
@@ -102,23 +105,23 @@ If the server rejects the transition request, the connection can continue to be
102
105
103
106
# Impact on HTTP Upgrade with Existing Upgrade Tokens {#existing}
104
107
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.
106
109
107
110
## "TLS"
108
111
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.
110
113
111
114
## "WebSocket"/"websocket"
112
115
113
-
{{Section 4.1 of ?RFC6455}} says:
116
+
{{Section 4.1 of ?WEBSOCKET=RFC6455}} says:
114
117
115
118
> Once the client's opening handshake has been sent, the client MUST wait for a response from the server before sending any further data.
116
119
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}}).
118
121
119
122
## "connect-udp"
120
123
121
-
{{Section 5 of !RFC9298}} says:
124
+
{{Section 5 of !CONNECT-UDP=RFC9298}} says:
122
125
123
126
> A client MAY optimistically start sending UDP packets in HTTP Datagrams before receiving the response to its UDP proxying request.
124
127
@@ -128,36 +131,44 @@ However, in HTTP/1.1, this "proxying request" is an HTTP Upgrade request. This
128
131
129
132
## "connect-ip"
130
133
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.
132
135
133
136
# Guidance for Future Upgrade Tokens
134
137
135
138
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:
136
139
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}}).
140
143
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.
142
145
143
146
## Selection of Request Methods
144
147
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.
146
149
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.
148
151
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.
150
153
151
154
# Guidance for HTTP CONNECT
152
155
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:
154
159
155
160
1. Wait for a 2xx (Successful) response before forwarding any TCP payload data.
156
161
1. Send a "Connection: close" request header.
157
162
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
159
170
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.
0 commit comments