<?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-02" 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-02"/>
    <author fullname="Daniel James Vance">
      <organization>Independent</organization>
      <address>
        <email>djvanc@outlook.com</email>
      </address>
    </author>
    <date year="2025" month="November" day="08"/>
    <abstract>
      <?line 33?>

<t>This document is published as a historical record of the SOCKS 4 protocol. The original spec does not have an Abstract, so the Abstract below is added afterwards.</t>
      <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>This document describes the SOCKS Version 4 protocol, which is presented as a historical record. This protocol does not define any new protocol fields, codes, or registries that require assignment by the Internet Assigned Numbers Authority (IANA).</t>
      <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>
  </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="RFC793">
          <front>
            <title>Transmission Control Protocol</title>
            <author fullname="J. Postel" initials="J." surname="Postel"/>
            <date month="September" year="1981"/>
          </front>
          <seriesInfo name="RFC" value="793"/>
          <seriesInfo name="DOI" value="10.17487/RFC0793"/>
        </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>
      </references>
    </references>
    <?line 237?>

<section anchor="security-analysis">
      <name>Security Analysis</name>
      <t>The SOCKS Version 4 (SOCKSv4) protocol, designed for TCP proxy traversal of network firewalls, operates exclusively at the session layer and <strong>inherently lacks robust security mechanisms</strong>. Its deployment and operational policy must be rigorously evaluated against the deficiencies outlined herein.</t>
      <section anchor="authentication-and-authorization-deficiencies">
        <name>Authentication and Authorization Deficiencies</name>
        <section anchor="weak-client-identification-mechanism">
          <name>Weak Client Identification Mechanism</name>
          <t>The SOCKSv4 request format incorporates a <strong><tt>USERID</tt></strong> field. This field is designated for rudimentary client identification, typically intended for conjunction with the <strong>IDENT protocol</strong> (specified in [RFC 1413]).</t>
          <ul spacing="normal">
            <li>
              <t><strong>Ident Protocol Vulnerability:</strong> Reliance on IDENT constitutes a <strong>significant security risk</strong>. The IDENT protocol operates via an untrusted daemon resident on the client host, rendering the identification process susceptible to trivial <strong>spoofing or malicious disabling</strong>.</t>
            </li>
            <li>
              <t><strong>Absence of Strong Authentication:</strong> SOCKSv4 <strong>lacks integrated provisions</strong> for strong client-to-server or server-to-client authentication. This includes the absence of any mechanism for verifying user credentials, such as passwords, or employing cryptographic challenge-response methods.</t>
            </li>
          </ul>
        </section>
        <section anchor="policy-dependent-authorization">
          <name>Policy-Dependent Authorization</name>
          <t>Access control (authorization) for SOCKSv4 services is <strong>exclusively managed</strong> by the local configuration and security policy of the SOCKS server implementation. A failure in the server's configuration or a weakness in its policy can directly result in <strong>unauthorized network access</strong> across the protective boundary of the firewall.</t>
        </section>
      </section>
      <section anchor="data-integrity-and-transport-limitations">
        <name>Data Integrity and Transport Limitations</name>
        <section anchor="absence-of-confidentiality-plaintext-relay">
          <name>Absence of Confidentiality (Plaintext Relay)</name>
          <t>SOCKSv4 functions as a session layer relay and <strong>does not incorporate any encryption</strong> capabilities for the application data stream. All application traffic traversing the SOCKS proxy is forwarded in <strong>plaintext</strong>. This inherent vulnerability exposes all transmitted data to <strong>passive network eavesdropping</strong> and interception.</t>
        </section>
        <section anchor="protocol-scope-restriction">
          <name>Protocol Scope Restriction</name>
          <t>The SOCKSv4 protocol is <strong>strictly confined</strong> to the proxying of <strong>Transmission Control Protocol (TCP)</strong> connections. It provides <strong>no native support</strong> for the relay of <strong>User Datagram Protocol (UDP)</strong> traffic or other protocols operating at the IP layer.</t>
        </section>
      </section>
      <section anchor="vulnerabilities-associated-with-the-bind-operation">
        <name>Vulnerabilities Associated with the BIND Operation</name>
        <t>The <strong>BIND</strong> command, utilized to establish a socket for an anticipated inbound connection (a callback) from an application server, introduces distinct security challenges.</t>
        <section anchor="source-address-verification-bypass">
          <name>Source Address Verification Bypass</name>
          <t>The SOCKS server attempts a rudimentary security check during the BIND operation by comparing the source IP address of the incoming connection with the target address (<tt>DSTIP</tt>) specified in the client's request.</t>
          <ul spacing="normal">
            <li>
              <t>IP Address Spoofing Risk: A malicious actor could potentially forge the source IP address of the inbound connection, thereby bypassing this basic server check and facilitating the establishment of an unauthorized session.</t>
            </li>
            <li>
              <t><strong>NAT/PAT Incompatibility:</strong> In network topologies employing <strong>Network Address Translation (NAT)</strong> or <strong>Port Address Translation (PAT)</strong>, the source IP address is structurally altered. This modification renders the BIND source address verification mechanism <strong>unreliable, ineffectual, or operationally complex</strong> to maintain.</t>
            </li>
          </ul>
        </section>
      </section>
      <section anchor="denial-of-service-dos-vector">
        <name>Denial of Service (DoS) Vector</name>
        <section anchor="resource-exhaustion-potential">
          <name>Resource Exhaustion Potential</name>
          <t>Each successful SOCKS connection consumes finite server resources, including active sockets, allocated memory, and network bandwidth. A malicious client can exploit this by initiating a <strong>large volume of connection attempts</strong>—particularly through the resource-intensive <strong>BIND operation</strong>—to rapidly exhaust the SOCKS server's capacity. This constitutes a direct vector for a <strong>Denial of Service</strong> attack against legitimate users.</t>
        </section>
        <section anchor="inadequate-mitigations">
          <name>Inadequate Mitigations</name>
          <t>Although the protocol specifies a basic connection establishment <strong>timeout mechanism (2 minutes)</strong>, this measure is insufficient in scope and rigor to fully mitigate the risks associated with sophisticated DoS attacks.</t>
        </section>
      </section>
      <section anchor="recommended-mitigation-and-deployment-practices">
        <name>Recommended Mitigation and Deployment Practices</name>
        <t>Given the security deficiencies of SOCKSv4, deployment should be guided by the following principles:</t>
        <ol spacing="normal" type="1"><li>
            <t>Strict Operational Environment: SOCKSv4 is only recommended for use in environments designated as highly trusted and subject to stringent local policy control*.</t>
          </li>
          <li>
            <t>Layered Security via Encrypted Tunnels: 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 confidentiality and integrity.</t>
          </li>
          <li>
            <t>Protocol Migration: Operators should actively plan for the migration to or substitution with a more secure protocol version, specifically SOCKS Version 5 ([RFC 1928]), which incorporates native, robust authentication methods.</t>
          </li>
        </ol>
      </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:
H4sIAAAAAAAAA91cbXLjRpL9z1PUyD9M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