Skip to content

Fix SOCKS5 dynamic forwarding of fragmented and pipelined requests - #912

Open
mucinoab wants to merge 1 commit into
apache:masterfrom
mucinoab:socks5-fragmentation
Open

Fix SOCKS5 dynamic forwarding of fragmented and pipelined requests#912
mucinoab wants to merge 1 commit into
apache:masterfrom
mucinoab:socks5-fragmentation

Conversation

@mucinoab

@mucinoab mucinoab commented Aug 11, 2026

Copy link
Copy Markdown

The SOCKS5 proxy used for dynamic port forwarding parsed each read as a complete message, throwing a buffer underflow when the greeting or the CONNECT request arrived split across several reads. It also reused the CONNECT request buffer as the reply, echoing request bytes (and any application data pipelined after the request) back to the client instead of forwarding them.

Rewrite Socks5 as a state machine with a retained buffer: parse only once a message is complete and queue bytes received before the channel opens, forwarding them once it is up.

The state is synchronized because channel open and write futures complete on other threads.

Fixes #911

The SOCKS5 proxy used for dynamic port forwarding parsed each read as a
complete message, throwing a buffer underflow when the greeting or the
CONNECT request arrived split across several reads. It also reused the
CONNECT request buffer as the reply, echoing request bytes (and any
application data pipelined after the request) back to the client instead
of forwarding them.

Rewrite Socks5 as a state machine with a retained buffer: parse only
once a message is complete and queue bytes received before the channel
opens, forwarding them once it is up.

The state is synchronized because channel open and write futures
complete on other threads.
@mucinoab
mucinoab force-pushed the socks5-fragmentation branch from a7cb206 to d9a8c39 Compare August 18, 2026 16:44
@mucinoab

Copy link
Copy Markdown
Author

@tomaswolf could you please trigger a pipeline run again. Thank you.

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.

SocksProxy mishandles fragmented and pipelined CONNECT requests and corrupts the reply

1 participant