Every new protocol arrives at a door that was installed before it was born. WebSocket — the two-way web connection that became RFC 6455 in December 2011 — arrived at the door of the proxy, and paid the toll in four-byte coins.
The toll is called masking. Every frame a client sends to a server carries a 32-bit key, and the payload is scrambled with it. The key travels inside the very frame it protects, in plain sight, so anyone holding the wire can undo the scramble. Masking is not encryption and was never meant to be. It exists because the web’s middleboxes read bytes and guess, and a protocol that wanted to escape HTTP first had to survive being mistaken for it.
That is RFC 6455 in miniature: a standard that could not govern the installed base, so it bribed it instead.
Why WebSocket begins as an HTTP request
HTTP was built for a client that asks and a server that answers. Chat, games, collaborative documents and trading screens needed the server to speak without being asked, and for a decade they faked it — long polling, Comet, hidden iframes, a response held open while everyone pretended a stall was an event.
In 2008 Michael Carter proposed something cleaner: one TCP connection, frames in both directions, no repeated headers. Ian Hickson carried the idea into HTML5. What came out the other side burned through eighteen drafts in the IETF’s HyBi working group, several of them mutually incompatible, before draft-17 became RFC 6455, edited by Ian Fette and Alexey Melnikov.
The handshake it settled on is deliberately, almost insultingly, ordinary. The client sends an HTTP request with Upgrade: websocket and Connection: Upgrade. The server answers 101 Switching Protocols. From that instant the connection stops being HTTP and starts being frames.
That choice was a toll paid in advance. A protocol arriving as raw TCP on a fresh port would have been simpler to build and impossible to route through the decade of proxies, firewalls, load balancers and transparent caches the web had already installed. So WebSocket knocked on the front door wearing HTTP’s coat, and every box in the path waved it through.
The cache-poisoning attack that made masking mandatory
The handshake explains the disguise. It does not explain why the payload is scrambled, which is the part most engineers get wrong.
RFC 6455 describes the attack it was built against. A client upgrades a connection, then sends bytes that look like an HTTP request for a popular resource. The peer replies with bytes that look like the response. An intermediary that never understood the upgrade — but understands HTTP very well — sees a request and a response, and caches the response for everyone behind it. The cache is poisoned, and the poison was delivered by a protocol the proxy had never heard of.
Framing alone did not fix it, because a nonconformant middlebox could skip the frame header and act on the payload anyway. So the specification went further: “the defense adopted is to mask all data from the client to the server, so that the remote script (attacker) does not have control over how the data being sent appears on the wire”.
Read that twice. The mask protects the infrastructure from the client’s content. It does not protect the content from the infrastructure. The direction of protection is the whole argument, and it gets reversed every time someone assumes masking is a weak cousin of TLS.
Masking is not encryption — and the difference is the point
The key is 32 bits. It sits in the frame it protects. The server strips it off before parsing a single byte, and so can anyone else holding a packet capture. What the key buys is not secrecy but unpredictability: the attacker cannot choose how the bytes look to a middlebox, because the attacker does not choose the key.
The rules are correspondingly fussy. A client must pick a fresh key for every frame from a strong source of entropy, so that a server or proxy cannot learn the pattern and predict the next one. A server must not mask at all — “A server MUST NOT mask any frames that it sends to the client” — because the attack only runs uphill.
The cost is permanent. Four extra bytes on every client frame, forever. A random-number draw per frame on every client on earth. A protocol designed to escape HTTP carries that tax in every message it will ever send.
Who pays the WebSocket toll — and why it is still being paid
Everyone in the path pays something. Clients pay the entropy and the four bytes. Servers pay the unmasking loop. Proxies pay the attention required to notice an upgrade at all. None of it is large; all of it is permanent, which is how infrastructure bills actually work.
The bill has been renewed twice. RFC 8441 in 2018 bootstrapped WebSocket over HTTP/2 using the extended CONNECT method. RFC 9220 in 2022 did the same for HTTP/3. Masking survived both. The protocol has now been carried by three generations of HTTP, and has never once been allowed to simply arrive as itself.
Lu Heng’s published Note on running-code primacy states the general rule: “A proposal is not reality. A recommendation is not reality. A document is not reality.” WebSocket supplies the corollary. Neither is a standard. The proxies were reality.
What WebSocket teaches about lock-in and the installed base
There is a comfortable story about protocol design in which the better idea wins on its merits and the old equipment is retired. WebSocket is the counter-example, and a friendly one: the old equipment was not wrong, exactly. It was simply already there, configured by people who had gone home, and nobody was going to fly to every data centre on earth to explain a new frame format.
So the protocol negotiated. It hid inside HTTP to get through the door, then scrambled its own sentences so the neighbours could not misread them. Neither decision is elegant. Both are why the protocol works in a browser sitting behind a corporate firewall that has not been updated since 2014.
That is the trade every standard eventually makes. Legitimacy in protocol design is not granted by a working group; it is granted by the boxes already in the path. A specification can be right and still be ignored. WebSocket chose to be deployed.
The middleboxes were never going to be persuaded. They were going to be paid — four bytes at a time, in a currency they could not read. The installed base is the only institution that never holds an election and never loses one.
Member Briefing
Read the full trend briefing
Members read the full briefing with the source notes behind every finding.
Strategic Circle
A daily briefing in your language, built from changes we have verified.
Join for USD 20/monthCancel anytime.
Members also get the full research library, a daily briefing on the networks they follow and the private forum.






