You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[SECURITY] Enforce MCP request limits and HTTP timeouts #828
Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.
CWEs: CWE-770.
Finding and evidence
Config exposes max_concurrent_requests and request_timeout, but the former only constructs an unused semaphore and the latter is never applied to requests (pkg/mcp_server/config.go, pkg/mcp_server/server.go). HTTP uses ListenAndServe/ListenAndServeTLS without an explicitly configured server timeout policy (pkg/mcp_server/server.go).
A current in-memory test configured max_concurrent_requests=1 and request_timeout=20ms. Two blocking calls both reached the backend; both remained active until the test released them after 100ms. This verifies the advertised controls are ineffective without performing a resource-exhaustion attack.
Required outcome
Acquire bounded admission in shared tool middleware, release on every exit path, and make waiting cancellation-aware.
Apply and propagate request deadlines to backend work; define finite defaults and invalid/zero-value semantics.
Use an explicit http.Server with suitable header/idle/read limits and bounded request bodies. Choose streaming-compatible deadlines rather than indiscriminately breaking SSE/long-lived responses.
Validation and acceptance
Test concurrent slow mock calls, queue cancellation, deadline propagation, refusal/error/panic permit release, oversized bodies and slow headers. Add black-box HTTP and stdio tests proving liveness and the configured limits. Preserve streaming behavior and authenticated HTTP access.
Scope and related work
#803 remains the owner for ongoing fuzz infrastructure; this issue fixes concrete missing controls. Provider response-size limits and pgwire connection limits are separate boundaries.
Activity
fix(mcp_server): enforce max_concurrent_requests and request_timeout …