Skip to content

Bound the SOCKS5 handshake by the connect timeout - #1031

Merged
benoitc merged 1 commit into
masterfrom
fix/socks5-handshake-timeout
Nov 15, 2026
Merged

benoitc merged 1 commit into
masterfrom
fix/socks5-handshake-timeout

Conversation

@benoitc

@benoitc benoitc commented Nov 14, 2026

Copy link
Copy Markdown
Owner

The SOCKS5 handshake read the proxy's replies with an infinite timeout. connect_timeout only covered the TCP connect, so a proxy that accepted the connection and then stopped answering blocked the caller forever.

The whole handshake (greeting, auth, connect reply, bound address) now runs under one deadline taken from the connect timeout, like the TLS upgrade that follows it, and returns {error, timeout}. A short read of the bound address now returns an error instead of crashing on a badmatch. hackney_socks5:connect/3 keeps its infinite timeout.

The SOCKS5 replies were read with an infinite timeout, so a proxy that
accepted the connection and then stopped answering blocked the caller
forever. The handshake now runs under the connect timeout and returns
{error, timeout}.
@benoitc
benoitc merged commit 18ae451 into master Nov 15, 2026
11 of 12 checks passed
@benoitc
benoitc deleted the fix/socks5-handshake-timeout branch November 15, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant