Skip to content

Commit 9cc013b

Browse files
committed
[optimistic-upgrade] Incorporate comments from Éric Vyncke
1 parent 150de04 commit 9cc013b

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

draft-ietf-httpbis-optimistic-upgrade.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ In some cases, the client might predict that the protocol transition is likely t
106106

107107
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 {{?WEBSOCKET=RFC6455}} similarly are often used to convey data chosen by a third party.
108108

109-
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.
109+
If the third-party data source is untrusted, then the data it provides is potentially "attacker-controlled". The combination of attacker-controlled data and optimistic protocol transitions results in two significant security issues.
110110

111111
## Request Smuggling
112112

@@ -116,6 +116,41 @@ If the server accepts a protocol transition request, it interprets the subsequen
116116

117117
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 ({{?TLS=RFC8446, Section 4.4.2}}), the attacker could send an HTTP/1.1 POST request ({{HTTP, Section 9.3.3}}) 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.
118118

119+
~~~ http-message
120+
## REQUESTS ##
121+
122+
# The malicious application requests a TCP connection to a nonexistent
123+
# destination, which will fail.
124+
CONNECT no-such-destination.example:443 HTTP/1.1
125+
Host: no-such-destination.example:443
126+
127+
# Before connection fails, the malicious application sends data on the
128+
# proxied TCP connection that forms a valid POST request to the proxy.
129+
# The vulnerable client optimistically forwards this data to the proxy.
130+
POST /upload HTTP/1.1
131+
Host: proxy.example
132+
Content-Length: 123456
133+
134+
<POST body controlled by the malicious application>
135+
136+
## RESPONSES ##
137+
138+
# When TCP connection establishment fails, the proxy responds by
139+
# rejecting the CONNECT request, but the client has already forwarded
140+
# the malicious TCP payload data to the proxy.
141+
HTTP/1.1 504 Gateway Timeout
142+
Content-Length: 0
143+
144+
# The proxy interprets the smuggled POST request as coming from the
145+
# client. If connection-based authentication is in use (e.g., using
146+
# TLS client certificate authentication), the proxy treats this
147+
# malicious request as authenticated.
148+
HTTP/1.1 200 OK
149+
Content-Length: 0
150+
151+
~~~
152+
{:figure title="Example request smuggling attack using HTTP CONNECT"}
153+
119154
## Parser Exploits
120155

121156
A related category of attacks use protocol disagreement to exploit vulnerabilities in the server's request parsing logic. These attacks apply when the HTTP client is trusted by the server, but the post-transition data source is not. If the server software was developed under the assumption that some or all of the HTTP request data is not attacker-controlled, optimistic transmission can cause this assumption to be violated, exposing vulnerabilities in the server's HTTP request parser.
@@ -174,7 +209,7 @@ The other upgrade tokens mentioned in {{existing}} do not preserve HTTP semantic
174209

175210
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.
176211

177-
# Guidance for HTTP CONNECT {#connect}
212+
# Requirements for HTTP CONNECT {#connect}
178213

179214
This document updates RFC 9112 to include the remaining text of this section. The requirements in this section apply only to HTTP/1.1.
180215

@@ -185,7 +220,7 @@ Proxy clients that send CONNECT requests on behalf of untrusted TCP clients MUST
185220

186221
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}}).
187222

188-
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.
223+
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 (i.e., complying with item 1 above). This requirement applies whether or not the request includes a "close" connection option. Proxy servers can identify compliant clients using the request's User-Agent header field and the user-agent vendor's documentation regarding its compliance.
189224

190225
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.
191226

0 commit comments

Comments
 (0)