Fixes
What to ask them to fix
The report should name the check that was missing, in server language.
Reports that spell out the exact server-side fix move through engineering much faster. Pick the checks below that match what broke during your test.
Origin
Section titled “Origin”- Allow only exact Origin values the application owns.
- Reject Origin null.
- Reject a value that merely contains the real host.
- Reject a value that merely starts with the real host.
- Reject a bad Origin in the upgrade handler before status 101.
The server is the component that enforces that list. A CORS header on an HTTP route does not do this job.
Session
Section titled “Session”- Authenticate the handshake.
- Close the socket when the session ends.
- Close the socket when the password changes.
- Close the socket when the role changes.
- Before a sensitive action, check the session again if the socket stays open.
A periodic re-check is extra. The action check is the one that stops a stale socket from trading.
A short-lived ticket is cleaner than a long-lived session cookie. The normal HTTP login issues the ticket. The handshake presents it once. The other origin cannot read the ticket if the HTTP response is not readable cross-site.
- Do not put a bearer token in the query string.
- Do not treat a cookie the browser will attach as a CSRF token.
Frames
Section titled “Frames”- Authorize the action name on every sensitive frame.
- Authorize the object id on every sensitive frame.
- Recompute room membership when the tenant or the role changes.
- Remove the socket from rooms when the session ends.
- Escape or encode text before a client inserts a broadcast into the page.
- Apply the same SQL and command checks you use on the HTTP API.
Limits and transport
Section titled “Limits and transport”- Limit how many frames one socket may send in a short window.
- Limit how many sockets one account may hold.
- Limit the payload size.
- Serve browser clients with
wssonly. - Do not offer
wson a host that also serves pages. - If a non-browser client must omit Origin, put it on a separate listener.
A separate listener can use mutual TLS. A missing-Origin exception on the public browser host is how the curl test turns into a bug.
Rooms and actions
Section titled “Rooms and actions”Treat a room name as an authorization decision. Treat an action name the same way. Hide nothing important by omitting it from the UI. The bundle will still contain the string, and the lowest role will send it.
Next, the epilogue explains why these checks keep going missing.
WebSocketFor authorized testing only.