-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http,x/crypto/ssh: Hijack hangs when underlying net.Conn doesn't support SetReadDeadline #67152
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Comments
seankhliao
changed the title
net/http - x/crypto/ssh: golang cant do websockets in ssh tunnels
net/http,x/crypto/ssh: Hijack hangs when underlying net.Conn doesn't support SetReadDeadline
May 3, 2024
seankhliao
added
the
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
label
May 3, 2024
Big ➕1 on this one... I have an HTTP reverse proxy (i.e. It seems to me like adding setting/checking deadlines to the SSH channel objects (i.e. here) wouldn't be too hard? |
Change https://go.dev/cl/562756 mentions this issue: |
jeffwilliams
pushed a commit
to jeffwilliams/go-x-crypto
that referenced
this issue
Jul 28, 2024
This is actually Nicola Murino's fix from google source: https://go-review.googlesource.com/c/crypto/+/562756 deadlines unblock reads waiting for data and writes waiting for window capacity Fixes golang/go#65930 Fixes golang/go#67152 Change-Id: Ica42573cdf11ddf58e48b51fa82466a14cc5e606
espadolini
pushed a commit
to espadolini/xcrypto
that referenced
this issue
Dec 10, 2024
Fixes golang/go#65930 Fixes golang/go#67152 Change-Id: Ica42573cdf11ddf58e48b51fa82466a14cc5e606
espadolini
pushed a commit
to espadolini/xcrypto
that referenced
this issue
Jan 22, 2025
Fixes golang/go#65930 Fixes golang/go#67152 Change-Id: Ica42573cdf11ddf58e48b51fa82466a14cc5e606
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Go version
go version go1.22.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I was trying to have a web server forwarded through an SSH tunnel - I've made an example of this bug in fasmide/the-thing-about-websockets-and-ssh-tunnels
This all works out really well until web sockets are introduced.
This is because the http.response, which does Hijacking, tries to set its net.Conn's deadline to the past to have it unblock its current Read() - but x/crypto/ssh's implementation of net.Conn does not support this.
Furthermore, the http.response does not do any error checking when setting the deadline - so effectively the conn locks up without any indication to anyone about whats going on.
What did you see happen?
Using the example, one should find that using a local net.Listener — everything is fine; however, forwarding the listener through SSH tunnel's, the browser (both Chrome and Firefox) hangs indefinitely trying to connect.
Example of a working local listener:
When opening the webpage, look in the debugger for messages:
Example of a broken forwarded listener:
Now, when opening the same webpage, the websocket is stuck in
(pending)
:What did you expect to see?
I did not expect there to be any differences :)
I don't know if this bug is in net/http or x/crypto/ssh - but given that HTTP hijack'ing usually returns an error if it is unable to hijack a connection, I would imagine some error checking is to be expected in net/http when SetReadDeadline returns an error
The text was updated successfully, but these errors were encountered: