Skip to content

mcp-http transport: no connection cap or read timeouts on the accept loop (slowloris DoS) #190

Closed

Description

@ajianaz

Summary

Full-codebase cora scan (2026-10-06, pre-0.6.0-tag gate) flagged this MAJOR (scan finding #17): the tole serve --transport mcp accept loop in crates/tole-cli/src/mcp_http.rs unconditionally spawns a tokio task per accepted TCP connection with no cap on concurrent connections and no read/idle/header timeouts. An unauthenticated attacker can open many sockets and trickle bytes to pin tasks and file descriptors indefinitely (slowloris-style DoS).

Reference

The sibling REST transport (serve.rs) hardens against exactly this class (Wave 2, #136): MAX_CONNECTIONS = 32 and SERVE_IO_TIMEOUT = 30s. The MCP transport predates the parity fix.

Proposed fix

Mirror the REST transport's controls in mcp_http.rs:

  • connection cap via a tokio Semaphore (permit per connection, acquired before spawn; refused when exhausted), and
  • header/read timeouts — hyper 1.x http1::Builder::header_read_timeout, plus wrapping the body-collection phase in tokio::time::timeout aligned with SERVE_IO_TIMEOUT.

Same class as #136, different face. Should ride the 0.6.0 train before the tag (scan MAJORs are tag blockers per the release gate).

Activity

  1. ajianaz commented on Oct 5, 2026

    @ajianaz
    ContributorAuthor

    Fixed by #191 (merged to develop as 3c254d5): 32-connection semaphore cap, hyper http1 header_read_timeout (30s), and 30s bounds on the auth-header/request-body read phases — the scan's suggested remedy, full CI green, 351/0 local tests.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions