Closed liorokman closed 6 months ago
@liorokman can't this be solved by pinning alpnProtocols
https://gateway.envoyproxy.io/latest/api/extension_types/#alpnprotocol to http/1.1
?
https://gateway.envoyproxy.io/latest/api/extension_types/#tlssettings
Soon Envoy Gateway will support BackendTLSPolicy
( #2247 ), at which point the protocol between the Envoy Proxy and the backend will most likely be negotiated with ALPN. At that point it makes sense to me to have the ability to prevent protocol upgrades/downgrades in the context of a specific request.
Pinning HTTP/1.1 on the client side is a solution that only makes sense if the upstream isn't TLS enabled. If it's possible to negotiate the HTTP protocol with upstream, I think it's better to allow HTTP/2 when the client supports it so that the benefits of HTTP/2 can be realised.
it sounds like for the case when downstream tls supports h2 and http/1.1 and upstream tls also supports h2 and http/1.1, we want to make sure that protocol downgrades are not supported. So instead of a field like USE_DOWNSTREAM_PROTOCOL (which disables protocol upgrades) what we'd really want is for envoy to disable downgrades by default or add a knob to support that, cc @ggreenway in case you have any thoughts here
This issue has been automatically marked as stale because it has not had activity in the last 30 days.
The useClientProtocol
added in #2433 solves this issue.
Description:
The way that EG sets up
HTTPRoute
s by default in Envoy Proxy today is that if TLS is enabled downstream, then ALPN negotiation is enabled with the default valuesh2, http/1.1
. Clients that support ALPN will prefer to use HTTP/2.In contrast, upstream connections are always HTTP/1.1 for
HTTPRoute
s. This can be seen in the following output (edited for brevity) :The output shows that while the
curl
command uses HTTP/2, the echo server identifies the protocol as HTTP/1.1.The fact that Envoy Proxy downgrades the protocol from HTTP/2 to HTTP/1.1 means that there is a potential attack surface created here for HTTP smuggling attacks, as detailed here.
When running the HTTP smuggling detection tool ( https://github.com/neex/http2smugl ) and keeping track of actual requests received in the server and the Envoy Proxy logs, there are several requests that appear in Envoy Proxy's log as rejected but are actually sent all the way to the backend server.
For example:
The following request specifies a response code of
0
and response flagsDPE
("The downstream request had an HTTP protocol error"), and bytes sent and received sizes of0
.When running a
tcpdump
session on the backend server side this specific request is actually found, including a valid HTTP 200 response. This was correlated via thex-request-id
header shown in the Envoy Proxy log. Here is the packet dump, edited for brevity.Since the Envoy Proxy log shows that there was a protocol error and no bytes sent or received, the request should not have appeared at all in the packet capture on the backend side.
I propose that it be made possible to prevent this category of issues by configuring Envoy Gateway to use the same HTTP protocol in upstream requests as received from downstream.
[optional Relevant Links:]
https://book.hacktricks.xyz/pentesting-web/http-request-smuggling/request-smuggling-in-http-2-downgrades