GHSA-g5vv-q72c-7j78 @anephenix/hub: Unauthenticated WebSocket RPC Waiter Resource Exhaustion
Summary`@anephenix/hub` starts a `setInterval` polling loop for every incoming WebSocket connection to request a client ID via RPC. If the remote client never replies — which requires no authentication or special configuration — the interval and the pending request object are never cleaned up, even after the socket is closed. An unauthenticated attacker who opens many WebSocket connections and ignores all server RPC messages will therefore cause the server to accumulate unbounded timers and heap entries, leading to CPU and memory exhaustion (DoS).DetailsWhen a client connects, `loadDefaultConnectionEventListeners` (registered in `src/lib/index.ts:128`) adds a connection listener that calls `requestClientId({ ws, rpc })` for every new WebSocket (`src/lib/index.ts:262`). `requestClientId` issues an RPC send for the `get-client-id` action (`src/lib/clientId.ts:112`), which internally calls `rpc.send`.Inside `rpc.send`, the payload is pushed onto `this.requests` (`src/lib/rpc.ts:282`) and `waitForReply` is invoked. `waitForReply` starts a `setInterval` that polls `responses[]` every 10 ms for a matching reply (`src/lib/rpc.ts:250`):`clearInterval` is only called when a matching response arrives. There is no timeout path and no socket-close handler that clears either the interval or the `this.requests` entry. The `close` handler registered in `loadDefaultConnectionEventListeners` (`src/lib/index.ts:128–134`) only calls `pubsub.unsubscribeClientFromAllChannels`; it does not cancel pending RPC requests for that socket.**Data flow (source → sink):**`src/lib/index.ts:269` — `wss.on("connection")` accepts any remote WebSocket (no authentication).`src/lib/index.ts:272` — connection listeners are iterated and invoked.`src/lib/index.ts:262` — `requestClientId({ ws, rpc: this.rpc })` is called for every connection by default.`src/lib/clientId.ts:112` — `rpc.send({ ws, action: 'get-client-id' })` creates an RPC request.`src/lib/rpc.ts:282` — `this.requests.push(payload)` registers the pending request.`src/lib/rpc.ts:250` — `setInterval(..., 10)` begins infinite polling; cleanup only happens on a matching response. Socket close does not trigger cleanup.PoC**Prerequisites:** Docker must be available on the host.**Step 1 — Build the verification image:****Step 2 — Run the container:**The container runs `verify.mjs`, which:Starts a `Hub` server on a local port.Opens a WebSocket and waits for the server's `get-client-id` RPC message without replying.Closes the socket and waits 300 ms.Inspects `hub.rpc.requests.length` — it must remain `1` even though `hub.wss.clients.size` is `0`.Opens five more sockets the same way (batch), then verifies that `pendingRpcRequests` equals `6`.**Step 3 — Alternatively, run the Python orchestrator directly:****Expected output (confirmed):**`pendingRpcRequests` grows linearly with the number of unanswered connections and never decreases, confirming the unbounded resource leak.**Minimal inline reproduction** (without Docker, inside the repository after `npm ci && npm run build`):Expected:ImpactThis is an **unauthenticated Denial-of-Service** vulnerability. Any network-reachable `@anephenix/hub` server running with default configuration is affected. An attacker who opens a large number of WebSocket connections and never replies to the server's `get-client-id` RPC causes the server process to accumulate one `setInterval` timer (polling every 10 ms) and one heap object per connection indefinitely. With enough connections this exhausts CPU scheduling time and memory, making the server unavailable to legitimate clients.No authentication, special headers, or knowledge of internal protocol details are required — a plain WebSocket `connect` followed by silence is sufficient.Reproduction artifacts`Dockerfile``poc.py`
CVSS v3.1 score: 7.5