In RFC 1928, it states:
It is expected that a SOCKS server will use DST.ADDR and DST.PORT in evaluating the BIND request.
And that's the only info about the DST
fields in a BIND
request context.
What's its purpose?
Perhaps it's the address and port of the host which the client wants to bind to? If so, should the server restrict incoming connection to the host as specified in DST
fields?
RFC 1928 for SOCKS v5 does not explicitly state the use of DST.ADDR
and DST.PORT
in the BIND
request. However, SOCKS v5 builds on top of SOCKS v4, and the SOCKS v4 spec does explain it:
The SOCKS server sends a second reply packet to the client when the anticipated connection from the application server is established. The SOCKS server checks the IP address of the originating host against the value of DSTIP specified in the client's BIND request. If a mismatch is found, the CD field in the second reply is set to 91 and the SOCKS server closes both connections. If the two match, CD in the second reply is set to 90 and the SOCKS server gets ready to relay the traffic on its two connections. From then on the client does I/O on its connection to the SOCKS server as if it were directly connected to the application server.
So, it is used by the client to let the SOCKS server know who is expected to be connecting to its newly-BIND
'ed port. If any other party connects, the current session with the client is terminated.