Visual RFC.
ALL RFCs / RFC 6455
Read the RFC ↗
RFC 6455 / PROTECT THE TRANSPORT

Client masking

05

Each client frame uses a new unpredictable masking key, repeated across its payload bytes.

Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

DIAGRAM§ 5.3 ↗
RFC 6455 · § 5.3EXAMPLE
3 / 3
Client maskingA five-byte payload is XORed with a repeating four-byte key; applying the same key recovers the original bytes.Client masking, byte by byteIllustrative bytes in hexadecimalpayload48656C6C6Fkey37FA213D37Four unpredictable key bytes repeat; key[4] = key[0]wire XOR7F9F4D5158XOR again48656C6C6FThe key is sent too: masking is not encryptionXOR again to recover the original payload
03
Recover the original payload.

The server uses the transmitted key; anyone observing the key can also undo the mask.

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
KEY POINT

Mask every client frame; use TLS for confidentiality.

  • The client chooses a fresh unpredictable 32-bit masking key for every frame, including control frames.
  • Payload byte i is XORed with key byte i modulo 4. The receiver uses the same operation to recover it.
  • Masking protects intermediaries from attacker-chosen wire patterns; the key travels with the frame, so masking does not hide content.
DETAILS

The byte example is deliberately tiny. Masked client frames and unmasked server frames are required even when TLS is used.

Read the RFC section ↗

Diagrams simplify the RFC. Read the linked sections for complete requirements.

Privacy
All chapters in this RFC
  1. Opening handshake
  2. Messages in both directions
  3. Frame fields
  4. Fragments and control frames
  5. Client masking
  6. Closing the connection

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