Closed FiloSottile closed 3 years ago
It looks like even x/net/http2 is doing this wrong
so we might need to just hardcode an exception such that if h2
is configured we keep ignoring the ALPN extension as long as it includes http/1.1
, assuming a fallback is expected.
Change https://golang.org/cl/325611 mentions this issue: http2: also set "http/1.1" ALPN in ConfigureServer
Change https://golang.org/cl/325432 mentions this issue: crypto/tls: let HTTP/1.1 clients connect to servers with NextProtos "h2"
This broke us and has been preventing us from upgrade http://github.com/istio/istio to golang 1.17.
Our expectation is that we can have a server that will serve any explicitly configured ALPNs with that config (ie h2
will serve HTTP 2), and anything else will fall back to http 1.1. This was the behavior on all former go versions.
https://github.com/golang/go/commit/dc00dc6c6bf3b5554e37f60799aec092276ff807 was an insufficient fix for us; we do not have NextProtos: h2
and want to allow http/1.1
, we want to support ANY alpn.
A few alternatives we have tried:
NextProtos
. This breaks h2 negotiation.SupportedProtos
in GetConfigForClient
. This works on the serverside but breaks go clients (and possibly others) as the NegotiatedProtocol is not correntNextProtos
(not really possible, since ideally we want all of them, but we can live with this), and then setup TLSNextProtos
to serve http/1.1 for all those ALPNs. This seems to require completely reimplementing the HTTP/1.1 serving code which is highly undesirable.Is there any viable workarounds? Right now we are stuck.
In 90d6bbb we fixed crypto/tls to require a successful ALPN negotiation if both sides support it. That is, if a client sends an ALPN extension, and the server has configured
NextProtos
, we reject the connection if there is no overlap between client and server protocols.This is what the spec requires, and has a security benefit, because it protects against cross-protocol attacks.
However, it's also kind of surprising, because if a client doesn't support ALPN it will never have its connection rejected.
Moreover, we used not to enforce this, so there is a risk that servers configured a partial
NextProtos
list, expecting other protocols to just fallback to not negotiating ALPN.In particular, we have anecdotal evidence of servers with
NextProtos: []string{"h2"}
that expect a client that tries to negotiatehttp/1.1
to fallback successfully. These servers will break in Go 1.17.I searched all code on the Modules Mirror for
NextProtos
uses, and it looks like this is the only case in which a fallback seems to be expected.Some of them are from gRPC, which as far as I know legitimately requires HTTP/2, so for those all is well.
Some though look like they might unintentionally break. We should figure out how common this is, weight it against the security benefit, and maybe proactively reach out.
We should also make sure the HTTP/2 docs in Go have correct examples that include
http/1.1
./cc @golang/security