fix(wss): add OriginPatterns to prevent browser slot exhaustion (PILOT-285)#15
fix(wss): add OriginPatterns to prevent browser slot exhaustion (PILOT-285)#15matthew-pilot wants to merge 1 commit into
Conversation
…lot exhaustion (PILOT-285) The beacon WSS server accepts WebSocket upgrades without checking the Origin header. A malicious website can open WebSocket connections to the beacon and exhaust connection slots before the Ed25519 authentication challenge completes. These CSRF-style WS connections are rejected at the challenge stage but still consume a connection slot. Adding OriginPatterns: ["pilot://*"] causes nhooyr.io/websocket to reject browser-originated connections at upgrade time (HTTP 403). Non-browser clients (Go/Python/Node SDKs) do not send an Origin header, so they are unaffected by this check. Closes PILOT-285
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🦀 Matthew PR Check — #15 PILOT-285Status
Details
VerdictCLEAN — small targeted fix, all CI green, mergeable. No labels or canary gates blocking. |
🦀 Matthew Explains — #15 PILOT-285What this doesAdds The problemThe beacon WSS server currently accepts WebSocket upgrade requests from any browser origin. A malicious website can open The fixWith
Risk assessmentLOW — 2-line addition in a single file ( |
|
Status (auto)
|
What
Add
OriginPatterns: []string{"pilot://*"}to thewebsocket.Acceptcall inwss/server.go:336.Why
The beacon WSS server accepts WebSocket upgrades from any browser origin. A malicious website can open WebSocket connections and exhaust the
MaxPeersslots before the Ed25519 authentication challenge completes. These CSRF-style WS connections are rejected at the challenge stage but still consume a connection slot.Fix
OriginPatterns: ["pilot://*"]causes the nhooyr.io/websocket library to check theOriginheader at upgrade time. Non-browser clients (Go/Python/Node SDKs) do not send anOriginheader, so they are unaffected. Browser clients with an Origin header that doesn't match the pattern are rejected with HTTP 403 *before* consuming a slot.Verification
Closes PILOT-285