Summary
Strawberry GraphQL's legacy graphql-ws WebSocket subscription handler failed to enforce completion of the connection_init handshake before accepting subscription start messages.
An unauthenticated remote client using the graphql-ws subprotocol could open a WebSocket and immediately start subscriptions, bypassing the on_ws_connect authentication hook that is normally required.
Affected context
This vulnerability appears in Strawberry GraphQL deployments that:
- Expose WebSocket endpoints for GraphQL subscriptions
- Enable or fall back to the legacy
graphql-wssubprotocol handler - Rely on
on_ws_connector equivalent connection hooks to enforce authentication or authorization
The issue manifests when the server assumes that every subscription goes through a connection_init handshake, but the implementation processes start messages even when that handshake did not occur.
Exploit preconditions
- Attack surface: Public or internal WebSocket endpoint used for GraphQL subscriptions (typically at the same path as HTTP GraphQL, e.g.,
/graphql). - Required access: Network-level ability to reach the WebSocket endpoint; no prior authentication is required to attempt exploitation.
- Trigger point: An attacker opens a WebSocket connection using the
graphql-wssubprotocol and sends astart(subscription) message directly, omitting theconnection_initmessage. - Why exploitation is possible: The legacy
graphql-wshandler does not enforce that theconnection_inithandshake has completed before processingstartmessages, so the subscription setup logic runs without the authentication hook (on_ws_connect) ever being invoked.
Why this happens
The root cause is a missing authentication enforcement step in the protocol state machine for the graphql-ws WebSocket handler.
Instead of modeling the connection as a sequence of states (e.g., CONNECTING → INIT_RECEIVED → AUTHENTICATED → SUBSCRIBING) and rejecting out-of-order messages, the implementation accepts start messages regardless of whether a connection_init was previously received and processed.
This maps to CWE-306: Missing Authentication for Critical Function, because the critical operation—creating and running subscription operations, often bound to user-specific data—is allowed to proceed without confirming that the client has been authenticated via the intended hook.
Potential impact
- Unauthorized clients may subscribe to GraphQL channels that were intended to require authentication.
- Attackers could receive real-time data streams (e.g., user updates, notifications, or sensitive domain events) without valid credentials.
- Information exposure about application behavior, schema fields, or internal events via subscription payloads.
- Potential compliance or privacy violations if subscription data contains personally identifiable or regulated information.
General mitigation guidance
Effective mitigation focuses on enforcing authentication and protocol correctness for WebSocket subscription flows:
- Ensure the WebSocket subscription handler enforces a strict protocol state machine that rejects
startmessages until a validconnection_inithas been received and authenticated. - Centralize authentication checks so that subscription creation always runs under an established security context, rather than relying on optional or best-effort hooks.
- Treat WebSocket endpoints as fully privileged entry points: apply the same authentication, authorization, and rate-limiting policies that protect your HTTP GraphQL endpoint.
- Consider implementing server-side guards that validate the presence of user identity, session, or token context at subscription resolution time, not just at connection time.
- Use least privilege principles in subscription logic, limiting the amount and sensitivity of data exposed on any single subscription channel.
How teams detect issues like this
Detection can combine protocol-aware testing, code review, and runtime monitoring:
- Static analysis & code review:
- Inspect WebSocket subscription handlers for explicit checks that
connection_inithas completed before handlingstartmessages. - Look for any code paths that create subscriptions or execute subscription resolvers without verifying authentication state.
- Review usage of hooks like
on_ws_connectand ensure their results are enforced before subscription setup. - Dynamic and security testing:
- Use integration tests or security testing tools to simulate a
graphql-wsclient that sends astartmessage without a precedingconnection_init, and verify that the server rejects the request. - Include protocol misuse test cases in CI pipelines to guard against regressions in WebSocket state handling.
- Runtime monitoring:
- Log WebSocket connection lifecycle events and message types, and alert on anomalous patterns, such as
startmessages from connections with no recorded authentication step. - Instrument subscription resolvers to record whether an authenticated principal is associated with each subscription; investigate any unauthenticated subscriptions.

