<?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.30 (Ruby 3.4.8) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-vance-socks-v4a-01" category="historic" submissionType="independent" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.31.0 -->
  <front>
    <title abbrev="SOCKS 4A">SOCKS Protocol Version 4A</title>
    <seriesInfo name="Internet-Draft" value="draft-vance-socks-v4a-01"/>
    <author fullname="Daniel James Vance">
      <organization>Independent</organization>
      <address>
        <email>djvanc@outlook.com</email>
      </address>
    </author>
    <date year="2026" month="February" day="16"/>
    <abstract>
      <?line 48?>

<t>This document specifies SOCKS 4A, an extension to the SOCKS Version 4 protocol. This extension allows SOCKS clients to delegate domain name resolution to the SOCKS server. This is particularly useful in environments where the client host cannot resolve the destination host's domain name due to restrictive network policies or lack of DNS access.</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 52?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>The original SOCKSv4 protocol requires the client to provide the destination host's IPv4 address. However, in many firewall configurations, the client resides on a network without direct DNS access to the outside world. SOCKS 4A addresses this by allowing the client to provide a domain name string instead of a resolved IP address.</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>
      </ul>
    </section>
    <section anchor="protocol-mechanism">
      <name>Protocol Mechanism</name>
      <t>The SOCKS 4A extension is triggered by a specific, non-routable pattern in the <tt>DSTIP</tt> field of a standard SOCKSv4 request.</t>
      <section anchor="request-format">
        <name>Request Format</name>
        <t>To initiate a SOCKS 4A request (either CONNECT or BIND), the client sends a packet with the following structure:</t>
        <table anchor="socks4a-req-format">
          <name>SOCKS 4A Request Structure</name>
          <thead>
            <tr>
              <th align="left">Field</th>
              <th align="left">Description</th>
              <th align="left">Size (bytes)</th>
              <th align="left">Value/Notes</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">VN</td>
              <td align="left">Version Number</td>
              <td align="left">1</td>
              <td align="left">0x04</td>
            </tr>
            <tr>
              <td align="left">CD</td>
              <td align="left">Command Code</td>
              <td align="left">1</td>
              <td align="left">0x01 (CONNECT) or 0x02 (BIND)</td>
            </tr>
            <tr>
              <td align="left">DSTPORT</td>
              <td align="left">Destination Port</td>
              <td align="left">2</td>
              <td align="left">Network Byte Order</td>
            </tr>
            <tr>
              <td align="left">DSTIP</td>
              <td align="left">Destination IP</td>
              <td align="left">4</td>
              <td align="left">0x00, 0x00, 0x00, x (x != 0)</td>
            </tr>
            <tr>
              <td align="left">USERID</td>
              <td align="left">User Identifier</td>
              <td align="left">variable</td>
              <td align="left">Variable length, NULL terminated</td>
            </tr>
            <tr>
              <td align="left">DOMAIN</td>
              <td align="left">Destination Domain</td>
              <td align="left">variable</td>
              <td align="left">Variable length, NULL terminated</td>
            </tr>
          </tbody>
        </table>
        <section anchor="dstip-encoding-and-signaling">
          <name>DSTIP Encoding and Signaling</name>
          <t>To signal a SOCKS 4A extension request, the client <bcp14>MUST</bcp14> set the first three octets of the DSTIP field to 0x00 and the final octet to a non-zero value in network byte order (i.e., representing an IPv4 address in the range 0.0.0.1 through 0.0.0.255).</t>
          <t>This specific address range, part of the 0.0.0.0/8 block, is reserved by IANA for "this host on this network" <xref target="RFC1122"/> and is not a routable destination. This ensures that the 4A signal is syntactically distinct from standard SOCKSv4 requests. A SOCKS server receiving such a DSTIP <bcp14>MUST</bcp14> ignore its numerical value and proceed to extract the destination address from the DOMAIN field as defined in <xref target="destination-domain-name-field"/>.</t>
        </section>
        <section anchor="destination-domain-name-field">
          <name>Destination Domain Name Field</name>
          <t>The <tt>DOMAIN</tt> field contains the fully qualified domain name (FQDN) of the application server. To ensure protocol stability and prevent common parsing errors, the following rules <bcp14>MUST</bcp14> be observed:</t>
          <ul spacing="normal">
            <li>
              <t>Positioning: The <tt>DOMAIN</tt> field <bcp14>MUST</bcp14> begin immediately after the <tt>NULL</tt> (0x00) terminator of the <tt>USERID</tt> field.</t>
            </li>
            <li>
              <t>Encoding: The domain name <bcp14>SHOULD</bcp14> be encoded in US-ASCII. While some implementations support Internationalized Domain Names (IDNs), clients <bcp14>SHOULD</bcp14> use the Punycode-encoded A-label format <xref target="RFC5891"/> to ensure maximum compatibility.</t>
            </li>
            <li>
              <t>Termination: The field <bcp14>MUST</bcp14> be terminated by a single <tt>NULL</tt> (0x00) octet.</t>
            </li>
            <li>
              <t>Length Constraints: The <tt>DOMAIN</tt> string (excluding the terminator) <bcp14>SHOULD NOT</bcp14> exceed <strong>255 octets</strong>, consistent with the maximum length of a FQDN defined in <xref target="RFC1035"/>. Servers <bcp14>SHOULD</bcp14> enforce a maximum buffer limit for this field to mitigate resource exhaustion attacks.</t>
            </li>
          </ul>
        </section>
      </section>
    </section>
    <section anchor="server-processing">
      <name>Server Processing</name>
      <t>Upon receipt of a client request, a SOCKS 4A compliant server <bcp14>MUST</bcp14> process the data according to the following sequential states:</t>
      <section anchor="initial-header-parsing">
        <name>Initial Header Parsing</name>
        <t>The server <bcp14>MUST</bcp14> first read the fixed-length 8-octet header. It <bcp14>SHALL</bcp14> evaluate the fields as follows:</t>
        <ul spacing="normal">
          <li>
            <t>VN: If the version number is not 4, the server <bcp14>SHOULD</bcp14> terminate the connection.</t>
          </li>
          <li>
            <t>CD: The server determines the requested operation (CONNECT or BIND).</t>
          </li>
          <li>
            <t>DSTPORT: The destination port is extracted for later use in the connection attempt.</t>
          </li>
          <li>
            <t>DSTIP: The server inspects the four-octet destination IP address to determine the routing mode (Standard SOCKSv4 or SOCKS 4A).</t>
          </li>
        </ul>
      </section>
      <section anchor="routing-mode-selection-and-field-extraction">
        <name>Routing Mode Selection and Field Extraction</name>
        <t>The server <bcp14>MUST</bcp14> apply the following logic based on the <tt>DSTIP</tt> value:</t>
        <ol spacing="normal" type="1"><li>
            <t>SOCKS 4A Signaling: If the first three octets of <tt>DSTIP</tt> are zero and the fourth octet is non-zero (0.0.0.x, where x != 0), the server <bcp14>SHALL</bcp14> enter the SOCKS 4A extended resolution mode. The server <bcp14>MUST</bcp14> continue to read the input stream to extract the <tt>USERID</tt> string, defined as all octets up to and including the first <tt>NULL</tt> (0x00) terminator. Immediately following the <tt>USERID</tt> terminator, the server <bcp14>MUST</bcp14> continue reading to extract the <tt>DOMAIN</tt> string, defined as all octets up to and including the second <tt>NULL</tt> (0x00) terminator.</t>
          </li>
          <li>
            <t>Standard SOCKSv4 Handling: If the <tt>DSTIP</tt> does not match the 0.0.0.x pattern (including the case of 0.0.0.0), the server <bcp14>MUST</bcp14> follow the standard SOCKSv4 procedure, extracting only the <tt>USERID</tt> field. In this mode, the server <bcp14>MUST NOT</bcp14> attempt to read or interpret any data following the first <tt>NULL</tt> terminator as a domain name.</t>
          </li>
        </ol>
      </section>
      <section anchor="name-resolution-and-execution">
        <name>Name Resolution and Execution</name>
        <t>In SOCKS 4A mode, once the <tt>DOMAIN</tt> string is extracted:</t>
        <ul spacing="normal">
          <li>
            <t>Resolution: The server <bcp14>SHALL</bcp14> attempt to resolve the ASCII-encoded domain name to a valid IPv4 address using the server's local DNS resolver or host lookup mechanism.</t>
          </li>
          <li>
            <t>Successful Resolution: If the domain resolves to one or more IPv4 addresses, the server <bcp14>SHOULD</bcp14> attempt to establish the requested TCP session (for CONNECT) or bind a socket (for BIND) using the first resolvable and reachable address.</t>
          </li>
          <li>
            <t>Resolution Failure: If the domain cannot be resolved, or if the resolver returns an error, the server <bcp14>MUST</bcp14> consider the request failed. It <bcp14>SHALL</bcp14> return a reply packet with <tt>CD = 91</tt> and <bcp14>MUST</bcp14> immediately close the connection to the client.</t>
          </li>
        </ul>
      </section>
      <section anchor="response-generation">
        <name>Response Generation</name>
        <t>Following the completion (success or failure) of the request processing, the server <bcp14>MUST</bcp14> return an 8-octet reply packet. For SOCKS 4A <tt>CONNECT</tt> operations, the <tt>DSTPORT</tt> and <tt>DSTIP</tt> fields in the reply are typically set to zero and <bcp14>SHOULD</bcp14> be ignored by the client. For <tt>BIND</tt> operations, these fields <bcp14>MUST</bcp14> contain the specific port and IP address where the SOCKS server is listening for the inbound connection.</t>
        <table anchor="socks4a-rep-format">
          <name>SOCKS 4A Reply Structure</name>
          <thead>
            <tr>
              <th align="left">Field</th>
              <th align="left">Description</th>
              <th align="left">Size (bytes)</th>
              <th align="left">Value/Notes</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">VN</td>
              <td align="left">Reply Version</td>
              <td align="left">1</td>
              <td align="left">0x00 (Null byte)</td>
            </tr>
            <tr>
              <td align="left">CD</td>
              <td align="left">Result Code</td>
              <td align="left">1</td>
              <td align="left">0x5A (Granted), 0x5B (Rejected/Failed), etc.</td>
            </tr>
            <tr>
              <td align="left">DSTPORT</td>
              <td align="left">Destination Port</td>
              <td align="left">2</td>
              <td align="left">Ignored for CONNECT; provided for BIND</td>
            </tr>
            <tr>
              <td align="left">DSTIP</td>
              <td align="left">Destination IP</td>
              <td align="left">4</td>
              <td align="left">Ignored for CONNECT; provided for BIND</td>
            </tr>
          </tbody>
        </table>
      </section>
    </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>
    </section>
  </middle>
  <back>
    <references anchor="sec-combined-references">
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>
        <reference anchor="SOCKS4" target="https://www.openssh.org/txt/socks4.protocol">
          <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="SOCKS">
          <front>
            <title>SOCKS</title>
            <author initials="D." surname="Koblas" fullname="David Koblas">
              <organization>Netskope</organization>
            </author>
            <date year="1992"/>
          </front>
          <seriesInfo name="1992 Usenix Security Symposium" value=""/>
        </reference>
        <reference anchor="SOCKS4a" target="https://www.openssh.org/txt/socks4a.protocol">
          <front>
            <title>SOCKS 4A: A  Simple Extension to SOCKS 4 Protocol</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="RFC1122">
          <front>
            <title>Requirements for Internet Hosts - Communication Layers</title>
            <author fullname="R. Braden" initials="R." role="editor" surname="Braden"/>
            <date month="October" year="1989"/>
            <abstract>
              <t>This RFC is an official specification for the Internet community. It incorporates by reference, amends, corrects, and supplements the primary protocol standards documents relating to hosts. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="3"/>
          <seriesInfo name="RFC" value="1122"/>
          <seriesInfo name="DOI" value="10.17487/RFC1122"/>
        </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>
        <reference anchor="RFC5891">
          <front>
            <title>Internationalized Domain Names in Applications (IDNA): Protocol</title>
            <author fullname="J. Klensin" initials="J." surname="Klensin"/>
            <date month="August" year="2010"/>
            <abstract>
              <t>This document is the revised protocol definition for Internationalized Domain Names (IDNs). The rationale for changes, the relationship to the older specification, and important terminology are provided in other documents. This document specifies the protocol mechanism, called Internationalized Domain Names in Applications (IDNA), for registering and looking up IDNs in a way that does not require changes to the DNS itself. IDNA is only meant for processing domain names, not free text. [STANDARDS-TRACK]</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="5891"/>
          <seriesInfo name="DOI" value="10.17487/RFC5891"/>
        </reference>
        <reference anchor="RFC1035">
          <front>
            <title>Domain names - implementation and specification</title>
            <author fullname="P. Mockapetris" initials="P." surname="Mockapetris"/>
            <date month="November" year="1987"/>
            <abstract>
              <t>This RFC is the revised specification of the protocol and format used in the implementation of the Domain Name System. It obsoletes RFC-883. This memo documents the details of the domain name client - server communication.</t>
            </abstract>
          </front>
          <seriesInfo name="STD" value="13"/>
          <seriesInfo name="RFC" value="1035"/>
          <seriesInfo name="DOI" value="10.17487/RFC1035"/>
        </reference>
      </references>
    </references>
    <?line 173?>

