Skip to content

fix(mcp): hardening gaps: Mongo maxTimeMS and response size, list sizes, session limits, a few unhandled errors #1776

Closed

Description

@ZhuchkaTriplesix

Smaller findings from the MCP review:

  • Mongo timeout (`McpMongoService._withSession`): the Dart future is dropped and the session closed, but no `maxTimeMS` is sent, so a heavy `$regex` or `$expr` may keep running server-side. The response is capped per field (4096 chars) but not in total.
  • `McpMongoGuard.maxKeys` counts map keys only; a huge `$in` list is not limited.
  • `McpSocketHost`: after the handshake there is no cap on a line's length or on the number of concurrent sessions; an unterminated line buffers without bound.
  • `McpAccessStore.setReadable` reads, changes and writes the list without a lock; two quick toggles can lose one.
  • `McpServerController._persist` is `unawaited` without error handling; a failed write goes only to the zone handler.
  • `McpServerController._start`: if `host.start()` throws after binding the socket, `_host` stays null and the host keeps listening with a token nobody has.
  • `McpQueryService`: a non-`McpToolException` thrown in a body is redacted by `_guarded` without the connection row, so the connection's own secrets are not masked.

Found in the MCP review.

Activity

  1. added
    bugSomething isn't working
    P3Low priority / Polish & Enhancements
    securitySecurity related
    on Oct 25, 2026
  2. added 2 commits that reference this issue on Oct 25, 2026
  3. ZhuchkaTriplesix commented on Oct 25, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Fixed on dev (#1808 for the rest of #1776 after #1802; #1809 for #1758). Closing by hand: the PRs target dev.

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

    P3Low priority / Polish & EnhancementsbugSomething isn't workingsecuritySecurity related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions