The vulnerability, identified as GHSA-mjf5-7g4m-gx5w, is a WebSocket hijacking issue in the Storybook development server. The root cause is the lack of origin validation on the WebSocket upgrade handler, which allows a malicious website to connect to the local server without restriction.
Analysis of the provided patch commits reveals that the vulnerability is located in the ServerChannelTransport class, specifically within its constructor. This constructor is responsible for setting up the WebSocket server and its connection handling logic.
In the vulnerable versions, the constructor registers a listener for the HTTP server's upgrade event. This listener would unconditionally upgrade any connection request to the /storybook-server-channel path to a WebSocket. The patch addresses this by introducing a token-based authentication mechanism. A unique token is generated on the server and passed to the client, which must then provide this token as a query parameter (?token=...) when initiating the WebSocket connection. The upgrade handler is modified to validate this token before proceeding with the connection upgrade. If the token is missing or invalid, the connection is rejected.
The vulnerable function is identified as ServerChannelTransport.constructor because it contains the logic that sets up the insecure upgrade handler. This function would appear in a runtime profile when the Storybook dev server is initialized. The analysis of multiple patch commits confirms this finding across different versions of Storybook (7.x, 8.x, 9.x, and 10.x), with the primary difference being the file path of the affected file (code/lib/core-server/src/utils/get-server-channel.ts vs. code/core/src/core-server/utils/get-server-channel.ts).