Skip to content

[SECURITY] Enforce MCP request limits and HTTP timeouts #828

Closed

Description

@jeffreyaven

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions