<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.29 (Ruby 3.4.4) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-vance-socks-v4-03" category="historic" submissionType="independent" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.31.0 -->
  <front>
    <title abbrev="SOCKS4 SPEC">SOCKS Protocol Version 4 Specification</title>
    <seriesInfo name="Internet-Draft" value="draft-vance-socks-v4-03"/>
    <author fullname="Daniel James Vance">
      <organization>Independent</organization>
      <address>
        <email>djvanc@outlook.com</email>
      </address>
    </author>
    <date year="2025" month="November" day="14"/>
    <abstract>
      <?line 35?>

<t>This document describes SOCKS version 4, a protocol designed to facilitate TCP proxy services across a network firewall. SOCKS operates at the session layer, providing application users with transparent access to network services on the other side of the firewall. It is application-protocol independent, allowing it to support a wide range of services, including those utilizing encryption, while maintaining minimum processing overhead by simply relaying data after initial access control checks. The protocol defines two primary operations: CONNECT for establishing outbound connections to an application server, and BIND for preparing for and accepting inbound connections initiated by an application server.</t>
    </abstract>
    <note removeInRFC="true">
      <name>Discussion Venues</name>
      <t>Source for this draft and an issue tracker can be found at
    <eref target="https://github.com/4socks/socks4"/>.</t>
    </note>
  </front>
  <middle>
    <?line 40?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>The SOCKS protocol, Version 4 (SOCKSv4), <bcp14>SHALL</bcp14> be used to relay TCP sessions between an application client and an an application server via a SOCKS server, often positioned at a firewall host. The protocol <bcp14>MUST</bcp14> provide transparent access across the firewall for application users.</t>
      <t>The protocol <bcp14>MUST</bcp14> be application-protocol independent, allowing it to be used for various services, including, but not limited to, telnet, ftp, finger, whois, gopher, and WWW (World Wide Web).</t>
      <t>The SOCKS server <bcp14>MUST</bcp14> apply access control mechanisms at the beginning of each TCP session. Following successful establishment, the SOCKS server <bcp14>MUST</bcp14> simply relay data between the client and the application server, incurring minimum processing overhead. The protocol inherently supports applications utilizing encryption, as the SOCKS server is not required to interpret the application protocol's payload.</t>
      <t>Two primary operations are defined: CONNECT and BIND.</t>
    </section>
    <section anchor="conventions-and-terminology">
      <name>Conventions and Terminology</name>
      <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
      <?line -18?>

