Skip to content

net/http: do not enable HTTP/2 extended connect by default #71128

Closed
@rthellend

Description

@rthellend

Go version

go version 1.24rc1

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/robin/.cache/go-build'
GODEBUG=''
GOENV='/home/robin/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2734898122=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/robin/src/tlsproxy/go.mod'
GOMODCACHE='/home/robin/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/robin/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/robin/src/goroot'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/robin/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/robin/src/goroot/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.24-705b5a569a Fri Jan 3 14:40:11 2025 -0800'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

This change, which should be autogenerated appears to have picked up an unintended change to src/net/http/h2_bundle.go

https://go-review.googlesource.com/c/go/+/631336

https://go-review.googlesource.com/c/go/+/631336/2/src/net/http/h2_bundle.go

all: update vendored dependencies [generated]

The Go 1.24 code freeze has recently started. This is a time to update
all golang.org/x/... module versions that contribute packages to the
std and cmd modules in the standard library to latest master versions.

For [#36905](https://go.dev/issue/36905).

[git-generate]
go install golang.org/x/build/cmd/updatestd@latest
go install golang.org/x/tools/cmd/bundle@latest
updatestd -goroot=$(pwd) -branch=master

What did you see happen?

The change to h2_bundle.go that enables the Extended Connect Protocol is undocumented.

What did you expect to see?

The change should either be documented or removed.

Activity

changed the title [-]net/http: undocumented (unintended?) change that enables extended connect protocol[/-] [+]net/http: document http2 extended connect support[/+] on Jan 4, 2025
added this to the Go1.24 milestone on Jan 4, 2025
seankhliao

seankhliao commented on Jan 4, 2025

@seankhliao
Member

The change looks intentional (part of #49918).
I think this just needs a release note?

cc @WeidiDeng @neild

rthellend

rthellend commented on Jan 4, 2025

@rthellend
Author

I doubt this is actually intentional. It will break existing websocket implementations. If anything, the feature should be optional (off by default).

Browsers will start trying to open websockets using h2, and it will fail unless there is code in the server to handle those requests.

rthellend

rthellend commented on Jan 5, 2025

@rthellend
Author

Here's a boiled down example that demonstrates the problem: https://gist.github.com/rthellend/e77264034eb761ccf32abd274792775a

2025/01/04 16:19:27 HTTP/2.0 GET /
2025/01/04 16:19:27 HTTP/2.0 CONNECT /websocket
2025/01/04 16:19:27 ERR websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header
prattmic

prattmic commented on Jan 6, 2025

@prattmic
Member

This was added in https://go.dev/cl/610977. I'll leave it to @neild to say whether it is intentional/correct, but I also want to point out that #70728 was filed as a follow-up issue, which I've tentatively made a release blocker as well, and the CL has another comment about a potential deadlock with no issue.

WeidiDeng

WeidiDeng commented on Jan 7, 2025

@WeidiDeng
Contributor

The exact proposal is here. And according to rsc, this should be on by default. To turn this flag off, GODEBUG=http2xconnect=0 is used. As said by @rthellend, it will break existing codes if that env isn't specified because the server advertised it can handle websockets over h2 but the handler still uses h1 upgrade mechanics which isn't compatible with h2 websockets. And some of the most used browsers will try to use websockets over h2 if the server advertises support.

#70728 is when the golang http2 client tries to use extended connect to establish a websocket connection over h2, which can only happen if user tries to use the new websocket upgrade mechanics.

rthellend

rthellend commented on Jan 7, 2025

@rthellend
Author

It's not clear to me that @rsc understood that this will break all websocket implementations when he said this didn't have to be opt-in.

#53208 (comment)

I don't think it has to be opt-in but it probably needs a GODEBUG to provide a fallback when hitting endpoints or middleware that is buggy when extended CONNECTs are involved. http2xconnect=0 or something like that.

15 remaining items

added
NeedsFixThe path to resolution is known, but the work has not been done.
and removed
DocumentationIssues describing a change to documentation.
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Jan 9, 2025
cdujeu

cdujeu commented on Jan 13, 2025

@cdujeu

Sorry i i'm wrong, I do not fully get the link between go versions and golang.org/x packages versioning.

For those having the issue, this has been introduced in golang.org/x/net v0.32.0 , so for me the http2xconnect flag is required although I'm building with go 22 or 23... Reverting to v0.31.0 fixes that (but brings back a known vulnerability 😭).

Will the backport you are referring to also be part of a golang.org/x/net next version ?

Thanks!

gopherbot

gopherbot commented on Jan 17, 2025

@gopherbot
Contributor

Change https://go.dev/cl/642606 mentions this issue: [internal-branch.go1.24-vendor] http2: disable extended CONNECT by default

added
FixPendingIssues that have a fix which has not yet been reviewed or submitted.
on Jan 18, 2025
gopherbot

gopherbot commented on Jan 21, 2025

@gopherbot
Contributor

Change https://go.dev/cl/642398 mentions this issue: net/http: update bundled golang.org/x/net/http2 [generated]

added a commit that references this issue on Jan 21, 2025
f6d17c5
dmitshur

dmitshur commented on Jan 22, 2025

@dmitshur
Member

@cdujeu For the golang.org/x/net module specifically, CL 641475 has already been submitted, so you're able to upgrade to a new enough version of that module that includes that change – it doesn't need backports or anything like that. For example, go get golang.org/x/net@0a5dcdd8 will get you the pseudo-version v0.34.1-0.20250108183736-0a5dcdd8587c. The golang.org/x modules are tagged monthly, so next month golang.org/x/net's released version (likely v0.35.0) will also include CL 641475.

cdujeu

cdujeu commented on Jan 22, 2025

@cdujeu

Ok, thanks a lot for the clarification @dmitshur !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.NeedsFixThe path to resolution is known, but the work has not been done.release-blocker

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @neild@prattmic@dmitshur@cdujeu@gopherbot

      Issue actions

        net/http: do not enable HTTP/2 extended connect by default · Issue #71128 · golang/go