* fix(security): enforce transport and WebSocket limits (#4752)
- x-gateway ws-proxy: release a connection slot once per connection;
close/error on both sockets decremented `active` up to four times,
which defeated the 500-connection cap.
- mcp http transport: /ws now has maxPayload (maxMessageSize, default
10 MiB) and checks the bearer token in verifyClient, before the
upgrade, using the same Authorization header as the HTTP routes
(no ?token=). Unset token entries are skipped instead of throwing.
- mcp http transport: cap legacy SSE streams on GET /mcp
(maxSseClients, default 100); extra streams get 503 + Retry-After.
- agent-federation fallback WebSocket listener: maxPayload (default
4 MiB, configurable) instead of the ws 100 MiB default.
- agentbbs sync: redirect "error", reject an oversized Content-Length
up front, and stream the body with a running byte cap instead of
buffering it whole.
Each limit has a test.
* fix(mcp): keep ?token= on /ws, checked before the upgrade (#4752)
Browsers cannot set Authorization on a WebSocket, so dropping ?token=
would cut browser clients off /ws and make the HTTP transport behave
differently from the standalone WebSocket transport. verifyClient now
takes the token from the Authorization header or, failing that, from
?token=, still before the upgrade and still failing closed on an empty
token list. ADR-479 describes the new check.
Also:
- maxMessageSize and maxSseClients fall back to their defaults unless
they are positive numbers.
- shared/src/mcp/transport/http.ts: /ws gets maxPayload (maxMessageSize,
default 10 MiB) instead of the ws 100 MiB default.
* chore(ruflo-x-gateway): bump to 0.10.5 for the ws-proxy slot fix
Co-Authored-By: RuFlo <ruv@ruv.net>
* chore(leaves): shared 3.0.9 for the /ws payload cap (#4752)
The /ws maxPayload change in shared/src/mcp/transport/http.ts only reaches
users through a standalone shared publish. shared 3.0.9 is published; the CLI
and root manifests pin it and both lockfiles follow.
Co-Authored-By: RuFlo <ruv@ruv.net>
* test(ci): list the x-gateway ws-proxy node:test file with its siblings
Root vitest cannot run plugins/ruflo-x-gateway node:test files (they run via
the plugin's npm test), so each one is listed in ci-test-baseline.txt. The new
ws-proxy test was missing, which failed the ratchet with 'No test suite found'.
Co-Authored-By: RuFlo <ruv@ruv.net>
---------
Co-authored-by: Rutvij97 <218486544+Rutvij97@users.noreply.github.com>
Co-authored-by: rUv <ruv@ruv.net>
Co-authored-by: r <r@x>