Skip to content
WebsiteHosting.com

concept Networks

SOCKS5 TCP and UDP association lifecycle

SOCKS5 uses TCP to set up a UDP association, not to carry its datagrams. A successful reply identifies the UDP relay; closing the TCP connection that carried the request ends the association.

Latest recorded source check · P0104

What it means

SOCKS5 sets up a UDP relay over a TCP control connection, but the UDP datagrams do not travel inside that connection. The client and proxy first negotiate a method over TCP. The client can then request UDP ASSOCIATE. If the request succeeds, the client sends datagrams to the UDP relay. When the TCP connection used for that request ends, so does the association.

Try it

Simulation: Start with the successful UDP ASSOCIATE example. The scenario evidence is provided, negotiation is accepted, the command is udp, the request address is valid, and the server reply is success. With the TCP control connection open, the result is UDP relay.

SOCKS5 TCP and UDP association lifecycle

Show how SOCKS5 command, relay and UDP association depend on a TCP control connection

Simulation
Modeled outcome: Udp association

UDP relay association depends on its TCP control connection.

SOCKS5 TCP and UDP association lifecycle: synthetic scenario inputs
Replaces all inputs with the documented starting example and the indicated change. Reset restores the starting example.
TCP control and application paths

TCP control

  1. Negotiationaccepted
  2. Addressvalid
  3. Commandudp
  4. Replysuccess
  5. Connectionopen

Application path

  1. TCP streamNot the UDP path
  2. UDP datagramsSeparate relay available

A successful reply establishes a relay; only UDP ASSOCIATE uses a separate UDP lane. Closing the TCP connection ends that association.

Evaluated inputs

Required scenario evidence
provided
Negotiation
accepted
Request address
valid
Command
udp
Server reply
success
TCP control connection
open

Symbolic request validation, CONNECT and UDP ASSOCIATE only; excludes BIND, authentication details, actual packets and unrestricted forwarding.

About this model

The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.

Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.

Change only TCP control connection to closed. Leave the successful reply in place. The result becomes no relay: the reply tells you the request succeeded at setup, while the connection state tells you the association has since ended. Those observations are consistent.

Use Reset to restore the original choices. Now change only Command from udp to connect. The result is stream. This time the client uses the open TCP connection to carry a byte stream rather than to maintain a separate UDP association. These are local examples; no proxy is contacted and no traffic is sent.

What the reply establishes

Negotiation and the command reply answer different questions. Negotiation determines whether the client and proxy have an acceptable method. If they do not, there is no command phase. For example, select rejected for negotiation and unsupported for the command. The result is no command, not “command unsupported”: the proxy never gets as far as the command in that scenario.

After successful negotiation, the command matters. For CONNECT, a successful reply lets the client start using the TCP stream. For UDP ASSOCIATE, the successful reply identifies the relay address and port to which the client should send UDP datagrams. TCP carries the request and reply; UDP carries the datagrams. The TCP connection still matters even when all the application traffic in the example is UDP.

The two lanes in the lab deliberately separate the setup exchange from the application’s data path. With UDP selected and negotiation accepted, set the server reply to failure while keeping the TCP connection open. The selected open state is not evaluated after a failure reply; no successful association was established. An open socket alone would not establish a successful command reply.

Read no relay together with its reason. In the simulation, a malformed request address stops evaluation before command support is considered. An unsupported command stops it before the selected reply is considered. A failure reply means setup did not succeed. Closure after a successful reply is different: the association was established, but it no longer exists. If required evidence is missing, the result is unknown, not no relay.

In practice

When interpreting a client's record of a SOCKS5 session, ask what it shows at the time in question. An accepted method does not show that UDP ASSOCIATE succeeded. A successful UDP ASSOCIATE reply identifies where the client could send datagrams at setup; it does not acknowledge receipt of any particular datagram. Even with the association open, the relay can decline to forward a datagram.

Keep protection separate from setup, too. The username/password method specified in RFC 1929 does not itself encrypt the password. Selecting a method is not evidence that application data is confidential. This simulation does not perform authentication, inspect packets, calculate header sizes, or model BIND or unrestricted forwarding.

If all you have is an earlier success reply, look for evidence about the same TCP connection before concluding that the UDP association still exists. Its closure settles the lifetime question for that association. Without its subsequent state, the reply is evidence of establishment, not a permanent relay reservation.

Frequently asked questions

Editorial questions, answered from the sources listed for this article.

Is UDP tunneled as TCP data?

UDP association specifies a UDP relay; TCP is its control channel.

What happens if the control channel closes?

The UDP association terminates when the TCP connection used for its UDP ASSOCIATE request ends. The relay endpoint is therefore not a permanent independent allocation.

Does SOCKS5 guarantee confidentiality?

No; security depends on the selected method and application protection.

Does a successful UDP ASSOCIATE reply acknowledge a datagram?

No. The reply identifies the relay endpoint for subsequent UDP traffic; it is not an acknowledgment of a particular datagram. The relay can discard traffic, so establishment and delivery are separate observations.

Sources & model boundaries

Primary references used for this explanation. The interactive example is an educational model, not a live check.

  1. RFC 1928: SOCKS Protocol Version 5

    3–7. UDP association ends with its TCP control connection. Authentication-method encapsulation can add protection; source IP filtering and relay refusal are part of the specified behavior.

    Checked .

  2. RFC 1929: Username/Password Authentication for SOCKS V5

    §3. The SOCKS username/password method described in RFC1929 does not encrypt the password. Method selection is not evidence that the relay protects application data.

    Checked .

Report an issue. Include the article URL and ID, not passwords or access keys.