<section anchor="operational-considerations-and-implementation-notes">
      <name>Operational Considerations and Implementation Notes</name>
      <t>The following behaviors were observed in historical deployments of SOCKS 4A to address specific network constraints and interoperability challenges.</t>
      <section anchor="proxy-chaining-and-relaying">
        <name>Proxy Chaining and Relaying</name>
        <t>In multi-tiered network environments, a SOCKS server (the "intermediate proxy") may itself be configured to use another SOCKS server (the "upstream proxy") for outbound connectivity. When an intermediate proxy receives a SOCKS 4A request:</t>
        <ul spacing="normal">
          <li>
            <t>Recursive Resolution: The intermediate proxy may attempt to resolve the DOMAIN locally. If successful, it may then downgrade the request to a standard SOCKSv4 CONNECT/BIND using the resolved IPv4 address when communicating with the upstream proxy.</t>
          </li>
          <li>
            <t>Transparent Relaying: If the intermediate proxy lacks DNS access or is configured for "blind" relaying, it passes the SOCKS 4A request—including the 0.0.0.x DSTIP signaling and the DOMAIN field—intact to the upstream proxy. This delegates the resolution responsibility to the edge of the network.</t>
          </li>
        </ul>
        <t>This mechanism was frequently employed in "firewall-behind-firewall" scenarios where only the outermost gateway possessed external name resolution capabilities.</t>
      </section>
      <section anchor="client-side-resolution-leakage-and-server-robustness">
        <name>Client-Side Resolution "Leakage" and Server Robustness</name>
        <t>While the SOCKS 4A extension was primarily designed for clients unable to perform local DNS lookups, many "SOCKSified" application libraries (such as those using <tt>LD_PRELOAD</tt> or global proxy settings) exhibited "leaky" behavior.</t>
        <ul spacing="normal">
          <li>
            <t>Pre-resolution: A client might resolve a domain name locally but still initiate a SOCKS 4A request using that domain name rather than the resolved IP address.</t>
          </li>
          <li>
            <t>Server Interoperability: To ensure maximum compatibility with various client stacks, historical SOCKS 4A server implementations typically did not validate whether the client <em>needed</em> to use 4A. A server would process any request matching the 0.0.0.x DSTIP pattern as a 4A request, regardless of the client's network location or supposed capabilities.</t>
          </li>
        </ul>
        <t>This permissive approach was essential for maintaining a uniform interface across diverse application environments, though it occasionally resulted in redundant DNS queries if both the client and the server performed the same resolution.</t>
      </section>
    </section>
    <section anchor="security-analysis">
      <name>Security Analysis</name>
      <t>This section provides an analysis of the security implications introduced by the SOCKS 4A extension. As an extension to SOCKSv4, it inherits the fundamental insecurities of the base protocol while introducing new vectors related to remote name resolution.</t>
      <section anchor="dns-privacy-and-information-leakage">
        <name>DNS Privacy and information Leakage</name>
        <t>SOCKS 4A functions as a countermeasure against DNS leakage at the client-side network layer. In the base SOCKSv4 protocol, the Requirement for the client to provide a literal IPv4 address necessitates a local DNS lookup. This transaction is typically unencrypted and occurs outside the proxy tunnel, exposing the destination hostname to local network observers and the DNS recursive resolver.</t>
        <t>By delegating resolution to the SOCKS server, the client encapsulates the intent (the DOMAIN string) within the TCP session established to the SOCKS server. However, this merely shifts the point of leakage; the SOCKS server’s own DNS queries may still be observable unless the server implements encrypted DNS transport (e.g., DNS over TLS).</t>
      </section>
      <section anchor="server-side-request-forgery">
        <name>Server-Side Request Forgery</name>
        <t>The SOCKS 4A resolution mechanism enables a primitive form of Server-Side Request Forgery. Because the server performs resolution and subsequent connection on behalf of the client, a malicious client may use the SOCKS server to:</t>
        <ul spacing="normal">
          <li>
            <t>Probe Internal Infrastructure: Access or scan hostnames and IP addresses that are non-routable or firewalled from the public internet but reachable from the SOCKS server’s internal interface.</t>
          </li>
          <li>
            <t>Resolve Split-Horizon DNS: Enumerate internal DNS records that are only visible to the SOCKS server's configured resolvers.</t>
          </li>
        </ul>
        <t>Implementations <bcp14>SHOULD</bcp14> employ strict egress filtering and Access Control Lists (ACLs) to prevent the SOCKS server from connecting to loopback addresses (127.0.0.0/8), private address space (RFC 1918), or link-local addresses.</t>
      </section>
      <section anchor="denial-of-service-and-resource-exhaustion">
        <name>Denial of Service and Resource Exhaustion</name>
        <t>The variable-length nature of the SOCKS 4A request introduces two primary vectors for resource exhaustion:</t>
        <ol spacing="normal" type="1"><li>
            <t>Memory Exhaustion: A SOCKS 4A request involves two variable-length NULL-terminated strings (USERID and DOMAIN). An implementation that fails to enforce strict bounds on these fields during the "read-until-NULL" phase is vulnerable to heap exhaustion. Servers <bcp14>MUST</bcp14> enforce a maximum buffer limit (<bcp14>RECOMMENDED</bcp14> 255 octets for DOMAIN) and terminate connections that exceed this limit without a NULL terminator.</t>
          </li>
          <li>
            <t>Resolver Tarpitting: DNS resolution is an asynchronous, I/O-bound operation. A client may initiate numerous concurrent 4A requests targeting non-responsive or slow DNS authoritative servers. This can exhaust the server's thread pool or file descriptors. Servers <bcp14>MUST</bcp14> implement a per-request resolution timeout.</t>
          </li>
        </ol>
      </section>
      <section anchor="lack-of-cryptographic-integrity-and-authentication">
        <name>Lack of Cryptographic Integrity and Authentication</name>
        <t>SOCKS 4A, like its predecessor, provides no facility for session encryption, message integrity, or robust authentication.</t>
        <ul spacing="normal">
          <li>
            <t>Identity Spoofing: The <tt>USERID</tt> field is provided by the client without any cryptographic proof of identity. It is trivial to spoof and <bcp14>SHOULD NOT</bcp14> be relied upon for security-critical authorization.</t>
          </li>
          <li>
            <t>Active Interception: The entire handshake, including the <tt>DOMAIN</tt> string, is transmitted in plaintext. An attacker in the path between the client and the SOCKS server can perform a Man-in-the-Middle (MITM) attack, observing the destination domain or modifying the server's reply to redirect the client.</t>
          </li>
        </ul>
        <t>Implementations requiring confidentiality or integrity <bcp14>MUST</bcp14> wrap the SOCKS 4A transaction in a secure transport layer, such as TLS or an SSH tunnel.</t>
      </section>
    </section>
    <section numbered="false" anchor="original-author">
      <name>Original Author</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:
