Skip to content

WebSocket routes have no Origin validation (CSWSH risk when auth relies on cookies) #225

Description

@ZhuchkaTriplesix

Where: src/websocket.rs, src/dispatch.rs (run_rsgi_websocket).

There is no built-in check of the Origin header on WebSocket upgrade. Browsers don't enforce CORS/SOP for WebSocket connections, so if a deployment authenticates WebSocket connections via a cookie (rather than a token passed explicitly in a message), any origin can open a cross-site WebSocket and ride the victim's session — classic CSWSH (Cross-Site WebSocket Hijacking).

Fix direction: provide an opt-in (or documented pattern) for validating Origin on the WebSocket handshake before accept(), e.g. an allowlist parameter on @app.websocket(path, allowed_origins=[...]) or documented guidance to check ws.scope.headers.get("origin") manually when cookie-based auth is used.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions