WebSocket Extension to disable masking
Internet-Draft draft-damjanovic-websockets-nomasking-02
Dragana Damjanovic
Microsoft
dragana.damjano@gmail.com
27 February 2024
ART
HTTP
Internet-Draft
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.
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 if the client uses an encrypted connection.
Introduction
The WebSocket protocol specifies that all frames sent from the client to the server must be masked [RFC6455]. This was introduced as a protection against a possible attack on the infrastructure described in Section 10.3 of [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.
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 Section 9 of [RFC6455]). The server may accept or decline the extension. The client can advertise the extension only if an encrypted connection.
Conventions and Definitions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
The "no-masking" extension
The "no-masking" extension is negotiated using the WebSocket extension mechanism described in Section 9 of [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.
The client MUST NOT send the extension if a non-secure connection is used.
If the "no-masking" extension is negotiated the client and the server behavior are:
- The client MUST send data to the server without masking. The client sets the field "frame-masked" to 0 on all frames. As defined in [RFC6455], the field "frame-masking-key" will not be present.
- 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 MUST close the connection with the status code 1002 define in Section 7.4.1 of [RFC6455].
Security Considerations
TBA
IANA Considerations
IANA has registered the following WebSocket extension name in the "WebSocket Extension Name Registry" defined in [RFC6455].
Extension Identifier: no-masking
Extension Common Name: Disable the WebSocket client-to-server masking
Extension Definition: This document.
Known Incompatible Extensions: None
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.
Normative References
[RFC6455]

The WebSocket Protocol
I. Fette
A. Melnikov
December 2011
RFC 6455
DOI 10.17487/RFC6455
[RFC2119]

Key words for use in RFCs to Indicate Requirement Levels
S. Bradner
March 1997
BCP 14
RFC 2119
DOI 10.17487/RFC2119
[RFC8174]

Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words
B. Leiba
May 2017
BCP 14
RFC 8174
DOI 10.17487/RFC8174
Acknowledgments