H4sIAAAAAAAAA81b25Ibx5F9x1eUoQdhGADI4WVFji3b4MzQnPXcPBhKoVAo
dgrdBaA9ja52XzADktrwR+zLvu237Kf4S/ZkZlV1NwDacmxsxFISBTS665KX
kyczq0ejUa9KqtQcqf706viPU3Vd2MpGNlXfmaJMbKZeTvo9PZsVZh3uoUuR
rszCFpsjtUzKyhZJ1OvFNsr0CmPFhZ5Xo7XOIjMqbXRfjtYv9ejZYa+sZ6uk
pHGrTY4bkyw2ucFfWdXD+C96PV1XS1sc9dSop/BnXqepjHmis8Sk6l/xpVTf
0dB8gy0W+OGjrjDmkTprjUe/mpVOUqznz7SW39u6Sq29H0d21etltljhqbXB
XIr39fKIn8GfjkiO1ETlXipzW6jb42u68LhROipsWap5UpgHnaZl3w8QduH/
yB5+SLLF6ESrc2Oan7CDI3V5eqymm7Iyq1Kd65ktNGS6Garj6e1xWJUuFqaC
wKsqL4+ePn14eBhb7LYsl2MM8rR6rJ6ytF+O/Xr91vbv7B8t90Svk1j90c5S
XW6v11TlPSb3l0tTJKZMsrk9Uodv3jxXH0qTJY9qaqK6SKoNNrfKbZnUK/9E
DAOSe4P89f5lwt5IB2qarPLUqNPHCnsm06yscjcEs/3/ogHdqKBHUmnZ2s27
42/eHLpPh4fPn7uPb56/eeGvvnn+uvn4xn188eqVv/fFi3955T6+et0M9uwF
rvZGo5HSs7IqdFT1erfwTwXPrFdwClXmJkrmUJWX3GSodKZMW6bV0rhfAwYE
BxgrHq+5H2ZvH/xoUZpgkpIG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