<t>This specification uses the following terms:</t>
      <ul spacing="normal">
        <li>
          <t>Client (Application Client): The program requesting a connection to an application server through the SOCKS server.</t>
        </li>
        <li>
          <t>SOCKS Server: The host, typically at a firewall, that intermediates the connection between the Client and the Application Server.</t>
        </li>
        <li>
          <t>Application Server: The host to which the Client ultimately wishes to connect (e.g., a Telnet daemon, an HTTP server).</t>
        </li>
        <li>
          <t>TCP Session: A connection established using the Transmission Control Protocol (TCP). SOCKSv4 only supports TCP sessions.</t>
        </li>
        <li>
          <t>DSTIP (Destination IP): The IP address of the Application Server, as specified in the SOCKS request.</t>
        </li>
        <li>
          <t>DSTPORT (Destination Port): The port number of the Application Server, as specified in the SOCKS request.</t>
        </li>
        <li>
          <t>USERID: A variable-length, NULL-terminated string identifying the client's user on the local system.</t>
        </li>
        <li>
          <t>NULL: A byte of all zero bits, used to terminate the USERID field.</t>
        </li>
        <li>
          <t>IDENT: A protocol (as described in RFC 1413) used by the SOCKS server to verify the user identity of the client.</t>
        </li>
      </ul>
    </section>
    <section anchor="connect-operation">
      <name>CONNECT Operation</name>
      <t>The client <bcp14>MUST</bcp14> initiate a CONNECT request when it desires to establish an outbound TCP connection to an application server.</t>
      <section anchor="connect-request-packet-format">
        <name>CONNECT Request Packet Format</name>
        <t>The client <bcp14>MUST</bcp14> send a request packet with the following structure:</t>
        <table>
          <name>CONNECT Request Packet Format</name>
          <thead>
            <tr>
              <th align="left">Field</th>
              <th align="left">Description</th>
              <th align="center">Size (bytes)</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">VN</td>
              <td align="left">Version Number</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">CD</td>
              <td align="left">Command Code</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">DSTPORT</td>
              <td align="left">Destination Port</td>
              <td align="center">2</td>
            </tr>
            <tr>
              <td align="left">DSTIP</td>
              <td align="left">Destination IP Address</td>
              <td align="center">4</td>
            </tr>
            <tr>
              <td align="left">USERID</td>
              <td align="left">User ID</td>
              <td align="center">variable</td>
            </tr>
            <tr>
              <td align="left">NULL</td>
              <td align="left">Null Terminator</td>
              <td align="center">1</td>
            </tr>
          </tbody>
        </table>
        <ul spacing="normal">
          <li>
            <t>VN (Version Number): <bcp14>MUST</bcp14> be 4, representing the SOCKS protocol version.</t>
          </li>
          <li>
            <t>CD (Command Code): <bcp14>MUST</bcp14> be 1, indicating a CONNECT request.</t>
          </li>
          <li>
            <t>DSTPORT (Destination Port): The port number of the application server (network byte order).</t>
          </li>
          <li>
            <t>DSTIP (Destination IP): The IP address of the application server (network byte order).</t>
          </li>
          <li>
            <t>USERID (User Identifier): A string of characters representing the client's user ID.</t>
          </li>
          <li>
            <t>NULL: A single byte with a value of all zero bits, terminating the USERID field.</t>
          </li>
        </ul>
      </section>
      <section anchor="connect-processing-and-reply">
        <name>CONNECT Processing and Reply</name>
        <t>The SOCKS server <bcp14>MUST</bcp14> determine whether to grant the request based on criteria such as the source IP address, DSTIP, DSTPORT, USERID, and information obtained via IDENT (cf. RFC 1413).</t>
        <t>If the request is granted, the SOCKS server <bcp14>MUST</bcp14> attempt to establish a TCP connection to the specified DSTPORT on the DSTIP.</t>
        <t>A reply packet <bcp14>MUST</bcp14> be sent to the client upon the establishment of the connection, rejection of the request, or operational failure.</t>
      </section>
      <section anchor="connect-reply-packet-format">
        <name>CONNECT Reply Packet Format</name>
        <t>The SOCKS server <bcp14>MUST</bcp14> send a reply packet with the following structure:</t>
        <table>
          <name>CONNECT Reply Packet Format</name>
          <thead>
            <tr>
              <th align="left">Field</th>
              <th align="left">Description</th>
              <th align="center">Size (bytes)</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">VN</td>
              <td align="left">Version Number</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">CD</td>
              <td align="left">Command Code</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">DSTPORT</td>
              <td align="left">Destination Port</td>
              <td align="center">2</td>
            </tr>
            <tr>
              <td align="left">DSTIP</td>
              <td align="left">Destination IP Address</td>
              <td align="center">4</td>
            </tr>
          </tbody>
        </table>
        <ul spacing="normal">
          <li>
            <t>VN: <bcp14>MUST</bcp14> be 0, representing the reply version code.</t>
          </li>
          <li>
            <t>CD (Result Code): The SOCKS server <bcp14>MUST</bcp14> use one of the following values:</t>
          </li>
        </ul>
        <table anchor="socks-version-4-reply-codes">
          <name>Result Codes</name>
          <thead>
            <tr>
              <th align="left">Reply Code</th>
              <th align="left">Description</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">90</td>
              <td align="left">Request granted (Connection successful).</td>
            </tr>
            <tr>
              <td align="left">91</td>
              <td align="left">Request rejected or failed.</td>
            </tr>
            <tr>
              <td align="left">92</td>
              <td align="left">Request rejected due to inability to connect to <tt>identd</tt> on the client.</td>
            </tr>
            <tr>
              <td align="left">93</td>
              <td align="left">Request rejected because the client program and <tt>identd</tt> report different user-IDs.</td>
            </tr>
          </tbody>
        </table>
        <ul spacing="normal">
          <li>
            <t>DSTPORT and DSTIP: These fields <bcp14>MUST</bcp14> be ignored by the client in a CONNECT reply.</t>
          </li>
        </ul>
        <t>If the request is rejected or failed (CD != 90), the SOCKS server <bcp14>MUST</bcp14> close its connection to the client immediately after sending the reply.</t>
        <t>If the request is successful (CD = 90), the SOCKS server <bcp14>MUST</bcp14> immediately begin relaying traffic in both directions between the client connection and the established application server connection. The client <bcp14>MUST</bcp14> then treat its connection to the SOCKS server as if it were a direct connection to the application server.</t>
      </section>
    </section>
    <section anchor="bind-operation">
      <name>BIND Operation</name>
      <t>The client <bcp14>MUST</bcp14> initiate a BIND request when it requires the SOCKS server to prepare for an inbound connection from an application server. This operation is typically used for protocols that involve a secondary data connection originating from the server (e.g., FTP's active mode). A BIND request <bcp14>SHOULD</bcp14> only be sent after a primary connection to the application server has been successfully established using a CONNECT request.</t>
      <section anchor="bind-request-packet-format">
        <name>BIND Request Packet Format</name>
        <t>The client <bcp14>MUST</bcp14> send a request packet identical in format to the CONNECT request:</t>
        <table anchor="socks-version-4-request-format">
          <name>BIND Request Packet Format</name>
          <thead>
            <tr>
              <th align="left">Field</th>
              <th align="left">Description</th>
              <th align="center">Size (bytes)</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">VN</td>
              <td align="left">Version Number (must be 4)</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">CD</td>
              <td align="left">Command Code (1 for CONNECT, 2 for BIND)</td>
              <td align="center">1</td>
            </tr>
            <tr>
              <td align="left">DSTPORT</td>
              <td align="left">Destination Port (Network Byte Order)</td>
              <td align="center">2</td>
            </tr>
            <tr>
              <td align="left">DSTIP</td>
              <td align="left">Destination IP Address</td>
              <td align="center">4</td>
            </tr>
            <tr>
              <td align="left">USERID</td>
              <td align="left">User ID (String of Octets)</td>
              <td align="center">variable</td>
            </tr>
            <tr>
              <td align="left">NULL</td>
              <td align="left">Null Terminator (0x00)</td>
              <td align="center">1</td>
            </tr>
          </tbody>
        </table>
        <ul spacing="normal">
          <li>
            <t>VN: <bcp14>MUST</bcp14> be 4.</t>
          </li>
          <li>
            <t>CD: <bcp14>MUST</bcp14> be 2, indicating a BIND request.</t>
          </li>
          <li>
            <t>DSTPORT: The port number of the primary connection to the application server.</t>
          </li>
          <li>
            <t>DSTIP: The IP address of the application server.</t>
          </li>
          <li>
            <t>USERID and NULL: As defined for the CONNECT request.</t>
          </li>
        </ul>
      </section>
      <section anchor="bind-first-reply-socket-assignment">
        <name>BIND First Reply (Socket Assignment)</name>
        <t>The SOCKS server <bcp14>MUST</bcp14> first decide whether to grant the BIND request. The reply format <bcp14>MUST</bcp14> be the same as the CONNECT reply format.</t>
        <t>If the request is rejected (CD != 90), the SOCKS server <bcp14>MUST</bcp14> close its connection to the client immediately.</t>
        <t>If the request is granted (CD = 90):</t>
        <t>1. The SOCKS server <bcp14>MUST</bcp14> obtain a local socket and begin listening for an incoming connection.
2. The SOCKS server <bcp14>MUST</bcp14> send a first reply packet where the DSTPORT and DSTIP fields are meaningful:
    - DSTPORT <bcp14>MUST</bcp14> contain the port number of the newly listening socket (network byte order).
    - DSTIP <bcp14>MUST</bcp14> contain the IP address of the SOCKS server's listening interface (network byte order).
3.  If the SOCKS server returns a DSTIP of 0 (the value of constant 'INADDR_ANY'), the client <bcp14>MUST</bcp14> replace this value with the IP address of the SOCKS server to which the client is currently connected.
4.  The client <bcp14>MUST</bcp14> use this IP address and port to inform the application server via the primary connection, enabling the application server to initiate the anticipated inbound connection to the SOCKS server.</t>
      </section>
      <section anchor="bind-second-reply-connection-established">
        <name>BIND Second Reply (Connection Established)</name>
        <t>The SOCKS server <bcp14>MUST</bcp14> send a second reply packet to the client once the anticipated inbound connection from the application server is established. The reply format <bcp14>MUST</bcp14> be the same as the first reply.</t>
        <t>The SOCKS server <bcp14>MUST</bcp14> check the IP address of the newly connected application server host against the DSTIP value specified in the client's original BIND request.</t>
        <ul spacing="normal">
          <li>
            <t>If the IP addresses match: The CD field in the second reply <bcp14>MUST</bcp14> be set to 90. The SOCKS server <bcp14>MUST</bcp14> then prepare to relay traffic between the client connection and the new application server connection.</t>
          </li>
          <li>
            <t>If a mismatch is found: The CD field in the second reply <bcp14>MUST</bcp14> be set to 91. The SOCKS server <bcp14>MUST</bcp14> immediately close both the client connection and the connection from the application server.</t>
          </li>
        </ul>
        <t>Upon a successful second reply, the client <bcp14>MUST</bcp14> perform I/O on its connection to the SOCKS server as if it were directly connected to the application server.</t>
      </section>
    </section>
    <section anchor="timeout-mechanism">
      <name>Timeout Mechanism</name>
      <t>For both CONNECT and BIND operations, the SOCKS server <bcp14>MUST</bcp14> employ a time limit for the establishment of its connection with the application server (e.g., 2 minutes). If the connection is not established before the time limit expires, the SOCKS server <bcp14>MUST</bcp14> close its connection to the client and abort the operation.</t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>See <xref target="security-analysis"/>.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>No IANA actions required.</t>
      <t>See <xref target="existing-values"/> for the existing values used within the protocol.</t>
    </section>
  </middle>
  <back>
    <references anchor="sec-combined-references">
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>
        <reference anchor="RFC1413">
          <front>
            <title>Identification Protocol</title>
            <author fullname="M. St. Johns" initials="M." surname="St. Johns"/>
            <date month="February" year="1993"/>
            <abstract>
              <t>The Identification Protocol was formerly called the Authentication Server Protocol. It has been renamed to better reflect its function. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="1413"/>
          <seriesInfo name="DOI" value="10.17487/RFC1413"/>
        </reference>
        <reference anchor="SOCKS4">
          <front>
            <title>SOCKS: A protocol for TCP proxy across firewalls</title>
            <author initials="Y.-D." surname="Lee" fullname="Ying-Da Lee">
              <organization>NEC Systems Laboratory, CSTC</organization>
            </author>
            <date>n.d.</date>
          </front>
        </reference>
        <reference anchor="RFC2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner"/>
            <date month="March" year="1997"/>
            <abstract>
              <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba"/>
            <date month="May" year="2017"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
      </references>
      <references anchor="sec-informative-references">
        <name>Informative References</name>
        <reference anchor="RFC791">
          <front>
            <title>Internet Protocol</title>
            <author fullname="J. Postel" initials="J." surname="Postel"/>
            <date month="September" year="1981"/>
          </front>
          <seriesInfo name="STD" value="5"/>
          <seriesInfo name="RFC" value="791"/>
          <seriesInfo name="DOI" value="10.17487/RFC0791"/>
        </reference>
        <reference anchor="RFC9293">
          <front>
            <title>Transmission Control Protocol (TCP)</title>
            <author fullname="W. Eddy" initials="W." role="editor" surname="Eddy"/>
            <date month="August" year="2022"/>
            <abstract>
              <t>This document specifies the Transmission Control Protocol (TCP). TCP is an important transport-layer protocol in the Internet protocol stack, and it has continuously evolved over decades of use and growth of the Internet. Over this time, a number of changes have been made to TCP as it was specified in RFC 793, though these have only been documented in a piecemeal fashion. This document collects and brings those changes together with the protocol specification from RFC 793. This document obsoletes RFC 793, as well as RFCs 879, 2873, 6093, 6429, 6528, and 6691 that updated parts of RFC 793. It updates RFCs 1011 and 1122, and it should be considered as a replacement for the portions of those documents dealing with TCP requirements. It also updates RFC 5961 by adding a small clarification in reset handling while in the SYN-RECEIVED state. The TCP header control bits from RFC 793 have also been updated based on RFC 3168.</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="7"/>
          <seriesInfo name="RFC" value="9293"/>
          <seriesInfo name="DOI" value="10.17487/RFC9293"/>
        </reference>
        <reference anchor="RFC1928">
          <front>
            <title>SOCKS Protocol Version 5</title>
            <author fullname="M. Leech" initials="M." surname="Leech"/>
            <author fullname="M. Ganis" initials="M." surname="Ganis"/>
            <author fullname="Y. Lee" initials="Y." surname="Lee"/>
            <author fullname="R. Kuris" initials="R." surname="Kuris"/>
            <author fullname="D. Koblas" initials="D." surname="Koblas"/>
            <author fullname="L. Jones" initials="L." surname="Jones"/>
            <date month="March" year="1996"/>
            <abstract>
              <t>This memo describes a protocol that is an evolution of the previous version of the protocol, version 4 [1]. This new protocol stems from active discussions and prototype implementations. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="1928"/>
          <seriesInfo name="DOI" value="10.17487/RFC1928"/>
        </reference>
        <reference anchor="RFC1929">
          <front>
            <title>Username/Password Authentication for SOCKS V5</title>
            <author fullname="M. Leech" initials="M." surname="Leech"/>
            <date month="March" year="1996"/>
            <abstract>
              <t>The protocol specification for SOCKS Version 5 specifies a generalized framework for the use of arbitrary authentication protocols in the initial socks connection setup. This document describes one of those protocols, as it fits into the SOCKS Version 5 authentication "subnegotiation". [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="1929"/>
          <seriesInfo name="DOI" value="10.17487/RFC1929"/>
        </reference>
        <reference anchor="RFC3552">
          <front>
            <title>Guidelines for Writing RFC Text on Security Considerations</title>
            <author fullname="E. Rescorla" initials="E." surname="Rescorla"/>
            <author fullname="B. Korver" initials="B." surname="Korver"/>
            <date month="July" year="2003"/>
            <abstract>
              <t>All RFCs are required to have a Security Considerations section. Historically, such sections have been relatively weak. This document provides guidelines to RFC authors on how to write a good Security Considerations section. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="72"/>
          <seriesInfo name="RFC" value="3552"/>
          <seriesInfo name="DOI" value="10.17487/RFC3552"/>
        </reference>
        <reference anchor="RFC3365">
          <front>
            <title>Strong Security Requirements for Internet Engineering Task Force Standard Protocols</title>
            <author fullname="J. Schiller" initials="J." surname="Schiller"/>
            <date month="August" year="2002"/>
          </front>
          <seriesInfo name="BCP" value="61"/>
          <seriesInfo name="RFC" value="3365"/>
          <seriesInfo name="DOI" value="10.17487/RFC3365"/>
        </reference>
      </references>
    </references>
    <?line 212?>

<section anchor="security-analysis">
      <name>Security Analysis</name>
      <t>The SOCKS Version 4 (SOCKSv4) protocol, designed exclusively for TCP proxy traversal across network firewalls, is fundamentally weak from a security perspective as it operates solely at the session layer and lacks intrinsic security mechanisms. Any deployment of SOCKSv4 must be critically assessed against its inherent deficiencies.</t>
      <section anchor="authentication-and-authorization-deficiencies">
        <name>Authentication and Authorization Deficiencies</name>
        <t>SOCKSv4's client identification relies on the USERID field, often intended for use with the IDENT protocol (specified in RFC 1413). This reliance constitutes a major security risk because the IDENT protocol depends on an untrusted daemon on the client host, making the identification process susceptible to trivial spoofing or malicious disabling. Crucially, SOCKSv4 entirely lacks integrated provisions for strong client-to-server or server-to-client authentication, offering no mechanisms for verifying user credentials, passwords, or employing cryptographic challenge-response methods. Consequently, access control (authorization) is managed exclusively by the SOCKS server's local configuration and security policy. A failure in the server's policy or configuration directly risks granting unauthorized network access across the protective boundary of the firewall.</t>
      </section>
      <section anchor="data-integrity-and-transport-limitations">
        <name>Data Integrity and Transport Limitations</name>
        <t>SOCKSv4 does not incorporate any encryption capabilities for the application data stream. As a session layer relay, it forwards all application traffic, including sensitive data, in plaintext. This inherent vulnerability exposes all transmitted data to passive network eavesdropping and interception, resulting in a total absence of confidentiality. Furthermore, the protocol’s operational scope is strictly confined to proxying Transmission Control Protocol (TCP) connections. It provides no native support for the relay of User Datagram Protocol (UDP) traffic or other IP-layer protocols, limiting its utility and scope of protection.</t>
      </section>
      <section anchor="vulnerabilities-associated-with-the-bind-operation">
        <name>Vulnerabilities Associated with the BIND Operation</name>
        <t>The BIND command, used for establishing a socket for an anticipated inbound connection (a callback) from an application server, introduces distinct security challenges. The SOCKS server attempts a rudimentary security check by comparing the source IP address of the incoming connection with the target address (DSTIP) specified in the client's request. However, a malicious actor can easily forge the source IP address of the inbound connection, potentially bypassing this basic server check and facilitating an unauthorized session. Moreover, in network topologies employing Network Address Translation (NAT) or Port Address Translation (PAT), the source IP address is structurally altered, rendering the BIND source address verification mechanism unreliable, ineffectual, or operationally complex to maintain.</t>
      </section>
      <section anchor="denial-of-service-dos-vector">
        <name>Denial of Service (DoS) Vector</name>
        <t>Every successful SOCKS connection consumes finite server resources, including active sockets, allocated memory, and network bandwidth. A direct vector for a Denial of Service attack exists where a malicious client can exploit this resource consumption by initiating a large volume of connection attempts, particularly through the resource-intensive BIND operation, to rapidly exhaust the SOCKS server’s capacity. Although the protocol specifies a basic connection establishment timeout mechanism (2 minutes), this measure is entirely insufficient in scope and rigor to fully mitigate the risks associated with sophisticated DoS attacks.</t>
      </section>
      <section anchor="recommended-mitigation-and-deployment-practices">
        <name>Recommended Mitigation and Deployment Practices</name>
        <t>Given SOCKSv4's security deficiencies, its deployment should be strictly limited to environments designated as highly trusted and subject to stringent local policy control. Where SOCKSv4 must transport sensitive application traffic, the protocol must be encapsulated within an existing secure transport layer, such as a Transport Layer Security (TLS/SSL) or IPsec tunnel, to establish the essential confidentiality and integrity mechanisms that SOCKSv4 lacks. Operators should actively plan for migration to SOCKS Version 5 (RFC 1928), which incorporates native, robust authentication methods.</t>
      </section>
    </section>
    <section anchor="existing-values">
      <name>Existing Values</name>
      <t>The existing values used within the protocol are summarized below:</t>
      <section anchor="socks-protocol-version-number-vn">
        <name>SOCKS Protocol Version Number (VN)</name>
        <ul spacing="normal">
          <li>
            <t>The SOCKS protocol version number <tt>VN</tt> in requests is 4 (0x04).</t>
          </li>
          <li>
            <t>The SOCKS protocol version number <tt>VN</tt> in replies is 0 (0x00).</t>
          </li>
        </ul>
      </section>
      <section anchor="socks-command-code-cd">
        <name>SOCKS Command Code (CD)</name>
        <t>The SOCKS command code <tt>CD</tt> in requests defines two values:</t>
        <ul spacing="normal">
          <li>
            <t>1 (0x01): CONNECT</t>
          </li>
          <li>
            <t>2 (0x02): BIND</t>
          </li>
        </ul>
      </section>
      <section anchor="socks-reply-code-cd">
        <name>SOCKS Reply Code (CD)</name>
        <t>The SOCKS reply code <tt>CD</tt> in replies defines four values:</t>
        <ul spacing="normal">
          <li>
            <t>90 (0x5A): Request granted</t>
          </li>
          <li>
            <t>91 (0x5B): Request rejected or failed</t>
          </li>
          <li>
            <t>92 (0x5C): Request rejected because SOCKS server cannot connect to <tt>identd</tt> on the client</t>
          </li>
          <li>
            <t>93 (0x5D): Request rejected because the client program and <tt>identd</tt> report different user-ids</t>
          </li>
        </ul>
      </section>
      <section anchor="port-number">
        <name>Port Number</name>
        <t>The SOCKS protocol is conventionally known to use TCP port 1080 for its service. This port number has already been registered in the IANA Service Name and Transport Protocol Port Number Registry for the <tt>socks</tt> service.</t>
      </section>
    </section>
    <section numbered="false" anchor="original-auther">
      <name>Original Auther</name>
      <artwork><![CDATA[
      Ying-Da Lee
      Principal Member Technical Staff
      NEC Systems Laboratory, CSTC
      ylee@syl.dl.nec.com

      David Koblas
      Netskope
]]></artwork>
      <t>We sincerely apologize that, due to the document's long history and the passage of time, many early contributors may not have been formally included in this list. We extend our deepest gratitude to all who have contributed to this work. If you believe your name should be added to the acknowledgments, please contact the draft maintainers.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA91b3XbbRpK+51P0KBehckiOJMs7sc5kZhTS3mhHlrSmbJ+c
nT1rEGiSiEA0Fw1IZmzv2dfYuzxLHmWfZ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