<?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.6.31 (Ruby 3.0.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-damjanovic-websockets-nomasking-00" category="exp" version="3">
  <!-- xml2rfc v2v3 conversion 3.17.1 -->
  <front>
    <title>WebSocket Extension to disable masking</title>
    <seriesInfo name="Internet-Draft" value="draft-damjanovic-websockets-nomasking-00"/>
    <author initials="D." surname="Damjanovic" fullname="Dragana Damjanovic">
      <organization>Microsoft</organization>
      <address>
        <email>dragana.damjano@gmail.com</email>
      </address>
    </author>
    <date year="2023" month="May" day="19"/>
    <area>ART</area>
    <workgroup>HTTP</workgroup>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>The WebSocket protocol specifies that all frames sent from the client to the
server must be masked. This was introduced as a protection against a possible
attack on the infrastructure. With careful consideration, the masking could be
omitted when intermediaries do not have access to the unencrypted traffic.</t>
      <t>This specification introduces a WebSocket extension that disables the mandatory
masking of frames sent from the client to the server. The extension is allowed
only under special circumstances where masking is known to be unnecessary.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t>The WebSocket protocol specifies that all frames sent from the client to the
server must be masked <xref target="RFC6455"/>. This was introduced as a protection against
a possible attack on the infrastructure described in <xref section="10.3" sectionFormat="of" target="RFC6455"/>. The attack can be performed on intermediaries, such as proxies and
it could cause cache poisoning. Using end-to-end encryption, the attack can be
mitigated without the use of masking. This is because every intermediary will
be denied access to the unencrypted traffic, which prevents the caching attack.
The masking has been made mandatory for the connection using TLS to protect the
infrastructure that is behind TLS terminating proxies.</t>
      <t>This specification introduces a WebSocket extension that disables the masking
of frames sent from the client to the server. The support for the extension
will be advertised by the client (see <xref section="9" sectionFormat="of" target="RFC6455"/>). The server
may accept the extension only after careful consideration discussed in Section
<xref target="serv"/>. The extension may only be advertised if secure transport is used.</t>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</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>
    </section>
    <section anchor="the-no-masking-extension">
      <name>The "no-masking" extension</name>
      <t>The "no-masking" extension is negotiated using the WebSocket extension
mechanism described in <xref section="9" sectionFormat="of" target="RFC6455"/>. The client advertises support
for the extension by sending "no-masking" in the list of supported extensions
sent in the "Sec-WebSocket-Extensions" header field. The server accepts the
extension, by sending "no-masking" in the "Sec-WebSocket-Extensions" header
value.</t>
      <t>The client <bcp14>MUST NOT</bcp14> send the extension if a non-secure connection is not used
on the connection. The server <bcp14>MUST</bcp14> reject the upgrade request if the
"no-masking" extension is advertised on a non-secure connection.</t>
      <t>If the "no-masking" extension is negotiated the client and the server behavior
are:</t>
      <ul spacing="normal">
        <li>The client <bcp14>MUST</bcp14> send data to the server without masking. The client sets the
field "frame-masked" to 0 on all frames. As defined in <xref target="RFC6455"/>, the field
"frame-masking-key" will not be present.</li>
        <li>The server must only accept frames with the field "frame-masked" set to 0.
If the server receives a frame with the field "frame-masked" set to 1, it <bcp14>MUST</bcp14>
close the connection with the status code 1002 define in <xref section="7.4.1" sectionFormat="of" target="RFC6455"/>.</li>
      </ul>
      <section anchor="serv">
        <name>Server behavior considerations</name>
        <t>If a WebSocket connection is end-to-end encrypted the server can accept the
"no-masking" extension.</t>
        <t>In case the connection is not end-to-end encrypted <bcp14>MUST NOT</bcp14> accept the
"no-masking" extension.</t>
        <t>Intermediaries that terminate TLS connection should remove the extension from
the "Sec-WebSocket-Extensions" header field.</t>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>TBA</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>IANA has registered the following WebSocket extension name in the "WebSocket
Extension Name Registry" defined in <xref target="RFC6455"/>.</t>
      <t>Extension Identifier: no-masking</t>
      <t>Extension Common Name: Disable the WebSocket client-to-server masking</t>
      <t>Extension Definition: This document.</t>
      <t>Known Incompatible Extensions: None</t>
      <t>The "no-masking" extension name is used in the "Sec-WebSocket-Extensions"
header in the WebSocket opening handshake to negotiate disabling of the
client-to-server masking.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="RFC6455" target="https://www.rfc-editor.org/info/rfc6455" xml:base="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6455.xml">
        <front>
          <title>The WebSocket Protocol</title>
          <author fullname="I. Fette" initials="I." surname="Fette"/>
          <author fullname="A. Melnikov" initials="A." surname="Melnikov"/>
          <date month="December" year="2011"/>
          <abstract>
            <t>The WebSocket Protocol enables two-way communication between a client running untrusted code in a controlled environment to a remote host that has opted-in to communications from that code.  The security model used for this is the origin-based security model commonly used by web browsers.  The protocol consists of an opening handshake followed by basic message framing, layered over TCP.  The goal of this technology is to provide a mechanism for browser-based applications that need two-way communication with servers that does not rely on opening multiple HTTP connections (e.g., using XMLHttpRequest or  s and long polling). [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="6455"/>
        <seriesInfo name="DOI" value="10.17487/RFC6455"/>
      </reference>
      <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119" xml:base="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
        <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" target="https://www.rfc-editor.org/info/rfc8174" xml:base="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml">
        <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>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA71Y624buRX+z6dglT/twiNIqXe3EdqiWjtFjPqS2g4Wi6I/
KA4lcT1DTkmOHdXIu+yz9Mn6HZKai2xvEqCoYcAzHPJcvvOdC10UBQs6VGrB
Jz+q1Y2Vdyrwtx+DMl5bw4PlpfZiVSleC3+nzWbCSiuNqHGidGIdilLUPwtj
77UsHtTKRwm+MDbvL2YzJkVQG+t2C64+Nozpxi14cK0Pr2ezN7PXTDglFnx5
fcserLvbONs2C/7u9vY9u1M7LJULfmaCckaF4pSUMibasLVuwXjBOH6SQfi2
EUbw086k+NE6rOp/iwCPFvxCS2e9hRD6pmqhq+gKnZxmZ/6yo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