MOLO-WS-001: WebSocket handshake has no Origin check (CSWSH)
Scope: audit · README · AGENTS
CWE-1385 ("Missing Origin Validation in WebSockets"). Real-world instances of this exact class include CVE-2024-23898 (Jenkins CLI, CVSS 9), CVE-2024-26135 (MeshCentral, CVSS 8.8) and CVE-2023-0957 (Gitpod, CVSS 8.2); the class, not a MoloApp-specific CVE.
Source
Relevance to MoloApp
A browser attaches the page's Origin to a WebSocket handshake automatically and also
attaches same-site cookies, the same way it would to any other cross-site request.
If the server accepts the handshake without checking Origin against an allow-list,
any page an authenticated victim visits can open a WebSocket to the app and ride the
victim's session, a Cross-Site WebSocket Hijacking. Unlike ordinary CSRF, the
Sec-Fetch-Site and SameSite-cookie defenses that CsrfGuard relies on for regular
requests do not automatically apply to the opening handshake unless the WebSocket
layer checks Origin itself.
src/realtime/websocket/server/handshake_validator.cpp, HandshakeValidator::validate
checks method, Upgrade, Connection, the key's shape, version and subprotocol; it
never reads Origin, and HandshakeConfig (handshake_validator.h) has no
allowed-origins field to check against.
What the check does
This class is "a pure function of request plus config: no I/O" (the header's own
comment) and is not wired to any upgrade route in the example app today, so there is
no live server to drive it through; the check instead compiles a tiny harness
(reproduce.cpp) against the real handshake_validator.cpp/sha1.cpp/base64.cpp/
realtime_metrics.cpp and calls HandshakeValidator::validate directly with a
well-formed handshake carrying Origin: https://evil.example. PASS means a future
origin check rejected it; FAIL means it was accepted (ok == true).
Caveats
This is not a claim that an upgrade route exists in the shipped example today; it is a check on the shared validator every real route would have to use, matching the header's own description of the class as I/O-free and route-independent.
Run: make test in this directory, or make -C audit test from the repo root.